DMCA notices: no action · Netherlands · Romania · Moldova · Pay in BTC, USDT, USDC, ETH, SOL, LTC, XMR
Language: English
Configure a VPS

Guide · Docker Engine and Compose

How to run Docker on a VPS?

Docker Engine from Docker’s own repository on a KVM server, with Compose, and the one firewall trap every VPS owner should know.

Last updated: · 5 min read

Quick answer

How to run Docker on a VPS?

To run Docker on a VPS, add Docker’s apt repository and key, install docker-ce with the Compose plugin, test with docker run hello-world, then publish container ports on 127.0.0.1 behind a reverse proxy. An IronKVM KVM server runs Docker with its own kernel; Girder, with 8 GB of RAM, costs $13.50 a month on 12 months.

In brief
  • Remove the distribution’s docker.io and related packages first: Docker lists them as conflicting.
  • Install docker-ce, docker-ce-cli, containerd.io and the buildx and compose plugins.
  • Ports published by containers are not filtered by ufw; publish them on 127.0.0.1.
  • The docker group grants root-level privileges to its members.
  • A KVM VPS boots its own kernel, so Docker runs without the limits of container-based VPS.

Which IronKVM plan fits how many containers?

IronKVM plans for Docker workloads; specs and prices from site data, 12-month term
WorkloadPlanSpecsPer month, 12 months
2 or 3 small servicesIngot2 vCPU / 4 GB / 80 GB NVMe$8.25
A self-hosted stack with a databaseGirder4 vCPU / 8 GB / 160 GB NVMe$13.50
Many services, media, searchAnvil6 vCPU / 16 GB / 240 GB NVMe$15.00
Build server, heavy stacksForge8 vCPU / 24 GB / 400 GB NVMe$20.63

What are the steps to run Docker on a VPS?

  1. Remove conflicting packages

    Uninstall docker.io, docker-compose, docker-doc and similar packages if the image has them.

  2. Add Docker’s key and repository

    Download the GPG key to /etc/apt/keyrings and add docker.sources to apt.

  3. Install Docker Engine

    Install docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin and docker-compose-plugin.

  4. Test it

    Run sudo docker run hello-world. It downloads a test image and runs it.

  5. Start at boot

    Enable docker.service and containerd.service with systemctl.

  6. Write a compose.yaml

    Describe the services and publish their ports on 127.0.0.1 only.

  7. Put nginx in front

    Proxy a domain to the local port and add HTTPS with certbot.

Install Docker Engine on Debian (from docs.docker.com)
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/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 <<EOF
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: stable
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run hello-world
sudo systemctl enable docker.service containerd.service
compose.yaml with a port reachable from the host only
services:
  web:
    image: nginx:stable
    ports:
      - "127.0.0.1:8080:80"
    restart: unless-stopped

Why do Docker ports get past the firewall?

Because Docker routes traffic to published ports before ufw’s rules are checked. Docker documentation says that when you expose container ports, they go around ufw or firewalld rules. By default, Docker publishes ports on every address, IPv4 and IPv6.

The fix is in the port mapping. Docker’s port publishing page shows -p 127.0.0.1:8080:80, which only the Docker host can reach. Then nginx on the host proxies the public domain to 127.0.0.1:8080. The UFW guide covers the rest of the firewall.

Should you add your user to the docker group?

Only if you accept that it gives that user root-level power. Docker’s post-install page warns that the docker group grants root-level privileges. Anyone in it can start a container that mounts the whole disk.

On a single-user VPS, that is often acceptable: run sudo usermod -aG docker $USER, then log in again or run newgrp docker. On a shared server, keep using sudo. Rootless mode is another option documented by Docker.

Which VPS is best to run Docker in 2026?

A KVM VPS with enough RAM for every container plus the host. On KVM, each VPS boots its own kernel, so Docker’s networking and storage drivers work as on a dedicated server. The what is a KVM VPS page explains the difference with container-based plans.

According to IronKVM's survey of 16 November 2026, plans comparable to Girder cost a median of $47.10 a month across 18 hosts; IronKVM Girder costs $13.50 on 12 months. Cryptocurrency mining is not allowed. A full node that only validates a blockchain is allowed. The best offshore VPS for self-hosting compares plans for container stacks.

How do you back up Docker volumes?

Dump databases from inside their containers, then back up the volume folders. Copying a live database volume can give a broken copy. Run the dump command with docker compose exec, write it to a file, then include /var/lib/docker/volumes in the backup. The VPS backup guide shows a restic script. No plan includes backups: keep a copy of anything that matters outside the VPS.

Docker on a VPS: questions

Can I run Docker on any VPS?

On KVM, yes. Some container-based VPS types limit Docker. Every IronKVM plan is KVM.

Docker Compose v1 or the compose plugin?

The plugin: install docker-compose-plugin and use docker compose, with a space.

How do I start and stop a stack?

docker compose up -d starts it in the background; docker compose down stops and removes it.

Does Docker work on AlmaLinux or Rocky Linux?

Yes, with Docker’s own repository for those systems. This guide shows the Debian steps.

Is Docker the best way to self-host apps?

It keeps each app isolated and easy to update. For one simple app, a native package can be lighter.

Verdict
  • Install from Docker’s repository, test with hello-world, publish ports on 127.0.0.1: Docker then runs safely on a VPS.
  • IronKVM Girder suits a typical self-hosted stack; Anvil gives room for many services.
Sources (6)
  1. Install Docker Engine on Debian — Docker (read 2026-11-16)
  2. Linux post-installation steps — Docker (read 2026-11-16)
  3. Packet filtering and firewalls — Docker (read 2026-11-16)
  4. Port publishing and mapping — Docker (read 2026-11-16)
  5. Docker Compose quickstart — Docker (read 2026-11-16)
  6. IronKVM offshore VPS survey (CSV) — IronKVM (read 2026-11-16)

Run your containers on KVM

Girder, 4 vCPU, 8 GB RAM, 160 GB NVMe, 8 TB traffic, $13.50 a month on 12 months.

From $4.46/month · no KYC

Configure a VPS