# How do you install Docker on a VPS?

> How to install Docker on a VPS from the official repository in 6 steps, with Compose, a test container and the UFW port warning.

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

This is how to install Docker on a VPS from Docker's own apt repository, on Debian 13 or Ubuntu 24.04, with Compose included.

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

To install Docker on a VPS, add Docker's GPG key and apt repository, then install docker-ce, the CLI, containerd and the Compose plugin, and run hello-world. It takes 6 steps. **JadeKVM** servers are KVM with their own kernel, so Docker runs as on any Linux machine. Bind published ports to 127.0.0.1, because Docker skips UFW.

**In brief**

- **Official repository**: newer than the distro docker.io package and includes Compose v2.
- **KVM matters**: Docker needs kernel features that container-based VPS often lack.
- **UFW warning**: published ports skip UFW rules; bind them to 127.0.0.1.
- **Memory**: 1 GB runs one small container; Bangle with 4 GB fits a stack.

## How to install Docker on a VPS in 6 steps?

These commands follow Docker's install pages for Debian and Ubuntu, read on 16 November 2026.

1. **Remove old packages** — Remove docker.io, podman-docker or containerd from the distro if present.
2. **Add the GPG key** — Download Docker's key to /etc/apt/keyrings/docker.asc.
3. **Add the repository** — Write /etc/apt/sources.list.d/docker.sources in the deb822 format.
4. **Install the packages** — Install docker-ce, docker-ce-cli, containerd.io, docker-buildx-plugin and docker-compose-plugin.
5. **Test it** — Run sudo docker run hello-world. A greeting means the engine works.
6. **Allow your user** — Add your user to the docker group, then log out and back in.

## Which JadeKVM plan fits which Docker workload?

*JadeKVM plans for Docker workloads, with resources and the 12-month price per month*

| Plan | Resources | Per month on 12 months | Fits |
| --- | --- | --- | --- |
| Bead | 1 vCPU / 1 GB / 20 GB | $3.75 | One small container, with swap |
| Pendant | 1 vCPU / 3 GB / 45 GB | $4.50 | An app and its database |
| Bangle | 2 vCPU / 4 GB / 80 GB | $8.25 | A Compose stack of 4 to 6 services |
| Seal | 4 vCPU / 8 GB / 160 GB | $13.50 | Build jobs and heavier stacks |
| Vessel | 4 vCPU / 16 GB / 200 GB | $15.75 | Many stacks, or in-memory caches |

## How do you add the official Docker repository?

**Fetch the key, write a deb822 sources file, then install the five packages.** The block below reads your system ID and codename from /etc/os-release, so it fits Debian 13 and Ubuntu 24.04 alike. Docker supports Debian 13 (trixie) and Debian 12 on amd64 and arm64.

The docker group grants root-level power. Add only trusted users to it.

*Docker Engine from download.docker.com*

```bash
sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
. /etc/os-release
sudo curl -fsSL https://download.docker.com/linux/$ID/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 > /dev/null <<EOF
Types: deb
URIs: https://download.docker.com/linux/$ID
Suites: $VERSION_CODENAME
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run hello-world
sudo usermod -aG docker $USER
```

## Does Docker ignore the UFW firewall on a VPS?

**Yes: Docker inserts its own iptables rules, so `-p 8080:80` opens port 8080 to the world even if UFW denies it.** Docker's documentation states this plainly. Publish on the loopback address instead, as `127.0.0.1:8080:80`, and let nginx serve the public side.

The guide on [how to set up a UFW firewall on a VPS](https://jadekvm.com/guides/how-to-set-up-a-ufw-firewall-on-a-vps/ "How do you set up a UFW firewall on a VPS?") covers the host rules. For an app behind nginx, see [how to deploy a Node.js app](https://jadekvm.com/guides/how-to-deploy-a-nodejs-app-on-a-vps/ "How do you deploy a Node.js app on a VPS?").

*compose.yaml with a loopback port*

```yaml
services:
  web:
    image: nginx:stable
    ports:
      - "127.0.0.1:8080:80"
    restart: unless-stopped
```

## Which is the best VPS size for Docker in 2026?

**Start with 4 GB for a Compose stack; 1 GB works for one light container with swap.** Images, logs and volumes also eat disk, so watch `docker system df`. According to JadeKVM's survey of 2 November 2026, comparable 4 GB plans at 11 no-KYC crypto hosts in the three cities averaged $25.03 a month, against $8.25 for Bangle on 12 months.

On Bead, add swap first with [how to add swap on a VPS](https://jadekvm.com/guides/how-to-add-swap-on-a-vps/ "How do you add swap on a VPS?"). The [4 GB Asia VPS page](https://jadekvm.com/4gb-asia-vps/ "What does a 4 GB VPS in Asia cost with crypto?") compares that size in detail.

## How do you keep containers running after a reboot?

**Enable the docker service and give each container a restart policy.** The package enables docker.service by default. `restart: unless-stopped` in Compose brings containers back after a reboot. Reboot, reinstall and delete requests are sent from the dashboard and carried out by a person; a reinstall wipes the disk, and containers return on their own afterwards.

## Questions about Docker on a VPS

### Should I use docker.io from apt or Docker's repository?

Docker's repository gives current releases and the Compose v2 plugin. The distro package lags behind.

### Can Docker run on a 1 GB VPS?

Yes, for one small service. Add swap and avoid building large images on the server.

### Does Docker work on any VPS?

It needs a full kernel. KVM servers such as JadeKVM run it; some container-based VPS cannot.

### How do I update Docker?

Run apt update and apt upgrade. The repository delivers new engine versions like any other package.

### Which is better for one server: Docker Compose or Kubernetes?

Compose. Kubernetes adds overhead that a single small server does not need.

**Verdict**

- **Install from Docker's own repository** and get Compose v2 in the same step.
- Publish ports on 127.0.0.1 behind nginx, since Docker skips UFW.

## Sources

1. [Install Docker Engine on Debian](https://docs.docker.com/engine/install/debian/) — Docker (read 2026-11-16)
2. [Install Docker Engine on Ubuntu](https://docs.docker.com/engine/install/ubuntu/) — Docker (read 2026-11-16)
3. [Linux post-installation steps for Docker Engine](https://docs.docker.com/engine/install/linux-postinstall/) — Docker (read 2026-11-16)
4. [Packet filtering and firewalls, Docker Engine documentation](https://docs.docker.com/engine/network/packet-filtering-firewalls/) — Docker (read 2026-11-16)

**Run your Compose stack in Asia** Bangle offers 2 vCPU / 4 GB / 80 GB for $8.25 a month on 12 months. [Order Bangle in Tokyo](https://jadekvm.com/app/checkout/?plan=bangle&term=12m&location=jp-tyo&from=how-to-install-docker-on-a-vps&lang=en) · [See every plan](https://jadekvm.com/pricing/ "How much does a JadeKVM server cost per month?")

---

JadeKVM: JadeKVM sells Linux KVM VPS in Hong Kong, Tokyo and Singapore, paid in crypto with no ID document, and publishes the measured latency from each city to the rest of Asia. 5 plans from 1 to 16 GB of RAM cost the same in all three cities and, on the 12-month term, sit at least 25% under a named comparable no-KYC crypto plan read on 16 November 2026. The operator is DomaineGoat LLC, Panama.
