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
sudoprivileges - 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
dockergroup 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 thedockergroup yet, or you have not logged out and back in since Step 5. Re-run theusermodline, then log out/in.docker: 'compose' is not a docker command— you installed the olddocker.ioor Snap package instead ofdocker-ce. Remove it (Step 1) and install from the official repo (Steps 2–3), which includes the Compose plugin.NO_PUBKEY/GPG erroronapt update— the GPG key step did not complete. Re-run the four key commands in Step 2 and check the key exists withls -l /etc/apt/keyrings/docker.asc.Unable to locate package docker-ce— the repository was not added orapt updatewas not run after adding it. Re-check/etc/apt/sources.list.d/docker.sourcesexists and re-runsudo apt update.- Behind a proxy or on a fresh server,
curlfails — installcurlfirst (sudo apt install curl) and confirm the box can reachdownload.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?
Why do I get 'permission denied while trying to connect to the Docker daemon socket'?
Which Ubuntu versions does this work on?
Do I need to install Docker Compose separately?
Is Docker Engine on Ubuntu the same as Docker Desktop?
How do I uninstall Docker from Ubuntu?
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.