Skip to content
Blog

Installing Docker Engine on Ubuntu

Set up Docker Engine on Ubuntu from Docker's official apt repository — remove conflicts, add the GPG key, install, verify, and drop sudo.

Published on • October 18, 2026

AI Assistant

Docker Engine on Ubuntu is four packages installed from one apt repository: docker-ce, docker-ce-cli, containerd.io, and the docker-buildx-plugin and docker-compose-plugin plugins. The install overview covers every distro Docker supports; this walkthrough follows the Ubuntu path end to end, using Docker’s own repository at download.docker.com/linux/ubuntu rather than Ubuntu’s packaged docker.io.

Prerequisites

You need the 64-bit version of a supported Ubuntu release — currently Jammy 22.04 LTS, Noble 24.04 LTS, and the newer Resolute and Stonking releases, per the Ubuntu install guide. Derivatives such as Linux Mint aren’t officially supported, though they generally work if you substitute the corresponding Ubuntu codename.

Two firewall notes matter before you start:

  • If you manage rules with ufw or firewalld, ports published by Docker bypass your firewall rules — container traffic is inserted into iptables directly. Docker documents this under Docker and ufw.
  • Docker only works with iptables-nft and iptables-legacy. Rules written for nft standalone won’t apply; add your rules to the DOCKER-USER chain instead.

Remove conflicting packages

Ubuntu’s own archives ship unofficial Docker packages that conflict with the official ones. Remove them first:

sudo apt remove $(dpkg --get-selections docker.io docker-compose docker-compose-v2 docker-doc \
  docker-buildx podman-docker containerd runc | cut -f1)

apt may tell you none of them are installed — that’s fine. Note that images, containers, and volumes under /var/lib/docker/ survive uninstalling; delete them yourself if you want a truly clean start.

Add Docker’s apt repository

The repository lives at https://download.docker.com/linux/ubuntu. Set up the signing key and the source entry:

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

The Suites line resolves your codename automatically (noble, jammy, and so on), and Architectures pins the entry to whatever dpkg --print-architecture reports — amd64, arm64, armhf, s390x, or ppc64el. Docker publishes two channels: stable for general-availability releases and test for pre-releases; the block above points at stable, which is what you want on a workstation or server.

Install the packages

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

To pin a specific version instead of the latest, list what the repository offers and install by version string:

apt list --all-versions docker-ce

VERSION_STRING=5:29.8.2-1~ubuntu.24.04~noble
sudo apt install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io \
  docker-buildx-plugin docker-compose-plugin

Patch releases are always backward compatible within their major/minor version, so pinned upgrades within a line are safe.

Verify the installation

Confirm the daemon is up, then run the smoke test:

sudo systemctl status docker
sudo docker run hello-world

hello-world pulls a tiny test image, runs it, and prints a confirmation banner — that proves the CLI, daemon, and registry access all work. If the service isn’t running:

sudo systemctl start docker
sudo systemctl enable docker

enable matters on servers: it brings the daemon back after a reboot without anyone having to remember. You can also confirm exactly what got installed:

docker version
docker compose version
docker buildx version

docker version reports both CLI and server versions — if the server section is missing or errors with “Cannot connect to the Docker daemon,” the daemon isn’t running or your user can’t reach its socket.

Run Docker without sudo

By default the docker group exists but has no members, so every command needs sudo. Grant yourself access:

sudo usermod -aG docker $USER
newgrp docker

Log out and back in for the group to take effect in your desktop session. Be clear about the tradeoff: membership in docker lets a user control the daemon, which is equivalent to granting root on the host. That’s the point of the post-installation steps — just don’t add users who shouldn’t have it.

Alternative install methods

The repository method is the recommended one, but two others exist:

  • Manual .deb packages. Browse https://download.docker.com/linux/ubuntu/dists/, pick your release and architecture under pool/stable/, download containerd.io, docker-ce, docker-ce-cli, docker-buildx-plugin, and docker-compose-plugin, then sudo dpkg -i all five. Upgrades mean repeating this by hand.
  • Convenience script. curl -fsSL https://get.docker.com -o get-docker.sh then sudo sh get-docker.sh provisions everything non-interactively. Docker explicitly restricts this to testing and development: it installs dependencies without confirmation, always pulls the latest stable release (an unexpected major-version jump on provisioned machines), and isn’t designed to upgrade existing installs. Preview it first with --dry-run:
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh --dry-run

For pre-releases, the equivalent script at test.docker.com configures the test channel of the same repository.

Upgrade and uninstall

Upgrading is just step 2 again — sudo apt update && sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin pulls the newest versions from the repo. To remove everything:

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 /var/lib/containerd
sudo rm /etc/apt/sources.list.d/docker.sources /etc/apt/keyrings/docker.asc

That last block deletes images and containers too — skip it if you plan to reinstall and keep your data.

Sources