How to Install Docker on Ubuntu

Docker is an open-source platform that allows you to build, package, and deploy applications as containers.
While Docker can be installed together with Ubuntu, if your Ubuntu system doesn't have Docker installed, you can follow these steps to install Docker on an Ubuntu system.
Below are the steps to install Docker on an Ubuntu system.
Step 1: Install using the apt repository
Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.
- Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
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
Add Docker's official GPG key
- Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Add the repository to Apt sources
Step 2: Install the latest version Docker packages
To install the latest version, run:
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Step 3: Verify that the Docker Engine installation is successful
Running the hello-world image to verify that the Docker Engine is installed
sudo docker run hello-world
You will see these lines on your screen if the Docker is installed correctly:

When the container runs, it prints a confirmation message and exits.
You have now successfully installed and started Docker Engine!
Do you enjoy this blog post?