Home / Guides / Docker Compose on a VPS
Guide

Docker Compose on a VPS.

Docker packages an app and its dependencies so you can run, update and remove it cleanly. This guide installs Docker and runs a small stack.

1. Install Docker

Docker publishes an apt repository for Ubuntu. Check the current steps on docs.docker.com and follow them, then confirm the install.

Confirm
docker --version
docker compose version
sudo systemctl enable --now docker

2. Use Docker without root

Add your user to the docker group
sudo usermod -aG docker $USER
# log out and back in, then:
docker run --rm hello-world

3. A small Compose stack

compose.yaml
mkdir -p ~/app && cd ~/app
cat > compose.yaml <<'EOF'
services:
  web:
    image: nginx:stable
    restart: unless-stopped
    ports:
      - "127.0.0.1:8080:80"
EOF
docker compose up -d
docker compose ps
curl -I http://127.0.0.1:8080

4. Keep ports safe

  • Bind to 127.0.0.1 unless a port must face the internet.
  • Docker edits firewall rules itself and can bypass ufw. Publish only what you intend to.
  • Put a reverse proxy such as nginx or Caddy in front for HTTPS. See host a website with nginx.

5. Update and clean up

Routine
docker compose pull
docker compose up -d
docker image prune -f
docker system df
FAQ

Common questions

How much RAM do I need for Docker?

4 GB (BASE) runs several small containers. Heavier stacks fit better on CORE or larger.

Does Docker make a server more private?

No. It isolates software, not identity. Read opsec mistakes.

Keep reading

Related pages

Host your own

Host your own apps on a private VPS: what size to choose for common self-hosted services, backups, updates and where to start.

Read more →

Host a website with nginx

Host a website on a VPS with nginx and a free TLS certificate: install, configure a server block, enable HTTPS and keep it updated. Copy-and-paste commands.

Read more →

VPS hardening checklist: secure a new Linux server in 15 minutes

A practical checklist for a new Linux VPS: SSH keys, a non-root user, firewall, automatic updates and backups, with the commands.

Read more →

Order a VPS paid in crypto.

Open the configurator