# How do I install Docker on a VPS?

> How to install Docker on a VPS from the official repository in 6 steps, on Ubuntu or Debian, with Compose, a first test and the ufw port trap.

- URL: https://saltvps.com/guides/how-to-install-docker-on-a-vps/
- Last updated: 2026-11-16
- Publisher: SaltVPS (https://saltvps.com)

**Quick answer — How do I install Docker on a VPS?**

To install Docker on a VPS, remove any distro Docker packages, add Docker's signing key and apt repository, then install docker-ce with the Compose plugin and run hello-world. It takes about 6 commands on Ubuntu or Debian. A **SaltVPS** Crystal server (2 vCPU / 6 GB / 120 GB) is sized for several containers.

**In brief**

- **Source**: Docker's own repository at download.docker.com, not the older docker.io package.
- **Packages**: docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin, docker-compose-plugin.
- **Compose**: now a plugin, called as `docker compose` with a space.
- **Trap**: ports published by Docker skip ufw rules unless you bind them to 127.0.0.1.
- **Systems**: Ubuntu and Debian use apt; AlmaLinux and Rocky Linux use Docker's RHEL repository.

## How do you install Docker on an Ubuntu or Debian VPS?

**Run these as root, or prefix each with sudo. Replace ubuntu with debian in the URLs on a Debian server.**

1. **Remove old packages** — Run apt remove docker.io docker-compose docker-doc podman-docker containerd runc. It is fine if apt says none are installed.
2. **Install the prerequisites** — Run apt update then apt install ca-certificates curl.
3. **Add Docker's signing key** — Run install -m 0755 -d /etc/apt/keyrings, then curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc, then chmod a+r /etc/apt/keyrings/docker.asc.
4. **Add the repository** — Create the Docker source file in /etc/apt/sources.list.d/ exactly as shown on docs.docker.com for your system. It names your release codename and the key file.
5. **Install Docker Engine** — Run apt update, then apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin.
6. **Test it** — Run docker run hello-world. A greeting message means the engine pulled and ran a container. Check Compose with docker compose version.

## How does the Docker install differ between systems?

**SaltVPS offers Debian 13, Debian 12, Ubuntu 24.04 LTS, Ubuntu 22.04 LTS, AlmaLinux 10, Rocky Linux 10; Docker publishes packages for each family.**

*Docker Engine install method by Linux system offered on SaltVPS servers*

| System | Package manager | Docker repository | Starts on its own |
| --- | --- | --- | --- |
| Ubuntu 24.04 / 22.04 LTS | apt | download.docker.com/linux/ubuntu | Yes, after install |
| Debian 13 / 12 | apt | download.docker.com/linux/debian | Yes, after install |
| AlmaLinux 10 / Rocky Linux 10 | dnf | download.docker.com/linux/rhel | No: run systemctl enable --now docker |

## How do you install Docker on AlmaLinux or Rocky Linux?

**Add Docker's RHEL repository with dnf, install the same five packages, then start the service.**

- `dnf -y install dnf-plugins-core`
- `dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo`
- `dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin`
- `systemctl enable --now docker`

Accept the GPG key fingerprint when dnf asks, after checking it against the one printed on docs.docker.com.

## Why can Docker ports get past the ufw firewall?

**Docker writes its own iptables rules, and a published port is reachable even when ufw denies it.** Docker's documentation states this plainly. A container started with `-p 8080:80` answers on the public IP whatever ufw says.

Two safe habits help. Bind private services to localhost, as in `-p 127.0.0.1:8080:80`, and put a reverse proxy in front. Or only publish ports you mean to expose. The [ufw guide](https://saltvps.com/guides/how-to-set-up-a-ufw-firewall-on-a-vps/ "How do I set up a firewall on a VPS?") covers the rest of the firewall setup.

## Which VPS size is best for Docker?

**It depends on the containers, not on Docker itself, which adds little overhead.** SaltVPS checked its plan list on 16 November 2026: RAM runs from 2 GB on Grain to 32 GB on Dome, all on NVMe disks. A single small app fits Grain. Crystal (6 GB, 120 GB NVMe) leaves room for a database, a reverse proxy and a few services at $6.75 a month on 12 months.

Images and volumes fill disks quietly; `docker system df` shows the space used. The [Docker VPS comparison](https://saltvps.com/best-vps-for-docker/ "Which VPS is best for Docker?") goes deeper, and [running a trading bot](https://saltvps.com/guides/how-to-run-a-trading-bot-on-a-vps/ "How do I run a trading bot on a VPS?") is a worked Compose example.

## Docker on a VPS: questions

### Can I run Docker without sudo?

Add your user to the docker group with usermod -aG docker youruser, then log out and back in. That group has root-level power on the host, so give it only to admins.

### Should I use the convenience script from get.docker.com?

Docker says it is meant for test and development setups. On a server you keep, the repository method is easier to audit and update.

### Does Docker work on a KVM VPS?

Yes. KVM gives the server its own kernel, so Docker runs as it would on a physical machine.

### How do I update Docker later?

With the normal system updates: apt upgrade or dnf upgrade pulls new Docker packages from the repository.

### Is docker-compose the same as docker compose?

docker compose is the current plugin. The older docker-compose tool is no longer maintained by Docker.

**Verdict**

- **Install Docker on a VPS from Docker's own repository**, then test with hello-world.
- **Bind private ports to 127.0.0.1**, because published ports skip ufw rules.

## Sources

1. [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/) — Docker (2026-11-16)
2. [Install Docker Engine on Debian](https://docs.docker.com/engine/install/debian/) — Docker (2026-11-16)
3. [Install Docker Engine on RHEL](https://docs.docker.com/engine/install/rhel/) — Docker (2026-11-16)
4. [Packet filtering and firewalls (Docker with ufw)](https://docs.docker.com/engine/network/packet-filtering-firewalls/) — Docker (2026-11-16)

**A KVM server ready for containers** Crystal pairs 6 GB of RAM with 120 GB NVMe, with root over SSH and a dedicated IPv4. [Order Crystal for 12 months](https://saltvps.com/app/checkout/?plan=crystal&term=12m&from=guides-how-to-install-docker-on-a-vps&lang=en) · [All guides](https://saltvps.com/guides/ "Which VPS guides and Linux tutorials does SaltVPS publish?")

---

SaltVPS: SaltVPS sells Linux KVM VPS in New York, Dallas, Los Angeles, London, Amsterdam and Frankfurt, paid in crypto with no ID document. Seven plans from 2 to 32 GB of RAM cost the same in all six cities, and on the 12-month term each is priced at least 25% under a named comparable plan of a no-KYC crypto host, read on 16 November 2026. The operator is DomaineGoat LLC, Panama.
