Skip to content
Summer 2026: 20% off 12-month terms with code ATLAS10 stacked on top
LinuxUpdated April 9, 2026 ยท 20,551 views

Installing Docker and Docker Compose on a VPS

The official installation path for Ubuntu and Debian, plus the settings that avoid trouble later.

Install

curl -fsSL https://get.docker.com | sudo sh
sudo usermod -aG docker $USER
newgrp docker
docker run --rm hello-world

The convenience script installs the engine, CLI, containerd and the Compose v2 plugin from Docker's own repository โ€” the same thing the manual instructions do, in one line.

Cap the logs before they eat your disk

Unbounded JSON logs are the most common cause of a full disk on a container host:

sudo tee /etc/docker/daemon.json >/dev/null <<'EOF'
{
  "log-driver": "json-file",
  "log-opts": { "max-size": "10m", "max-file": "3" },
  "live-restore": true
}
EOF
sudo systemctl restart docker

Docker and UFW do not get along

Docker writes its own iptables rules and will happily publish a port to the world that UFW believes is blocked. Bind sensitive services to localhost explicitly:

ports:
  - "127.0.0.1:5432:5432"   # correct
  # - "5432:5432"           # exposed to the entire internet

For anything that must be public, put a reverse proxy (Caddy, Traefik, nginx) in front and publish only 80/443.

Housekeeping

docker system df
docker system prune -a --volumes    # careful: removes unused volumes too

Sizing

A Compose stack of app + Postgres + Redis + Caddy runs comfortably on VPS Micro (2 vCPU / 4 GB). Add memory before CPU โ€” containers usually hit the memory wall first.

Did this solve your problem?

If not, open a ticket and paste the command output you got. Support is 24/7 with a 12-minute median first reply, and the same engineers maintain these pages.