# How to run Docker on a VPS?

> How to run Docker on a VPS in 7 steps: Docker's apt repository, docker-ce and the Compose plugin, hello-world, then ports on 127.0.0.1 behind nginx.

- URL: https://ironkvm.com/guides/how-to-run-docker-on-a-vps/
- Last updated: 2026-11-16
- Publisher: IronKVM (https://ironkvm.com)

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

**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*

| Workload | Plan | Specs | Per month, 12 months |
| --- | --- | --- | --- |
| 2 or 3 small services | Ingot | 2 vCPU / 4 GB / 80 GB NVMe | $8.25 |
| A self-hosted stack with a database | Girder | 4 vCPU / 8 GB / 160 GB NVMe | $13.50 |
| Many services, media, search | Anvil | 6 vCPU / 16 GB / 240 GB NVMe | $15.00 |
| Build server, heavy stacks | Forge | 8 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)*

```bash
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*

```yaml
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](https://ironkvm.com/guides/how-to-set-up-a-firewall-with-ufw/ "How to set up a firewall with UFW?") 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](https://ironkvm.com/what-is-a-kvm-vps/ "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](https://ironkvm.com/best-offshore-vps-for-self-hosting/ "What is 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](https://ironkvm.com/guides/how-to-back-up-a-vps/ "How to back up a VPS?") 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

1. [Install Docker Engine on Debian](https://docs.docker.com/engine/install/debian/) — Docker (read 2026-11-16)
2. [Linux post-installation steps](https://docs.docker.com/engine/install/linux-postinstall/) — Docker (read 2026-11-16)
3. [Packet filtering and firewalls](https://docs.docker.com/engine/network/packet-filtering-firewalls/) — Docker (read 2026-11-16)
4. [Port publishing and mapping](https://docs.docker.com/engine/network/port-publishing/) — Docker (read 2026-11-16)
5. [Docker Compose quickstart](https://docs.docker.com/compose/gettingstarted/) — Docker (read 2026-11-16)
6. [IronKVM offshore VPS survey (CSV)](https://ironkvm.com/data/ironkvm-offshore-vps-survey-2026-11-16.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. [Order Girder](https://ironkvm.com/app/checkout/?plan=girder&term=12m&from=guide-docker&lang=en) · [Compare the plans](https://ironkvm.com/pricing/ "IronKVM prices 2026: how much does an offshore KVM VPS cost?")

---

IronKVM: IronKVM is an offshore KVM VPS provider with servers in the Netherlands, Romania and Moldova that takes no action on DMCA takedown notices, for content that is legal in the server's country. It is paid in crypto with no ID upload and run by DomaineGoat LLC, a company registered in Panama. On the 12-month term each plan costs at least 25% less than a named comparable plan read on 16 November 2026.
