EQVPS

How to install Docker on a VPS

Install Docker Engine and the Compose plugin on Ubuntu the right way — from Docker's official repository, not the outdated distro package — then run a test container and set it to start on boot. A few commands to a working container host.

Docker packages an app and everything it needs into a container that runs the same anywhere — the cleanest way to self-host services on a VPS. The one catch on Ubuntu and Debian is that the version in the distro's own repository is often old and ships without the modern Compose plugin. Install from Docker's official repository instead. Here's the whole process.

1. Set up Docker's official repository (Ubuntu)

sudo apt update
sudo apt install -y ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
  https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

2. Install Docker Engine and Compose

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

3. Confirm it's running and enabled on boot

sudo systemctl enable --now docker
sudo docker run --rm hello-world

The hello-world container downloads, prints a success message and exits — proof the engine works.

4. (Optional) Run Docker without sudo

sudo usermod -aG docker $USER
# log out and back in for the group to take effect

Only do this for a user you trust — docker-group access is effectively root on the host.

A quick real container

docker run -d --restart unless-stopped -p 8080:80 --name web nginx
# visit http://YOUR.SERVER.IP:8080

--restart unless-stopped is what makes the container come back after a reboot.

Honest cautions

Next steps

With Docker installed you can self-host almost anything. See self-hosting multiple services behind one IP, or concrete Docker builds like a RustDesk remote-desktop server and Uptime Kuma monitoring. To put a domain and HTTPS in front, see how to set up an nginx reverse proxy.

FAQ

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

For a current version, use Docker's official repository (the steps below). The distro's docker.io package is convenient but often lags behind, and the modern 'docker compose' plugin ships with the official packages. If you only need a quick throwaway box, docker.io works too.

What's the difference between 'docker compose' and 'docker-compose'?

The old 'docker-compose' was a separate Python tool (hyphenated). The current one is 'docker compose' (a space) — a plugin bundled with Docker. Use the plugin; the standalone tool is legacy. Install docker-compose-plugin as shown and you get it.

How do I run Docker without typing sudo every time?

Add your user to the docker group: 'sudo usermod -aG docker $USER', then log out and back in. Note that this effectively grants root-level access via containers, so only do it for a trusted user on your own box.

How much RAM does Docker need?

Docker itself is light; what matters is the containers you run. A small app or two fits comfortably on a 1 GB box, while heavier stacks (databases, multiple services) want more headroom. Size the VPS to the workload, not to Docker.

Will my containers survive a reboot?

Only if you tell them to. Docker's service is enabled on boot by the steps below, and containers started with '--restart unless-stopped' (or that policy in Compose) come back automatically. Without a restart policy, a container stays down after a reboot.

Comments

No comments yet. Be the first.

Leave a comment

Comments are moderated before they appear.