Deployment GuideUpdated August 22, 2026

Ubuntu VPS foundation

How to Install Docker on Ubuntu VPS

Install Docker Engine from the official repository, verify Compose and run a safe test container.

Docker is the common foundation for many self-hosted VPS applications. The reliable path on Ubuntu is to use Docker's official apt repository, install Engine and the Compose plugin together, then verify networking and persistence before deploying an application. Avoid copying a random install script onto a production VPS when you need predictable updates.

Why this matters

Docker lets one VPS run several applications with repeatable configuration, isolated dependencies and a simpler migration path. It is useful for n8n, Open WebUI, dashboards, databases and small web stacks. It does not remove server administration: you still own the firewall, image updates, storage, backups and the blast radius of anyone who can access the Docker socket.

Where Docker earns its keep on a VPS

Repeatable deploys

Move a Compose stack between VPS providers without rebuilding the server by hand.

Controlled updates

Pull, recreate and roll back one service without replacing the whole VPS.

Clear boundaries

Separate application dependencies while keeping ports and persistent data explicit.

VPS requirements

Buy for the workload, not the install command

Find a matching VPS
Minimum1 vCPU / 1 GB RAM / 20 GB SSD

Learning Docker or running one lightweight stateless container.

Heavy workload4+ vCPU / 8+ GB RAM / 100+ GB NVMe

Several stacks, local image builds, search services or high log and database I/O.

Target resultdocker run hello-worldthen a Compose smoke test bound to localhost

Install path with checkpoints

01

Remove conflicting packages

Ubuntu may contain older packages with similar names. Removing only conflicting packages does not remove your future Docker data.

sudo apt remove -y docker.io docker-compose docker-doc podman-docker containerd runc || true
sudo apt update
sudo apt install -y ca-certificates curl
02

Add Docker's repository

Use the official keyring and repository for your Ubuntu release, then install the maintained packages.

sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo $VERSION_CODENAME) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
03

Install Engine and Compose

The Compose plugin is now invoked as docker compose, with a space, rather than the older docker-compose binary.

sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo systemctl enable --now docker
sudo docker run hello-world
docker compose version
04

Decide how to run Docker

Adding a user to the docker group removes sudo but grants root-equivalent control through the Docker socket. On a shared administrative server, keep using sudo or use rootless Docker instead.

sudo usermod -aG docker $USER
newgrp docker
docker run hello-world

A Docker group decision is a security decision

Adding a user to the docker group is convenient, but access to the Docker socket is effectively root-equivalent. On a personal VPS that trade-off may be reasonable. On a shared administrative machine, keep using sudo or investigate rootless Docker instead.

Do not expose the Docker daemon API to the public internet. Publish application ports intentionally and bind internal smoke tests to 127.0.0.1.

Finish with a disposable smoke test

Create a small Compose smoke test

A disposable test confirms port publishing and container lifecycle before you put a real application on the machine.

mkdir -p ~/docker-test && cd ~/docker-test
printf 'services:
  web:
    image: nginx:alpine
    ports:
      - 127.0.0.1:8080:80
' > compose.yml
docker compose up -d
curl -I http://127.0.0.1:8080
docker compose down

Common mistakes that cause real downtime

  • Installing docker.io and docker-ce together, then troubleshooting mismatched packages
  • Adding every administrator to the docker group without treating it as root-level access
  • Publishing databases or admin ports on 0.0.0.0 when only a private network needs them
  • Keeping application data only inside a container writable layer
  • Choosing a tiny disk without allowing space for images, build cache, logs and database growth

Before deploying the first app

systemctl is-active docker returns active
docker run hello-world completes
docker compose version prints a version
The test service is not exposed on 0.0.0.0 by accident

Next step

Keep the deployment moving

Sources and further reading

Commands assume a fresh Ubuntu server. Replace domains, users, database names and provider-specific values before running them. VPS sizing is a practical starting point, not a guarantee: monitor the real workload and resize when CPU, memory, disk or network headroom becomes tight.