Quick answer

Installing Docker on Ubuntu with sudo apt install docker.io or the Snap package is the common mistake: both lag upstream and ship without the bundled Compose v2 plugin, so docker compose reports it is not a docker command. Add Docker’s apt repository instead, install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin, then usermod -aG docker $USER and log out.

By LK Wood IV · Published 2026-06-30 · ~8 min read · St. Louis County, MO

Docker is the foundation of almost every self-hosted stack — Jellyfin, Nextcloud, Home Assistant, Pi-hole, the lot. (Weighing it against the daemonless, rootless alternative first? See our Podman vs Docker comparison.) This guide installs Docker Engine on Ubuntu the official way: from Docker’s own apt repository, so you get the current release, the Buildx plugin, and Compose v2 together, with updates straight from Docker. It works on Ubuntu 24.04 LTS, 22.04 LTS, and current interim releases, and the repository line auto-detects your version so you never edit it by hand.

Skip Ubuntu’s built-in docker.io package and the Snap version — both lag upstream and ship without the bundled Compose v2 plugin, which is the usual reason docker compose “is not a docker command.” The steps below come straight from Docker’s official Ubuntu install documentation; I have reproduced the current commands verbatim and added the post-install and error-fixing steps that the quick-start glosses over.

Prerequisites

  • A 64-bit Ubuntu 24.04, 22.04, or current release (desktop or server)
  • A user with sudo privileges
  • Internet access to reach download.docker.com

Step 1: Remove conflicting packages

Older or distro-packaged Docker bits collide with the official packages. Clear them first:

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

It is fine if apt reports some of these were not installed. Your images and volumes in /var/lib/docker are left untouched.

Step 2: Add Docker’s official apt repository

First add Docker’s GPG key so apt trusts the packages:

# 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

Then add the repository itself. This block writes the modern deb822-format source file and fills in your Ubuntu codename and CPU architecture automatically:

# 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

Step 3: Install Docker Engine

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

That single command installs the Engine, the CLI, containerd, Buildx, and Compose v2 — everything a homelab needs.

Step 4: Verify the install

sudo docker run hello-world

If you see “Hello from Docker!”, the Engine is running. Confirm Compose v2 too:

docker compose version

A v2.x number means docker compose up -d will work for your stacks.

Step 5: Run Docker as a non-root user

By default docker needs sudo. Add your user to the docker group so you can drop it:

sudo usermod -aG docker $USER

Then log out and back in (or run newgrp docker in the current shell) so the new group membership takes effect. After that, docker run hello-world works without sudo.

Security note: the docker group grants root-equivalent access to the host — a member can mount the host filesystem into a container. Only add users you trust as administrators.

Docker is enabled to start on boot automatically after this install (via systemd). You can confirm with systemctl is-enabled docker.

Common install errors and fixes

  • permission denied while trying to connect to the Docker daemon socket — your user is not in the docker group yet, or you have not logged out and back in since Step 5. Re-run the usermod line, then log out/in.
  • docker: 'compose' is not a docker command — you installed the old docker.io or Snap package instead of docker-ce. Remove it (Step 1) and install from the official repo (Steps 2–3), which includes the Compose plugin.
  • NO_PUBKEY / GPG error on apt update — the GPG key step did not complete. Re-run the four key commands in Step 2 and check the key exists with ls -l /etc/apt/keyrings/docker.asc.
  • Unable to locate package docker-ce — the repository was not added or apt update was not run after adding it. Re-check /etc/apt/sources.list.d/docker.sources exists and re-run sudo apt update.
  • Behind a proxy or on a fresh server, curl fails — install curl first (sudo apt install curl) and confirm the box can reach download.docker.com.

Where to go next

With the Engine running, the natural next step is a Compose stack. Start with the Docker Compose starter stack for a homelab, size your host RAM with the Docker homelab RAM planner, or jump straight to a real service like Jellyfin in Docker. For the bigger picture of what to self-host, see the best self-hosted apps to replace SaaS.

Commands reproduced from Docker’s official Ubuntu installation guide and verified 2026-06-30. Docker Engine, Buildx, and Compose are trademarks of Docker, Inc.; this is an independent guide.

Frequently asked questions

Should I install Docker from apt (docker.io) or Docker's official repository?
Use Docker’s official apt repository, which installs the docker-ce package. Ubuntu’s own docker.io package and the Snap version both lag behind upstream and miss the bundled Compose v2 plugin, which causes the ‘docker: compose is not a docker command’ confusion. The official repository gives you the current Docker Engine, the Buildx plugin, and Compose v2 in one install, with security updates straight from Docker. Remove any docker.io or snap Docker first (Step 1) so the packages do not conflict.
Why do I get 'permission denied while trying to connect to the Docker daemon socket'?
Your user is not in the docker group, so it cannot talk to the daemon socket without sudo. Run ‘sudo usermod -aG docker $USER’, then fully log out and back in (or run ’newgrp docker’ in the current shell) for the new group to apply. After that, ‘docker run hello-world’ works without sudo. Note the security trade-off: members of the docker group have effectively root-equivalent access to the host, so only add trusted users.
Which Ubuntu versions does this work on?
Docker’s official repository supports the current Ubuntu LTS and interim releases — 24.04 LTS (Noble), 22.04 LTS (Jammy), and 25.04 at the time of writing. The commands below detect your release codename automatically via UBUNTU_CODENAME, so the same steps work across versions without editing the repository line. Docker drops support for a release when Ubuntu itself reaches end of standard support.
Do I need to install Docker Compose separately?
No. The official install includes the docker-compose-plugin, so ‘docker compose’ (with a space, v2) works immediately — for example ‘docker compose up -d’. You do not need the old standalone ‘docker-compose’ binary (with a hyphen, v1), which is deprecated. If you see ‘docker compose version’ return a v2 number, you are set.
Is Docker Engine on Ubuntu the same as Docker Desktop?
No. On a server or homelab box you want Docker Engine (these steps) — the lightweight daemon with no GUI and no virtual machine. Docker Desktop is a separate product that runs Engine inside a VM with a dashboard, aimed at developer laptops, and it has its own licensing for larger companies. For a headless Ubuntu server, install Docker Engine; do not install Docker Desktop.
How do I uninstall Docker from Ubuntu?
Remove the packages with ‘sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin’, then delete the data with ‘sudo rm -rf /var/lib/docker /var/lib/containerd’. That removes all images, containers, and volumes, so back up anything you need first. You can also remove the repository file at /etc/apt/sources.list.d/docker.sources and the key at /etc/apt/keyrings/docker.asc.

Evidence ledger

Last updated
Methodology
This tutorial was written and edited by Lowell K. Wood IV in St. Louis County, MO. Specs and prices verified against vendor and project documentation current on the date above. Full editorial standard: methodology.
Update log
  • 2026-08-15 — Last reviewed and updated.
Corrections
Spotted an error or a stale number? Email hello@techfuelhq.com. Confirmed corrections are added to the update log above.

About the author

Written by Lowell K. Wood IV, who builds and runs TechFuelHQ from St. Louis, Missouri.