This guide shows how to install Docker Engine on an Ubuntu or Debian Linux VPS.
Note: these commands require root privileges. Run them as root or with sudo. Always review the commands before executing them on production servers.
If you previously installed Docker from distribution packages, remove them first:
sudo apt remove -y docker docker-engine docker.io containerd runc
sudo apt update
sudo apt install -y ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
Debian: the URL is similar, but uses /linux/debian/gpg instead of /linux/ubuntu/gpg.
Ubuntu:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Debian: replace ubuntu with debian in the repository URL.
sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo docker run --rm hello-world
Docker can be configured to run without sudo by adding your user to the docker group:
sudo usermod -aG docker $USER
Log out and log in again. Security note: users in the docker group effectively have root-level permissions on the server.
-p or a compose port mapping.