How to install Docker Engine on Ubuntu 20.04

Senali
2 min readMay 7, 2023

--

There is different ways to install docker on ubuntu. What method should I will use to install docker?? It will depends on your needs.

  1. Docker Engine comes bundled with Docker Desktop for Linux.
  2. Set up and install Docker Engine from Docker’s apt repository.
  3. Install it manually and manage upgrades manually.
  4. Use a convenience scripts. Only recommended for testing and development environments.

Here I will use the second method. Use Docker apt repository for installation.

  1. Setup docker repository

i. Update the apt package

sudo apt-get update

ii. Install packages to allow apt to use a repository over https

sudo apt-get install ca-certificates curl gnupg

iii. Add Docker’s official GPG key

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

iv. Set up the repository

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

2. Install Docker Engine

i. Update the apt package

sudo apt-get update

ii. Install Docker Engine, containerd, and Docker Compose

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

iii. Verify the Docker Engine installation

sudo docker run hello-world

After successfully installation you can see following result. When verify it using run “hello-world” docker image.

Reference

Docker Doc

Thank You!

--

--

Senali

I write about stuff I find interesting. Usually WebDev, DevOps, ML and occasionally Finance