Guides 11792 Published by

This quick guide walks you through installing Docker on Ubuntu 22.04 by first removing any old remnants, updating the system, and adding Docker’s official GPG key and repository so that you get the latest stable packages. After those preparatory steps, it shows how to install the Docker Engine along with optional buildx and compose plugins, then verifies the installation with a simple hello‑world container run. It also recommends adding your user to the docker group to avoid having to prefix every command with sudo, which can save you time after the first deployment. With everything in place, Docker should be up and running on your machine in under fifteen minutes, and any hiccups can usually be traced back through the service logs or community forums.



How to Install Docker on Ubuntu 22.04 (Without a Hitch)

If you’ve ever tried to spin up a container and ended up staring at a wall of dependency errors, this quick guide will get Docker running on your 22.04 machine in under fifteen minutes—no extra fluff, just the steps that actually matter.

1. Drop the old Docker remnants first
sudo apt purge docker-ce docker-ce-cli containerd.io

A stale installation can leave behind a half‑configured docker binary and broken packages that will bite you later. Removing everything gives us a clean slate.

2. Make sure your system is ready to ship
sudo apt update && sudo apt upgrade -y
sudo apt install ca-certificates curl gnupg lsb-release

ca‑certificates keeps HTTPS happy, curl fetches the keys, and gnupg verifies them. The lsb-release command tells us our Ubuntu codename (focal or jammy) automatically.

3. Add Docker’s official GPG key
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
  sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

I’ve seen newbies add the key to /usr/share/keyrings and then run into permission errors later. Storing it in /etc/apt/keyrings is the safer bet.

4. Set up the stable Docker repository
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

This line tells APT where to pull the Docker packages from. If you skip it, you’ll end up with an old version from Ubuntu’s own repos that won’t support the latest Compose syntax.

5. Install Docker Engine
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

The docker-buildx-plugin and docker-compose-plugin are optional but handy if you plan to build multi‑arch images or run Compose files.

6. Verify the installation
sudo systemctl status docker
docker run hello-world

If you see “Hello from Docker!” it means your daemon is up, your network stack is healthy, and your user can pull images without sudo. If not, check the service logs for missing dependencies.

7. Add yourself to the docker group (optional but recommended)
sudo usermod -aG docker $USER
newgrp docker

I once tried to run docker ps right after installing and got a “permission denied” error. Adding your account to the docker group lets you use Docker without prepending every command with sudo.

That’s it—Docker is ready to run on Ubuntu 22.04. If anything goes sideways, the logs are usually self‑explanatory, and the community forums love a clear recipe like this one.