Blog

How to Install Docker on Ubuntu (Step-by-Step Guide)

Docker is a powerful open-source containerization platform that allows developers to build, test, and deploy applications as lightweight, portable containers. These containers include everything an application needs to run dependencies, libraries, and runtime, while staying isolated from the host system.

Because of its speed, portability, and scalability, Docker has become a core tool in modern software development and DevOps pipelines.

In this tutorial, we’ll walk you through installing the latest version of Docker on Ubuntu.

Supported Ubuntu Versions

At the time of writing, the official Docker repository provides packages for:

  • Ubuntu 23.10 (Mantic)
  • Ubuntu 22.04 (Jammy)
  • Ubuntu 20.04 (Focal)

We’ll use Docker’s official repository to ensure you always get the latest stable release.

Step 1: Update Your System

Update the package index and install essential dependencies for adding a secure repository:

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

Step 2: Add Docker’s GPG Key

Create a keyring directory and import the Docker GPG key:

sudo mkdir -p /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc

Step 3: Add the Docker Repository

Add Docker’s official repository to your system:

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] \
  https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list

$(lsb_release -cs) prints your Ubuntu codename (e.g., jammy for 22.04).

Update the package list:

sudo apt update

Step 4: Install Docker

To install the latest version of Docker CE (Community Edition), run:

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

Step 5: Installing a Specific Docker Version (Optional)

If you want a specific Docker version, first list all available versions:

apt list -a docker-ce

Example output:

docker-ce/jammy 5:26.0.0-1~ubuntu.22.04~jammy amd64
docker-ce/jammy 5:25.0.5-1~ubuntu.22.04~jammy amd64
...

Install a chosen version by specifying it:

DOCKER_VERSION=5:24.0.7-1~ubuntu.23.10~mantic
sudo apt install docker-ce=$DOCKER_VERSION docker-ce-cli=$DOCKER_VERSION containerd.io docker-buildx-plugin docker-compose-plugin -y

Step 6: Verify Docker Installation

Check Docker’s service status:

sudo systemctl status docker

Run the test container:

docker run hello-world

If successful, Docker will print “Hello from Docker” and exit.

Step 7: Run Docker Without sudo

By default, only root or sudo users can run Docker. To allow your user account to run Docker:

sudo usermod -aG docker $USER

Log out and log back in, then test:

docker run hello-world

Step 8: Update or Hold Docker Packages

  • To update Docker when a new version is released:
sudo apt update && sudo apt upgrade -y
  • To prevent updates (pin the version):
sudo apt-mark hold docker-ce

Conclusion

You’ve successfully installed Docker on Ubuntu. 🎉

Docker makes it easy to build, test, and deploy applications consistently across environments. From simple test containers to production-grade deployments, Docker is a must-have tool in your DevOps toolkit.

Read more : Uninstall docker

0xSnow

0xSnow is a cybersecurity researcher with a focus on both offensive and defensive security. Working with ethical hacking, threat detection, Linux tools, and adversary simulation, 0xSnow explores vulnerabilities, attack chains, and mitigation strategies. Passionate about OSINT, malware analysis, and red/blue team tactics, 0xSnow shares detailed research, technical walkthroughs, and security tool insights to support the infosec community.

Recent Posts

How AI Puts Data Security at Risk

Artificial Intelligence (AI) is changing how industries operate, automating processes, and driving new innovations. However,…

1 week ago

The Evolution of Cloud Technology: Where We Started and Where We’re Headed

Image credit:pexels.com If you think back to the early days of personal computing, you probably…

2 weeks ago

The Evolution of Online Finance Tools In a Tech-Driven World

In an era defined by technological innovation, the way people handle and understand money has…

2 weeks ago

A Complete Guide to Lenso.ai and Its Reverse Image Search Capabilities

The online world becomes more visually driven with every passing year. Images spread across websites,…

2 weeks ago

How Web Application Firewalls (WAFs) Work

General Working of a Web Application Firewall (WAF) A Web Application Firewall (WAF) acts as…

2 months ago

How to Send POST Requests Using curl in Linux

How to Send POST Requests Using curl in Linux If you work with APIs, servers,…

2 months ago