Deployment GuideUpdated August 22, 2026

Practical VPS tutorial

How to Install Docker on Ubuntu VPS

Install Docker Engine and Compose on Ubuntu VPS from the official apt repository, run a private test container and check Docker ports before deploying apps.

I'd install Docker from its official apt repository on an Ubuntu VPS. You get Engine, the Compose plugin and a straightforward update path through apt. You don't need Docker Desktop on a server.

How to Install Docker on Ubuntu VPS — overview

We'll finish by running a small web container on localhost. That checks the installation and networking before you add an application with real data.

Before you start: check Ubuntu and existing containers

This guide targets a fresh 64-bit Ubuntu 22.04, 24.04 or 26.04 LTS server. Check your release and architecture:

. /etc/os-release
printf '%s %s\n' "$PRETTY_NAME" "$(dpkg --print-architecture)"

Docker's installation page lists supported releases and architectures. Use an account with sudo access and keep SSH recovery available.

You don't need a particular RAM size just to install Docker. Buy for the apps: 2 vCPU, 4 GB RAM and 40 GB SSD is a reasonable starting estimate for a small app plus database, not a Docker minimum.

2 vCPU, 4 GB RAM, 40 GB SSDreasonable starting estimate for a small app plus database
8080host port the private test container binds to localhost
22.04, 24.04, 26.04Ubuntu LTS releases this guide targets
How to Install Docker on Ubuntu VPS — detail

1. Remove conflicting packages

Ubuntu's Docker packages and Docker's own packages have different names. Mixing them is an avoidable headache. Remove installed conflicts, then install the tools needed to add the official repository:

sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc docker-buildx podman-docker containerd runc | cut -f1)
sudo apt update
sudo apt install -y ca-certificates curl

On a clean VPS, messages about packages not being installed are normal. Package removal doesn't automatically erase Docker data, but it can interrupt existing containers.

2. Add the official Docker repository

This block installs the signing key and creates a repository entry for your Ubuntu release:

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

sudo tee /etc/apt/sources.list.d/docker.sources > /dev/null <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

If apt reports duplicate Docker sources, check whether you already have a docker.list entry. Keep one correct entry rather than adding the same repository twice.

3. Install Docker Engine and Compose

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 --rm hello-world
sudo docker compose version
sudo systemctl is-active docker

Look for the hello-world success message, a Compose version and an active service result. The test container exits afterward; it isn't supposed to stay running.

Use docker compose, with a space. You don't need to install the older standalone docker-compose command for this guide.

The commands use sudo docker throughout. That keeps the permission model explicit. Adding your account to the docker group is optional and grants root-level host control through the Docker socket, as the post-installation guide explains.

4. Run a private Compose test

Let's check something you can actually open. Create a separate test project and bind its web port to localhost:

sudo install -d -m 0755 /opt/docker-smoke
cd /opt/docker-smoke
sudo tee compose.yml > /dev/null <<'EOF'
services:
  web:
    image: nginx:alpine
    ports:
      - "127.0.0.1:8080:80"
    logging:
      driver: local
EOF

sudo docker compose up -d
sudo docker compose ps
curl --fail --head http://127.0.0.1:8080
sudo docker compose down

The HTTP check should return 200 OK. The final down command removes this test project's container and network, leaving its Compose file behind. If the first request arrives before Nginx is ready, wait a moment and repeat the curl check.

Port 8080 already in use? Change the left side of 127.0.0.1:8080:80, then use that port in the curl URL too. The right-hand 80 is Nginx's port inside the container.

Before deploying an app: check ports and storage

Here's the detail I'd check before calling the server ready: Docker-published ports can bypass UFW rules. A database mapped as 5432:5432 may be reachable even when you expected the host firewall to block it. See Docker's firewall documentation.

A database used only by other containers

leave out host port publishing.

A host-based reverse proxy

bind the app to 127.0.0.1.

A proxy in Docker

use a shared container network.

If the installation doesn't work

ProblemCheck first
Docker socket says permission deniedUse sudo; don't make the socket world-writable.
Cannot connect to the daemonRun sudo systemctl status docker and sudo journalctl -u docker -n 50.
Repository has no Release fileCheck the Ubuntu codename and supported release.
Container port is already allocatedCheck the host port and existing listeners.
Disk fills after updatesInspect sudo docker system df and logs before removing anything. Volumes may hold live data.

FAQ

Can I install Docker on a small Ubuntu VPS?

Yes, but the application determines whether the server is large enough. A simple web container and a database-plus-browser stack have very different memory needs.

Why does Docker work with sudo but not without it?

Your account lacks access to the Docker socket. Keeping sudo is fine. Group membership or rootless Docker are deliberate alternatives, not reasons to loosen socket permissions.

Does docker compose down delete application data?

Ordinary down removes the project's containers and networks. Adding -v also removes applicable volumes, so don't use it casually on a live application.

What to install next

  1. Deploy n8n with PostgreSQL and HTTPS
  2. Run Open WebUI with an external API
  3. Back up Docker volumes and databases

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.

Where to run this

Affiliate links: you pay the same price as buying direct.