Quick answer: Install Docker Engine from Docker's official repository (not the distro's default packages) — add the repo, then sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin (or the dnf equivalent), and verify with sudo docker run hello-world.

Overview

Docker packages applications into containers that run identically anywhere — ideal on a VPS for isolating apps, quick deployments and reproducible stacks with docker compose. Docker's official repository ships current, supported builds, which is why it is preferred over distro packages.

Before you start

  • A 64-bit Linux server with root/sudo access; 1 GB+ RAM recommended.
  • Remove old packages if present: sudo apt remove docker docker-engine docker.io containerd runc.

Step-by-step guide

  1. Add Docker's official repository (Ubuntu example; Debian/Alma/Rocky follow the same pattern from docs.docker.com):
    sudo apt update && sudo apt -y install 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
    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
  2. Install Docker Engine and the Compose plugin:
    sudo apt update
    sudo apt -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  3. Enable and verify:
    sudo systemctl enable --now docker
    sudo docker run hello-world
    docker compose version
  4. (Optional) run docker without sudo — note this grants root-equivalent power to that user:
    sudo usermod -aG docker $USER
    # log out and back in

Common issues

  • permission denied on the socket: you skipped the group step or didn't re-login.
  • Docker bypasses UFW: published ports (-p 80:80) are opened via iptables directly — publish only what must be public, e.g. bind internal services to 127.0.0.1:PORT.
  • Disk filling up: clean unused images/volumes with docker system prune (review before confirming).

When to contact support

Container workloads are yours to manage; for platform issues or to add resources for heavier stacks, open a ticket.

Frequently asked questions

Why install Docker from its official repository?

Distribution packages often lag far behind. Docker's own repository ships current, supported Engine releases plus the Compose and Buildx plugins.

Is adding my user to the docker group safe?

It is convenient but grants root-equivalent power, since containers can mount the host filesystem. Only add trusted admin users to the docker group.

Why are my container ports open despite UFW?

Docker programs iptables directly, bypassing UFW for published ports. Publish only public services and bind internal ones to 127.0.0.1, e.g. "-p 127.0.0.1:5432:5432".

Related articles

Ready to get started? Order a VPS at Cloud2Y →

Was this answer helpful? 0 Users Found This Useful (0 Votes)