Skip to content
Commitpedia
Log in Join & edit

Install Docker Engine on Ubuntu and Debian

Set up Docker's official apt repository, install Docker Engine with the Compose and Buildx plugins, run hello-world and let your user run docker without sudo.

Drafted with AI from official documentation. Scripts were run in a test environment and repository links verified. Awaiting a human check. Did it work for you? Last edited Outdated?

Edit history of Install Docker Engine on Ubuntu and Debian: 1 recorded edit
Edit history · 1 edit
Type
Article
Edits
1
Editors
1
First issued
15 Oct 2026
Last edit
15 Oct 2026
Reading
3 min

Ubuntu and Debian both ship a docker.io package, but it lags behind upstream. Docker recommends installing from its own apt repository instead, which gives you current releases of the engine plus the docker compose and docker buildx plugins. The steps below follow the official guide and work on all currently supported Ubuntu and Debian releases on amd64 and arm64.

Step 1: Remove conflicting packages

If an older or unofficial Docker was installed earlier, remove it first. It is fine if apt reports that none of these packages exist. Your images, containers and volumes under /var/lib/docker are not touched by this step.

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt remove $pkg; done

Step 2: Add Docker's GPG key and repository

On Ubuntu:

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
sudo apt update
sudo apt 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
sudo chmod a+r /etc/apt/keyrings/docker.asc

sudo tee /etc/apt/sources.list.d/docker.sources <<EOF
Types: deb
URIs: https://download.docker.com/linux/ubuntu
Suites: $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

On Debian the only differences are the URL and the codename variable:

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/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 <<EOF
Types: deb
URIs: https://download.docker.com/linux/debian
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")
Components: stable
Architectures: $(dpkg --print-architecture)
Signed-By: /etc/apt/keyrings/docker.asc
EOF

sudo apt update

The repository definition uses the deb822 .sources format, which is what the official guide now shows. If you are on a derivative such as Linux Mint, the Suites: line must contain the codename of the Ubuntu or Debian release it is based on, not the derivative’s own name.

Step 3: Install Docker Engine

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

The service starts automatically on Ubuntu and Debian and is enabled at boot. Check it:

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
sudo systemctl status docker
sudo docker run hello-world

The hello-world image prints a short message confirming that the client talked to the daemon, the daemon pulled an image and started a container.

Step 4: Run docker without sudo

The daemon listens on a Unix socket owned by root and the docker group. Adding your user to that group lets you skip sudo. Log out and back in afterwards, or run newgrp docker in the current shell.

Check before you run this

  • Runs with administrator rights. Make sure you understand every line.
sudo usermod -aG docker $USER
newgrp docker
docker run hello-world

Careful: membership of the docker group is equivalent to root on that machine, because a user who can start containers can mount the host file system into one. Only add trusted accounts. For a stricter setup, look at rootless mode in the documentation.

Upgrading and removing

Upgrades arrive through sudo apt update && sudo apt upgrade like any other package. To uninstall completely:

Check before you run this

  • Deletes files and folders without asking. Check the path before running.
  • Runs with administrator rights. Make sure you understand every line.
sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
sudo rm -rf /var/lib/docker
sudo rm -rf /var/lib/containerd
sudo rm /etc/apt/sources.list.d/docker.sources
sudo rm /etc/apt/keyrings/docker.asc

Careful: the two rm -rf lines delete every image, container and volume on the host. Skip them if you only want to reinstall the packages.

Official documentation

Did this work for you?

No votes yet. Be the first.

If it did not work, the report form below tells the editors what went wrong.

See also

  • 0055 Docker basics: images, containers and the commands you need An image is a read-only package of an app and its dependencies, and a container is a running instance of it. Learn… Beginner · Explains an idea · Linux, macOS, Windows Article Docker basics 15 Oct 2026
  • 0056 Docker Compose: run a small web app with a database Docker Compose describes several containers, their ports, volumes and environment in one compose.yaml file, then starts them all with docker compose up. Intermediate · Step by step · Linux, macOS, Windows Article Docker basics · Docker Compose 15 Oct 2026
  • 0099 Proxmox VE repositories and updates: enterprise vs no-subscription A fresh Proxmox VE install uses the enterprise repository, which needs a subscription. Learn how to switch to the no-subscription repository and… Beginner · Step by step · Linux Article Installation & first steps · Packages & updates 15 Oct 2026
  • 0176 apt vs dnf: package commands and automatic security updates The everyday package commands on Debian/Ubuntu (apt) and RHEL/Rocky/Alma (dnf) side by side, plus how to turn on automatic security updates on… Beginner · Cheat sheet · Linux Article Packages & updates 15 Oct 2026
  • 0249 Set up and harden a fresh Linux server in one afternoon Take a new Ubuntu, Debian or Rocky/Alma server from first login to a safer baseline: sudo admin, SSH keys only, firewall, automatic… Beginner · Guided project · Linux Article Networking & firewalls · Packages & updates · Users, sudo & hardening 15 Oct 2026
  • 0250 Containerize a Node.js app and run it with PostgreSQL using Docker Compose Package a small Node.js web app in a multi-stage Docker image, then run it next to PostgreSQL with Docker Compose, named volumes,… Intermediate · Guided project · Linux, macOS, Windows Article Docker basics · Docker Compose · PostgreSQL 15 Oct 2026

Repos in the wild

History

Every saved edit is kept. The plot on the sleeve draws one line per edit. Open any edit to see exactly what changed.

  1. Dominik +3,979 chars

Report a problem

Something wrong, unsafe or copied? Tell the editors.
What is wrong?