Skip to main content

Dive into the world of containerization as we unravel the seamless process of installing Docker on Ubuntu 22.04 and 20.04. Follow these easy steps to empower your system with the agility and efficiency of Docker.

Installing Docker on Ubuntu 22.04|20.04

Installation methods :

Install using the apt repository

1) Set up Docker’s apt repository:

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

2) Install the Docker packages

sudo apt-get install docker-ce docker-ce-cli docker-buildx-plugin docker-compose-plugin

3) Verify that the Docker Engine installation

sudo docker run hello-world

Congratulations ! You have now successfully installed and started Docker Engine.

Bonus : Want to run docker without sudo ?

The docker user group exists but contains no users, which is why you’re required to use sudo to run Docker commands

1) Create the docker group

sudo groupadd docker

2) Add your user to the docker group

sudo usermod -aG docker $USER

3) Log out and log back in so that your group membership is re-evaluated

Enjoy Docker without sudo !

Close Menu

Welcome to Coded Brainy

Coded Brainy Provides you with technical blogs

Coded Brainy