← Back to list

How to Install Docker on Ubuntu Server 22.04.5 (The Right Way)

A complete, copy‑paste guide for beginners and sysadmins

Md. Mahim Hossain · 2026-05-09 07:45 · 55 claps · 2.6 min read
#soc #docker #docker-compose #docker-image #linux
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud 🔒 · Cybersecurity 🔓 · Open Source

How to Install Docker on Ubuntu Server 22.04.5 (The Right Way)

A complete, copy‑paste guide for beginners and sysadmins

If you’re running Ubuntu Server 22.04.5 and want to containerize your apps, Docker is the industry standard. But installing it correctly — not just apt install docker.io — makes all the difference for security, updates, and long‑term stability.

In this guide, I’ll walk you through the official Docker method using their GPG key and repository. You’ll end up with a production‑ready installation and learn why each step matters.

Why not the Ubuntu default package? The docker.io package in Ubuntu’s repos is often outdated. Docker’s own repo gives you the latest stable release, security patches, and tools like docker compose plugin.

Prerequisites

  • A machine (or VM) running Ubuntu Server 22.04.5 LTS.
  • sudo privileges.
  • An internet connection.

Step 1 — Update Your System & Install Prerequisites

First, refresh the package index and install ca-certificates and curl. These are needed to fetch Docker’s GPG key securely.

sudo apt update
sudo apt install ca-certificates curl -y

Step 2 — Add Docker’s Official GPG Key

Package managers use GPG keys to verify that the software you download hasn’t been tampered with. We’ll create a special directory and store the key there.

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

What’s happening?

  • install -m 0755 -d creates /etc/apt/keyrings with safe permissions.
  • curl downloads the key.
  • chmod a+r makes the key readable by everyone (required by APT).

Step 3 — Add the Official Docker Repository

Now we tell APT where to find Docker’s software. The command below automatically detects your Ubuntu version (jammy for 22.04) and your CPU architecture (amd64, arm64, etc.).

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Then update APT again so it sees the new repository:

sudo apt update

If you ever see a “GPG error” in the future, it’s likely because the key expired. Run sudo apt update again – Docker automatically renews the key.

Step 4 — Install Docker Engine and Plugins

This single command installs the Docker daemon (docker-ce), the CLI (docker-ce-cli), the container runtime (containerd.io), and the official buildx and compose plugins.

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

Step 5 — Start Docker and Enable Auto‑Start

Even after installation, the Docker service may not be running. Let’s start it and make sure it comes back after a reboot.

sudo systemctl start docker
sudo systemctl enable docker

To verify that Docker is active:

sudo systemctl status docker

You should see active (running) in green.

Step 6 — Test With hello-world

Nothing beats a real test. Run the official hello-world container:

sudo docker run hello-world

If everything works, you’ll see a friendly message like:

Hello from Docker! This message shows that your installation appears to be working correctly.

Optional — Run Docker Without sudo (Highly Recommended)

Typing sudo before every docker command gets old fast. Adding your user to the docker group removes that need.

# Add your current user to the docker group
sudo usermod -aG docker $USER

# Activate the group change in your current shell
newgrp docker

# Test without sudo
docker run hello-world

Final Thoughts

You’ve now installed Docker on Ubuntu Server 22.04.5 using the official, secure, and update‑friendly method. Whether you’re spinning up a local dev environment or provisioning a production host, this setup will serve you well.

Remember to check for updates regularly:

sudo apt update && sudo apt upgrade

Docker releases new versions often, so staying updated gives you the latest features and security fixes.

Enjoy containerizing your world! 🐳


메타데이터
post_id
b08deae48b2c
slug
how-to-install-docker-on-ubuntu-server-22-04-5-the-right-way-b08deae48b2c
url
https://medium.com/@mahimsec/how-to-install-docker-on-ubuntu-server-22-04-5-the-right-way-b08deae48b2c
canonical_url
https://medium.com/@mahimsec/how-to-install-docker-on-ubuntu-server-22-04-5-the-right-way-b08deae48b2c
author_url
https://medium.com/@mahimsec
status
ok
fetched_at
2026-06-09 15:37:30