A small studio in Basra runs three things for its clients: a WordPress site, an n8n workflow and an internal tool written in Node.js. On a bare server, each of them wants its own PHP or Node version, its own libraries and its own database settings, and every upgrade risks breaking one of the others. Docker solves this by putting each application in a of its own, with exactly the versions it needs, isolated from the rest. This guide explains what containers are and how they differ from virtual machines, then walks through installing Docker on a VPS from the official documentation, running your first container, describing a full application with Compose, keeping its data safe with volumes and backups, updating it, and the security basics most beginners miss. The last part covers the web interfaces that make all of this easier.
01Containers and virtual machines: the difference
Your VPS is itself a virtual machine: a hypervisor divides a physical server into machines, each with its own kernel, its own operating system and resources reserved for it. A container works one level higher. It is a process, or a group of processes, that the Linux kernel isolates from the rest of the system: it sees its own files, its own network and its own process list, but it shares the kernel with the server and with every other container.
The files a container starts from come from an : a read-only package with the application, its libraries and the settings it needs, built in layers and pulled from a registry such as Docker Hub. One image can start any number of containers, and deleting a container leaves the image untouched.
| Virtual machine | Container | |
|---|---|---|
| What it carries | A full operating system with its own kernel | The application and its libraries only |
| Start time | Tens of seconds to minutes | Usually a second or two |
| Size | Gigabytes | Tens to hundreds of megabytes |
| Isolation | Strong: separate kernels | Good, but every container shares the host’s kernel |
| Best for | Separating customers, other operating systems | Running many applications side by side on one server |
So the two work together rather than compete: you rent a VPS, which is a virtual machine, and run your applications inside it as containers. Docker on a VPS gives you a clean server where everything you add can be removed without trace, and the same application starts the same way on your laptop, on a test server and in production.
02Install Docker from the official repository
Most distributions ship a package called docker.io or podman-docker, and many guides use a one-line script from get.docker.com. Docker’s own documentation says the script is for testing and development, not production, and asks you to remove unofficial packages first. The reliable route is Docker’s apt or dnf repository, which also keeps Docker updated with the rest of the system.
On Ubuntu 24.04 and Debian 12
# Remove unofficial packages if they are installedsudo apt remove docker.io docker-compose podman-docker containerd runc# Add Docker’s signing key and repositorysudo apt updatesudo apt install ca-certificates curlsudo install -m 0755 -d /etc/apt/keyringssudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.ascsudo chmod a+r /etc/apt/keyrings/docker.ascsudo tee /etc/apt/sources.list.d/docker.sources <<EOFTypes: debURIs: https://download.docker.com/linux/ubuntuSuites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")Components: stableArchitectures: $(dpkg --print-architecture)Signed-By: /etc/apt/keyrings/docker.ascEOF# Install Docker Engine and the Compose pluginsudo apt updatesudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginsudo docker run hello-world
On Debian, replace ubuntu with debian in the two download.docker.com addresses; the rest is the same. The last command downloads a tiny test image and prints a greeting if everything works.
On AlmaLinux 9
AlmaLinux is a rebuild of Red Hat Enterprise Linux, so Docker’s RHEL repository serves it:
sudo dnf -y install dnf-plugins-coresudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.reposudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin# On AlmaLinux the service does not start by itselfsudo systemctl enable --now dockersudo docker run hello-world
Docker’s documentation suggests adding your user to the docker group so you can drop sudo. Know what that means first: whoever controls the Docker daemon can start a container that mounts the whole disk, so membership of the docker group is the same as root. Add only the users you would give root to anyway.
03Your first container
Start an Nginx web server, look at it, then remove it. These six commands are most of what you will type day to day:
# Start Nginx in the background, named web, on port 8080 of the serversudo docker run -d --name web -p 8080:80 nginx:stable# What is running, and what it printedsudo docker pssudo docker logs web# Open a shell inside the containersudo docker exec -it web sh# Stop it and remove it (the image stays)sudo docker stop websudo docker rm web
The -p 8080:80 option port 80 inside the container on port 8080 of the server, so http://SERVER_IP:8080 shows the Nginx welcome page. The tag after the colon, stable here, chooses which line of releases you follow; without a tag Docker takes latest, which may jump to a new major version under you on the next pull.
Anything the container writes inside itself disappears when you remove it. That is a feature: you can throw a container away and start a fresh one at any time. The data you want to keep belongs in volumes, which we cover below.
04Describe the whole application with Compose
A real application is rarely one container. WordPress needs a database, n8n may need PostgreSQL, a Node.js app may need Redis. Instead of long docker run commands you have to remember, Docker Compose describes them all in one compose.yaml file, which you keep in a folder per application and back up with it. Here is a WordPress site for a bookshop in Baghdad, with its MariaDB database:
# /opt/bookshop/compose.yamlservices: db: image: mariadb:11.8 restart: unless-stopped environment: MARIADB_DATABASE: wordpress MARIADB_USER: wordpress MARIADB_PASSWORD: ${DB_PASSWORD} MARIADB_RANDOM_ROOT_PASSWORD: "1" volumes: - db_data:/var/lib/mysql wordpress: image: wordpress:php8.3-apache restart: unless-stopped depends_on: - db environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_USER: wordpress WORDPRESS_DB_PASSWORD: ${DB_PASSWORD} WORDPRESS_DB_NAME: wordpress volumes: - wp_data:/var/www/html ports: - "127.0.0.1:8080:80"volumes: db_data: wp_data:
Put the password in a .env file next to it, readable by root only, and start everything:
cd /opt/bookshopecho "DB_PASSWORD=$(openssl rand -base64 24)" | sudo tee .envsudo chmod 600 .envsudo docker compose up -dsudo docker compose pssudo docker compose logs -f wordpress
Three details in this file matter. The containers reach each other by service name, so WordPress finds its database at the address db, and the database publishes no port at all: nothing outside the application can reach it. The restart: unless-stopped line brings both back after a server reboot. And WordPress is published on 127.0.0.1 only, because a in front of it, such as Nginx, Caddy or Nginx Proxy Manager, will serve it on your domain with an SSL certificate.
05Volumes and backups
A is storage that Docker manages outside the container, so the data survives when the container is removed or replaced with a newer image. There are two kinds:
- Named volumes: Like db_data above. Docker keeps them under /var/lib/docker/volumes, and they are the right choice for databases.
- Bind mounts: A folder on the server you choose yourself, such as ./uploads:/app/uploads. Easier to see and copy, and suited to configuration files and uploads.
Volumes protect your data from the container, not from a disk failure, a mistaken command or a hacked server. You still need backups, and for databases the safe copy is a dump, not the raw files of a running database:
# A consistent dump of the database while it runssudo docker compose exec db sh -c 'mariadb-dump -u wordpress -p"$MARIADB_PASSWORD" wordpress' | gzip > /backup/bookshop-db-$(date +%F).sql.gz# A copy of a named volume through a temporary containersudo docker run --rm -v bookshop_wp_data:/data:ro -v /backup:/backup alpine tar czf /backup/bookshop-files-$(date +%F).tar.gz -C /data .# Then copy /backup off the server, for example with rsync or restic
Compose prefixes volume names with the folder name, which is why wp_data becomes bookshop_wp_data; docker volume ls shows the real names. Schedule both commands with cron or a systemd timer, keep the copies on another server or storage, and restore one to a test server every few months. A backup you have never restored is a hope, not a backup.
06Update containers and Docker itself
A container never updates itself. Updating means pulling a newer image and recreating the container from it, while the volumes keep the data:
cd /opt/bookshop# Back up first, then pull the new images and recreate what changedsudo docker compose pullsudo docker compose up -d# Remove images no container uses any moresudo docker image prune
With a pinned tag such as mariadb:11.8, pull brings the latest patch release of that line, with its security fixes, and never jumps to a new major version without you. Move between major versions on purpose, after reading the release notes and taking a backup, because a database or an application may migrate its data on first start and not go back.
Docker Engine itself comes from the repository you added, so it updates with the system: sudo apt upgrade on Ubuntu and Debian, sudo dnf upgrade on AlmaLinux. Restarting Docker stops and restarts your containers, so do it at a quiet hour.
07Security basics most beginners miss
Docker adds powerful tools to your server, and with them a few new ways to get things wrong:
- Never expose the daemon: The Docker API listens on a local Unix socket, and that is where it should stay. Opening it on TCP port 2375 or 2376 to the internet hands the server to anyone who finds it, and bots scan for exactly that. To manage Docker remotely, use SSH, for example DOCKER_HOST=ssh://admin@SERVER_IP.
- Published ports bypass ufw: Docker writes its own iptables rules, so a port published with -p is reachable from the internet even when ufw denies it. Docker’s documentation says so plainly. On AlmaLinux, Docker adds its own docker zone to firewalld, so do not count on the public zone to hide a published port either.
- Bind private ports to 127.0.0.1: The simplest fix: publish as 127.0.0.1:8080:80, and only the reverse proxy on the server can reach it. Publish to the world only the ports that must be public, usually 80 and 443 on the proxy.
- Mounting docker.sock is giving root: Tools such as Portainer need /var/run/docker.sock inside their container. That is fine for a tool you trust, but never mount it into an image you pulled without knowing who made it.
- Prefer official and verified images: Pull from Docker Official Images or the project’s own publisher, pin a tag, and read the Dockerfile of anything else before running it.
- Keep secrets out of images: Passwords go in a .env file or Docker secrets, never in a Dockerfile or an image you push to a registry.
If you want ufw to control published ports anyway, the ufw-docker project adds rules to ufw’s after.rules file that route Docker traffic through ufw, blocking public access by default while containers keep talking to each other. You then open a port with a rule such as sudo ufw route allow proto tcp from any to any port 80. Note that the rule names the container’s port, 80, not the published port on the server.
# Which ports are published, and on which addresses?sudo docker ps --format "table {{.Names}}\t{{.Ports}}"# 0.0.0.0:8080->80/tcp is public; 127.0.0.1:8080->80/tcp is notsudo ss -ltnp
- Problempermission denied while trying to connect to the Docker daemon socket
- FixYour user is not in the docker group. Use sudo, or add the user with sudo usermod -aG docker USER and log in again, remembering that this is the same as root.
- ProblemBind for 0.0.0.0:80 failed: port is already allocated
- FixAnother container or a service on the server, often Apache or Nginx, already uses the port. Find it with sudo ss -ltnp and stop it, or publish on another port.
- ProblemThe disk fills up slowly with no new data
- FixContainer logs and old images. Run sudo docker system df to see where the space went, prune unused images, and limit logs by setting "log-driver": "local" in /etc/docker/daemon.json.
- ProblemA container restarts over and over
- FixRead sudo docker logs NAME: usually a missing variable, a wrong password or a database that is not ready yet.
- ProblemThe data disappeared after an update
- FixThe path was not in a volume. Check where the image keeps its data in its documentation and mount a volume there before you put real data in.
08Web interfaces: Portainer, Coolify and Dokploy
Once the basics are clear, a web interface saves time. Three are popular, and they do different jobs:
| Portainer CE | Coolify | Dokploy | |
|---|---|---|---|
| What it is | A dashboard for containers, images, volumes and stacks | A self-hosted platform that deploys apps from Git, with databases and SSL | A self-hosted platform that deploys apps and Compose files from Git, with Traefik |
| Suits | Seeing and managing what runs on the server | Developers who want a Heroku-like workflow | Developers who want deployments and Compose in one place |
| Minimum resources | Light | 2 cores, 2 GB RAM, 10 GB disk | 2 GB RAM, 30 GB disk |
| Web interface port | 9443 (HTTPS) | 8000 | 3000 |
| Licence | zlib (open source) | Apache 2.0 | Apache 2.0, with a separately licensed proprietary folder |
Portainer sits on top of whatever you already run and shows it in a browser: start, stop, read logs, open a console, deploy a Compose stack. Coolify and Dokploy go further and take over deployment: you connect a Git repository, they build the image, attach a domain, issue the SSL certificate and redeploy on every push. Coolify and Dokploy expect a server of their own, because they run their own reverse proxy on ports 80 and 443.
09Docker as a ready app on CoreVPS
Everything above works on any CoreVPS server, since you get full root access. But if you would rather skip the installation, CoreVPS comes with nearly 100 ready apps. On the order form, after choosing the operating system, open «Preinstalled software» and pick the app. The list shows only the apps that support the system you chose and fit the plan, and after delivery the installation runs on its own; you receive an email with the app’s address and login details or its setup steps.
- Docker and Portainer: Run from the VPS Start plan: 1 vCPU, 1 GB of memory and 20 GB of NVMe, enough to learn and to run a few light containers.
- Coolify, Dokploy and CapRover: Start from the VPS Plus plan, 2 vCPU, 2 GB and 30 GB, which matches the minimum Coolify and Dokploy ask for.
- Apps that run in containers: Among the ready apps are n8n, Nextcloud, Supabase, Uptime Kuma, Nginx Proxy Manager and WireGuard Easy, so you can start from one and learn Docker by reading how it was set up.
- Your own mix of resources: In the CoreVPS builder you set up to 32 vCPU, 64 GB of memory and 1000 GB of NVMe, and the order button opens the order form in the client area already filled in.
Most ready apps run on Ubuntu 22.04, 24.04 or 26.04, Debian 12 or 13, and AlmaLinux, Rocky, Oracle or CentOS Stream, with Ubuntu 24.04 as the default. The current plans are in our Germany data centre. Each plan includes a monthly data transfer allowance, which matters when your containers pull large images often. If you are not sure which plan fits your containers, ask our technical support team, or read our guide to choosing a VPS.




