
Images, containers and volumes, installing Docker on an Ubuntu VPS from the official repository, Docker Compose, Portainer, and the security and backup rules to follow.
By Mouhamed BANKOLE, CEO at ITNET Technologies · Updated November 26, 2026 · Reading time: 10 min
Want to run n8n, Nextcloud, an API or a client's website without spending a day installing dependencies, and without breaking what is already running on the server? Docker is built for exactly that: each application ships with everything it needs, in an isolated container you can start, update or remove with a single command. On a VPS, it is the simplest way to deploy several services cleanly. This guide covers the basics, a step-by-step installation on Ubuntu, Docker Compose, web interfaces such as Portainer, then security and backups.
In short
- Docker runs applications in containers: each service carries its own libraries and stays isolated from the others on the same server.
- A Linux VPS is enough to get started: Docker Engine supports Ubuntu 22.04, 24.04, 26.04 and 26.10 according to the official documentation.
- Install Docker from the official repository in production: the quick get.docker.com script is meant for testing, according to Docker.
- Docker Compose describes a whole application in one file, and comes with the docker-compose-plugin package.
- Watch your firewall: ports published by Docker bypass ufw rules, warns the Docker documentation.
Contents
- What is Docker?
- Why use Docker on a VPS?
- What kind of VPS do you need to run Docker?
- How do you install Docker on an Ubuntu VPS?
- How do you run your first container?
- How do you use Docker Compose?
- Do you need an interface such as Portainer?
- How do you secure Docker on a VPS?
- How do you back up and update your containers?
What is Docker?
Docker is an open-source tool that packages an application and all its dependencies into a container, which runs the same way on any Linux server. It puts an end to the classic "it works on my machine but not on the server".
Four concepts are enough to get going:
- the image: a read-only template (for example nginx, postgres or n8n), downloaded from a registry such as Docker Hub;
- the container: a running instance of an image, which you can start, stop and remove at will;
- the volume: persistent storage created and managed by Docker, which keeps data even when the container is removed (Docker);
- the network: Docker connects containers to each other and only exposes the ports you choose.
A container is not a virtual machine: it shares the host system's kernel. It therefore starts in seconds and uses few resources, but it depends on the Linux system it runs on.
Why use Docker on a VPS?
Docker on a VPS lets you host several isolated applications on a single server, deploy them with one command and move them easily. It is the natural companion to a server you manage yourself.
The practical benefits:
- isolation: a PHP update for one site does not break another application;
- reproducibility: the same configuration file rebuilds the application identically, on another server or after a failure;
- speed: thousands of ready-to-use applications are published as official images;
- cleanliness: removing a container leaves no orphaned packages on the system;
- portability: moving from a VPS to a dedicated server means copying the Compose files and the volumes.
To understand what a virtual server offers compared with shared hosting, see our guide What is a VPS?.
What kind of VPS do you need to run Docker?
Docker needs a Linux VPS with full virtualisation and root access, with resources sized for the applications you plan to run. Docker itself is light; the containers are what count.
| Use case | Example containers | Indicative resources |
|---|---|---|
| Getting started, small tool | Uptime Kuma, a static site | 1 vCPU, 1 to 2 GB RAM |
| Automation, internal tools | n8n, Vaultwarden, a reverse proxy | 2 vCPU, 4 GB RAM |
| Business applications | Nextcloud, WordPress with a database | 2 to 4 vCPU, 4 to 8 GB RAM |
| Several client projects | 5 to 15 containers, databases | 4 vCPU or more, 8 to 16 GB RAM |
These figures are practical starting points, not official minimums: monitor actual memory use with docker stats and adjust. Also check three things with your provider:
- virtualisation: a KVM VPS behaves like a real machine and runs Docker without any special tweaks;
- the operating system: choose a release supported by Docker, such as Ubuntu 24.04 LTS (Docker);
- storage: images and logs grow quickly, so leave headroom on the disk.
Available configurations are listed on our VPS page.
How do you install Docker on an Ubuntu VPS?
The recommended method is to add Docker's official repository, then install Docker Engine and its plugins with apt. Run every command over SSH with a user that has sudo rights.
- Remove old unofficial packages (docker.io, docker-compose) if present, as the Docker documentation requires.
- Add Docker's key and repository: the key goes into /etc/apt/keyrings/docker.asc, then the repository is declared in /etc/apt/sources.list.d/ following the commands on the official page.
- Install the packages:
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
- Check the service with sudo systemctl status docker.
- Test the installation:
sudo docker run hello-world
Pro tip: the curl -fsSL https://get.docker.com script is handy, but Docker advises against it in production because it installs the latest release and can trigger unexpected major version upgrades (Docker). On a client server, always prefer the repository.
On Debian and Ubuntu, Docker starts automatically at boot; on other distributions, enable it with systemctl enable docker.service (Docker).
How do you run your first container?
You start a container with docker run, specifying the image, the name, the published ports and the data volume. Here is an example with an nginx web server:
docker run -d --name web -p 8080:80 --restart unless-stopped nginx:stable
What each option does:
- -d runs the container in the background;
- --name web gives it a readable name;
- -p 8080:80 publishes the container's port 80 on the VPS's port 8080;
- --restart unless-stopped restarts it after a server reboot;
- nginx:stable names the image and its version tag.
Everyday commands:
- docker ps lists running containers;
- docker logs web shows the logs;
- docker stop web then docker rm web stop and remove the container;
- docker volume create creates a persistent volume, the mechanism Docker recommends for data (Docker).
How do you use Docker Compose?
Docker Compose describes a complete application, with all its containers, networks and volumes, in a single compose.yaml file that you start with docker compose up -d. It is the tool to use as soon as an application has more than one container.
Example: WordPress with its database.
services:
db:
image: mariadb:11
environment:
MARIADB_DATABASE: wordpress
MARIADB_USER: wp
MARIADB_PASSWORD: change-me
MARIADB_RANDOM_ROOT_PASSWORD: "1"
volumes:
- db_data:/var/lib/mysql
restart: unless-stopped
wordpress:
image: wordpress:latest
depends_on:
- db
ports:
- "127.0.0.1:8081:80"
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wp
WORDPRESS_DB_PASSWORD: change-me
WORDPRESS_DB_NAME: wordpress
volumes:
- wp_data:/var/www/html
restart: unless-stopped
volumes:
db_data:
wp_data:
Useful commands:
- docker compose up -d creates and starts everything;
- docker compose ps and docker compose logs -f track the status;
- docker compose pull then docker compose up -d update the images;
- docker compose down stops everything without deleting the volumes.
Keep each project in its own folder (for example /opt/apps/wordpress) and put passwords in a .env file rather than in plain text in compose.yaml.
Do you need an interface such as Portainer?
A web interface such as Portainer is not essential, but it helps you see containers, logs and volumes at a glance if you are not comfortable with the command line. It runs in a container itself.
| Criterion | Command line and Compose | Portainer |
|---|---|---|
| Learning curve | Requires knowing the commands | Visual, faster at first |
| Reproducibility | Files you can version in Git | Possible through Compose "stacks" |
| Managing several servers | Over SSH, one server at a time | Central dashboard |
| Attack surface | No exposed interface | A web interface to protect |
If you install it, do not expose it directly to the internet: reach it through an SSH tunnel or a VPN. Our Portainer guide covers installation and hardening.
How do you secure Docker on a VPS?
Securing Docker is mostly about limiting who can control the daemon, keeping published ports in check and keeping images up to date. The key rules:
- the docker group grants root-level privileges: only add trusted administrators to it (Docker);
- published ports bypass ufw: Docker diverts traffic before the firewall rules apply, so a published port is reachable even if ufw blocks it (Docker);
- publish internal services on 127.0.0.1 (as in the Compose example) and expose them through a reverse proxy with HTTPS;
- consider rootless mode, which runs the daemon and containers as a non-root user (Docker);
- cap log sizes: the default json-file driver can eventually fill the disk, the Docker documentation points out;
- use official or verified images, with a precise version tag rather than latest in production.
On the system side, apply the basics of a well-run VPS: key-based SSH login, automatic security updates and disk space monitoring. For a simple brochure site that does not need containers, managed web hosting spares you all this administration.
How do you back up and update your containers?
Backing up a Docker application means backing up its Compose files, its .env file and the contents of its volumes, not the containers themselves. A container can be recreated from its image; only the data matters.
The simple method:
- version the compose.yaml files in a private Git repository (without secrets);
- export databases with their native tool (mysqldump, pg_dump) from inside the container, ideally every night;
- archive the volumes and copy the archives off the server, to another site;
- test a restore on a test VPS at least once a quarter.
For updates:
- docker compose pull then docker compose up -d fetch and apply new images;
- read the release notes before a major database version upgrade;
- clean up with docker image prune to reclaim the space used by old images.
Agencies hosting several client sites on one server will find a typical setup in our article on a VPS for web agencies.
Frequently asked questions
Is Docker free?
Docker Engine, the engine that runs containers on a Linux server, is free and open-source software. Docker Compose is free too. Only Docker Desktop, the workstation application, requires a paid licence for some companies.
What is the difference between Docker and a virtual machine?
A virtual machine carries its own complete operating system, whereas a Docker container shares the host server's kernel. A container therefore starts faster and uses less memory. In return, a virtual machine offers stronger isolation.
Can you install Docker on shared hosting?
No, Docker needs root access and control over the Linux kernel, which shared hosting does not provide. You need a VPS or a dedicated server. This is actually one of the most common reasons to move from shared hosting to a VPS.
Does Docker work on a Windows VPS?
Docker is designed primarily for Linux, and most published images are Linux images. On a server, the simplest and best-documented option remains a VPS running Ubuntu or Debian. Docker Desktop on Windows is mainly aimed at development on a workstation.
How many containers can you run on a VPS?
There is no fixed limit: it all depends on the memory and CPU each application uses. A small service may only use a few dozen megabytes, a database much more. Monitor consumption with docker stats before adding new containers.
Is Docker Compose installed with Docker?
With the official repository method, yes, provided you install the docker-compose-plugin package. The command is then docker compose, with a space. The old docker-compose command with a hyphen refers to an obsolete version.
Why doesn't my firewall block a Docker port?
Docker inserts its own network rules, which apply before ufw's. A port published with -p therefore stays reachable even when it is closed in ufw. Publish the port on 127.0.0.1 or drop the -p option if the service should not be public.
Should you back up Docker images?
No, public images can be downloaded again from the registry in seconds. What you need to back up are the data volumes, database exports and configuration files. An image you built yourself can be kept in a private registry.
Key takeaways
- Docker isolates each application in a container, so you can host several of them cleanly on one VPS.
- Install Docker from the official repository, not with the quick script, on a production server.
- Use Docker Compose to describe each application in a reproducible file.
- Beware of published ports, which bypass ufw: publish on 127.0.0.1 behind a reverse proxy.
- Back up volumes and Compose files, and test restores regularly.
To deploy your containers on a Linux server with root access, discover Wayhost VPS.
Article written by Mouhamed BANKOLE, CEO at ITNET Technologies.