Docker has become one of the most important tools in modern software development, DevOps, cloud engineering, and system administration.
Whether you are building microservices, running databases, deploying web applications, experimenting with Kubernetes, or setting up an AI development environment, Docker provides a consistent way to package and run applications.
In this guide, we'll install Docker Engine on Ubuntu using Docker's official APT repository.
The process is straightforward and works well for developers, DevOps engineers, SREs, system administrators, and anyone learning containerization.
🐳 What Is Docker?
Docker is a containerization platform that allows applications and their dependencies to run inside isolated environments called containers.
Instead of installing every application dependency directly onto your Ubuntu system, you can package an application into a container and run it consistently across different environments.
A typical Docker workflow looks like this:
Application
↓
Dockerfile
↓
Docker Image
↓
Docker Container
↓
Application RunningFor example, instead of installing a database directly on Ubuntu, you could run PostgreSQL inside a Docker container.
🧩 Prerequisites
Before installing Docker, make sure you have:
- An Ubuntu system
- Internet connectivity
- A user with
sudoprivileges - A terminal
- Basic familiarity with Linux commands
It is also a good idea to update your system before starting.
🚀 Step 1: Update Ubuntu
Open Terminal:
Ctrl + Alt + TThen run:
sudo apt update && sudo apt upgrade -yThis updates the package index and installs available package upgrades.
Depending on how recently your system was updated, this may take a few minutes.
📦 Step 2: Install Required Dependencies
Docker's repository setup requires several supporting packages.
Install them with:
sudo apt install -y ca-certificates curl gnupg lsb-releaseThese packages provide tools required to securely access and configure external APT repositories.
🔐 Step 3: Add Docker's Official GPG Key
Create the directory used to store APT repository keys:
sudo mkdir -p /etc/apt/keyringsNow download Docker's official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpgThe key allows APT to verify packages obtained from Docker's repository.
🗂️ Step 4: Add the Docker APT Repository
Next, configure Ubuntu to use Docker's official package 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/nullThis command dynamically detects:
- Your CPU architecture
- Your Ubuntu release codename
- Docker's stable repository
The repository configuration is written to:
/etc/apt/sources.list.d/docker.list