How to Install Docker on Ubuntu 22.04: A Step-by-Step Guide
Docker has become a cornerstone of modern software development and system administration. Whether you're running containers for local development, hosting web apps, or experimenting with microservices, Ubuntu 22.04 (Jammy Jellyfish) is one of the most reliable platforms to do it on. Here's exactly how to get Docker up and running — and what to understand before you start.
What Docker Actually Does
Before touching a terminal, it's worth being clear on what you're installing. Docker is a containerization platform that lets you package applications and their dependencies into isolated, portable units called containers. Unlike virtual machines, containers share the host OS kernel, making them lightweight and fast to spin up.
On Ubuntu 22.04, Docker runs natively via the Linux kernel's built-in container features — cgroups and namespaces — which means you get solid performance without hypervisor overhead.
There are two main Docker products to know:
| Product | What It Is |
|---|---|
| Docker Engine | The core daemon and CLI — what most developers install on Linux |
| Docker Desktop for Linux | A GUI-based app with additional tooling, suited for desktop workflows |
Most server and developer use cases on Ubuntu 22.04 only require Docker Engine.
Before You Begin: System Requirements and Prep
Ubuntu 22.04 supports Docker Engine on 64-bit x86 (amd64), ARM64, and ARMhf architectures. If you're unsure of yours, run:
uname -m You'll also want a non-root user with sudo privileges and a working internet connection. The installation pulls packages from Docker's official repository, so access to external repositories matters.
One important step first: remove any older or conflicting Docker packages that may have been installed from Ubuntu's default repositories. Ubuntu ships a version called docker.io, but it's often outdated compared to Docker's official release.
sudo apt remove docker docker-engine docker.io containerd runc This won't delete any images or containers if Docker was previously configured with a separate data directory, but it clears the path for a clean install.
Installing Docker Engine from Docker's Official Repository 🐳
The recommended method is pulling Docker directly from Docker's own APT repository. This ensures you get the latest stable release and ongoing updates.
Step 1: Update and Install Prerequisites
sudo apt update sudo apt install ca-certificates curl gnupg These packages allow your system to securely fetch and verify Docker's signing key.
Step 2: Add Docker's Official GPG Key
sudo install -m 0755 -d /etc/apt/keyrings curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg This stores Docker's GPG key so your system can verify package authenticity — a critical security step.
Step 3: Set Up the Docker Repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null The $(dpkg --print-architecture) and $VERSION_CODENAME variables auto-detect your system, so this command works across architectures and Ubuntu versions without manual editing.
Step 4: Install Docker Engine
sudo apt update sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin This installs:
- docker-ce — the Docker Engine daemon
- docker-ce-cli — the command-line interface
- containerd.io — the container runtime
- docker-buildx-plugin — extended build capabilities
- docker-compose-plugin — runs multi-container apps via
docker compose
Step 5: Verify the Installation
sudo docker run hello-world If Docker is installed correctly, this pulls a test image and prints a confirmation message. If you see it, the daemon is running.
Post-Installation: Running Docker Without Sudo
By default, Docker commands require root privileges. For most workflows, you'll want to add your user to the docker group so you can run containers without prefixing every command with sudo:
sudo usermod -aG docker $USER Log out and back in (or run newgrp docker) for the change to take effect. After that, docker run hello-world should work without sudo.
⚠️ Note: Users in the docker group have effective root-level access to the Docker daemon. On shared or production systems, weigh that access carefully against your security posture.
Managing the Docker Service
Docker runs as a systemd service on Ubuntu 22.04. Useful commands:
sudo systemctl start docker # Start the daemon sudo systemctl stop docker # Stop it sudo systemctl enable docker # Auto-start on boot sudo systemctl status docker # Check current status By default, Docker is set to start on boot after installation — but verifying with systemctl status is a good habit.
Variables That Shape Your Experience
How Docker behaves in practice depends heavily on your specific setup:
- Available RAM and CPU cores determine how many containers you can run simultaneously without contention
- Storage driver (overlay2 is the default on Ubuntu 22.04) affects container read/write performance
- Whether you're on bare metal vs. a VM can influence networking behavior and storage access
- Your use case — local development, CI/CD pipelines, production hosting — drives which additional tools (Docker Compose, Docker Swarm, a container registry) you'll actually need
- Networking requirements affect whether bridge networking, host networking, or custom networks make more sense for your containers
A developer running a few containers locally for testing works with a very different configuration than someone orchestrating a multi-service production application.
The installation steps above get Docker running cleanly on Ubuntu 22.04 — what you build on top of that foundation depends entirely on what you're trying to run and how your environment is structured.