pull/this/repo
RoundupGit, GitHub and developer tools#docker#linux#how-to

How to install Docker on Ubuntu (Engine and Compose, the official way)

By Pull This RepoPosted 4 min read

Short answer

To install Docker on Ubuntu the official way, remove any old docker.io packages, add Docker's GPG key and apt repository, then run sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin. Check it with sudo docker run hello-world. Docker supports Ubuntu 26.10, 26.04 LTS, 24.04 LTS and 22.04 LTS on 64-bit systems.

RoundupHow to install Docker on Ubuntu (Engine and Compose, the official way)

To install Docker on Ubuntu, add Docker's own apt repository and install Docker Engine and the Compose plugin from it. That gives you the current release, kept up to date by apt upgrade, instead of the older docker.io package in Ubuntu's archive. The steps below are Docker's own, copied from docs.docker.com on 22 November 2026, and they also work inside Ubuntu on Windows through WSL.

Docker Engine is open source: its upstream project, moby/moby, is Apache-2.0 licensed and had 72,303 stars on GitHub on 22 November 2026.

Which Ubuntu versions does Docker support?

Docker's install page listed four 64-bit releases on 22 November 2026:

  • Ubuntu 26.10
  • Ubuntu 26.04 LTS (Resolute)
  • Ubuntu 24.04 LTS (Noble)
  • Ubuntu 22.04 LTS (Jammy)

Supported architectures are x86_64 (amd64), armhf, arm64, s390x and ppc64le. Run cat /etc/os-release if you are not sure which release you have. Docker adds that Ubuntu derivatives such as Linux Mint are not officially supported, though it may work.

Step 1: How do you remove old Docker packages?

Remove the unofficial packages first, because they conflict with Docker's. Docker names docker.io, docker-compose, docker-compose-v2, docker-doc, docker-buildx and podman-docker, plus containerd and runc if you installed them earlier:

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

Docker notes apt might report that none of these are installed, which is fine. Images, containers, volumes and networks already in /var/lib/docker/ are not removed by this step.

Step 2: How do you add Docker's apt repository?

Install the tools apt needs, save Docker's signing key, and add the repository as a .sources file:

terminal
# Add Docker's official GPG key:
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

# Add the repository to Apt sources:
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 fills in your release's codename, such as noble, and the Architectures line fills in your machine type. Paste the tee block as one piece, from sudo tee to the closing EOF.

Step 3: How do you install Docker Engine and Docker Compose?

One command installs the engine, the command line tool, containerd, and the Buildx and Compose plugins:

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

Compose arrives as a plugin, so you run it as docker compose with a space, not the old docker-compose.

Step 4: How do you check Docker is working?

Check the service, then run the test image:

terminal
sudo systemctl status docker
sudo docker run hello-world

Docker's docs say hello-world downloads a test image and runs it in a container, which prints a confirmation message and exits. If you see that message, the engine works.

Step 5: How do you run Docker without sudo?

Add your user to the docker group. From Docker's post-installation guide:

terminal
sudo groupadd docker
sudo usermod -aG docker $USER
newgrp docker
docker run hello-world

Docker notes some distributions create the group automatically, so groupadd may say it already exists; that is fine. newgrp applies the change in the current terminal, and logging out and back in makes the new membership count everywhere. Docker's warning is worth reading twice: "The docker group grants root-level privileges to the user." Anyone in that group can control the machine, so add only accounts you trust.

To make sure Docker starts at boot:

terminal
sudo systemctl enable docker.service
sudo systemctl enable containerd.service

How is installing Docker on Debian different?

Only the URLs and one line change. Docker's Debian page listed Debian 13 Trixie and Debian 12 Bookworm on 22 November 2026. Swap linux/ubuntu for linux/debian in both the key URL and the URIs line, and the Suites line reads the Debian codename directly:

terminal
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
# inside the docker.sources block:
URIs: https://download.docker.com/linux/debian
Suites: $(. /etc/os-release && echo "$VERSION_CODENAME")

The Debian removal command is the same list without docker-compose-v2, and the install command in step 3 is identical.

What about the convenience script?

Docker publishes a script at get.docker.com that does all of this in one go, for development machines. Docker's docs say it is not recommended for production, and advise you to read any script before you run it. The five steps above take a couple of minutes and leave you knowing exactly what was added to the system.

How do you uninstall Docker?

Purge the packages, then delete the data if you want it gone:

terminal
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

The two rm -rf lines delete every image, container and volume on the machine, with no undo.

What is the catch?

The firewall. Docker's install page warns that ports you publish from containers bypass ufw and firewalld rules, and that Docker supports only iptables-nft and iptables-legacy, not rules created with nft. If you expose a database with -p 5432:5432 on a server, assume the internet can reach it unless you add rules to the DOCKER-USER chain or bind the port to 127.0.0.1. The other catch is the docker group's root-level access, covered in step 5.

Once Docker is running, our Docker CLI cheat sheet covers the commands you will use daily, from docker run and docker exec to Compose and cleanup. Running a home server? Our guide to installing Proxmox is a common base for a Docker virtual machine.

On a Mac instead? Our guide to installing Docker on a Mac compares Docker Desktop, Colima and OrbStack. Good first projects once Docker runs: self-hosted document management with Paperless-ngx, a self-hosted AI agent kept in a container, or a Minecraft server for friends.

Pull it. Stash it.

Questions people ask

What is the easiest way to install Docker on Ubuntu?

Docker's own apt repository, in four commands: add the key, add the repository, run apt update, then install docker-ce with the Compose and Buildx plugins. Docker also offers a convenience script at get.docker.com, but its docs say that script is not recommended for production environments.

Does this install Docker Compose too?

Yes. The docker-compose-plugin package installs Compose as a Docker CLI plugin, so you run it as docker compose with a space. The old docker-compose package from Ubuntu's own repositories is one of the unofficial packages Docker tells you to remove first.

How do I run Docker without sudo on Ubuntu?

Add your user to the docker group with sudo usermod -aG docker $USER, then log out and back in, or run newgrp docker. Docker's docs warn that the docker group grants root-level privileges, so only add accounts you trust.

Should I use docker.io from Ubuntu or docker-ce from Docker?

Docker's install guide calls docker.io an unofficial package and lists it among the packages to uninstall before installing Docker Engine. The docker-ce packages come from Docker's own repository and follow Docker's releases.

How do I install Docker on Debian instead?

The steps are the same with two changes: the key and repository URLs use linux/debian in place of linux/ubuntu, and the Suites line reads only VERSION_CODENAME. Docker supported Debian 13 Trixie and Debian 12 Bookworm on 22 November 2026.

Sources

  1. 1Docker Docs: Install Docker Engine on Ubuntu (read 2026-11-22)
  2. 2Docker Docs: Install Docker Engine on Debian (read 2026-11-22)
  3. 3Docker Docs: Linux post-installation steps for Docker Engine (read 2026-11-22)
  4. 4moby/moby
  5. 5docker/cli

Get tomorrow's repo in your feed

One free, open source repo a day as a short video, shown working, with the catch named. Pull it. Stash it.