This tutorial post will show you how to install docker on ubuntu 20.04 with step by step procedure.

In the previous posts, we have already shown you How to install docker on ubuntu 18.04, RHEL 7 and CentOS 7.

Refer our other similar tutorial posts for Docker. it might be useful to you if are a beginner and looking for docker tutorial from basics.

What is Docker – Get Started from Basics – Docker Tutorial
How to Install Docker on Ubuntu 18.04 – Docker Tutorial
How to Install Docker on CentOS 7 / RHEL 7
How to Run Docker Containers – Explained with Examples
Working with Docker Images – Explained with Examples
Dockerfile Explained with Examples of all Instructions
Understanding Docker Port Mapping to Bind Container Ports
How to Write Dockerfile To Build Your Own Docker Images
Create or Build Your Own Private Docker Registry on Linux

How to Install Docker on Ubuntu 20.04
How to Install Docker on Ubuntu 20.04

How to Install Docker on Ubuntu 20.04

Steps Involved:

Prerequisites to Install Docker on Ubuntu 20.04

  1. Ubuntu 20.04 Linux System.
  2. Sudo access to perform the docker installation.
  3. Internet connection is required.

How to Install Docker dependencies?

Before installing docker on ubuntu, lets update and install docker dependencies using apt-get command as below.

[email protected]:~$ sudo apt-get update
[email protected]:~$ sudo apt-get install -y curl ca-certificates lsb-release gnupg

Once you have updated your packages index and installed docker dependencies, lets enable docker repository and deploy the official docker GPG key.

How to Enable repository for docker and deploy GPG key?

Use curl command to add official docker GPG key else you will end up signing error.

[email protected]:~$ sudo curl -fssl https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
OK
[email protected]:~$

Once GPG key is added, we can enable the official docker repository for Ubuntu as below using add-apt-repository command.

[email protected]:~$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

Output:

Hit:1 https://download.docker.com/linux/ubuntu focal InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu focal InRelease
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:4 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:5 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Fetched 336 kB in 2s (169 kB/s)
Reading package lists... Done
[email protected]:~$

Once these GPG key and docker reopsitory is enabled, we can move to the next step to install docker on Ubuntu 20.04.

How to Install Docker on Ubuntu 20.04 using apt-get command?

As we have enabled docker repository newly, we need to re update the package index for the latest packages.

[email protected]:~$ sudo apt-get update

Now, use apt-get command to install docker with required packages.

[email protected]:~$ sudo apt-get install -y docker-ce containerd.io docker-ce-cli

Output Trimmed:

Setting up docker-ce-cli (5:20.10.14~3-0~ubuntu-focal) ...
Setting up pigz (2.4-1) ...
Setting up docker-ce-rootless-extras (5:20.10.14~3-0~ubuntu-focal) ...
Setting up docker-ce (5:20.10.14~3-0~ubuntu-focal) ...
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for systemd (245.4-4ubuntu3.15) ...
[email protected]:~$

Our task to install docker on ubuntu 20.04 is success. Now We need to make sure to check the installed docker version and also check whether the docker services are running properly or not.

How to Verify Installed Docker Version details?

Use docker command along with option version. This command will show you both docker client and docker server version details.

[email protected]:~$ sudo docker version

Output:

Client: Docker Engine - Community
 Version:           20.10.14
 API version:       1.41
 Go version:        go1.16.15
 Git commit:        a224086
 Built:             Thu Mar 24 01:48:02 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.14
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.15
  Git commit:       87a90dc
  Built:            Thu Mar 24 01:45:53 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.5.11
  GitCommit:        3df54a852345ae127d1fa3092b95168e4a88e2f8
 runc:
  Version:          1.0.3
  GitCommit:        v1.0.3-0-gf46b6ba
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

Above command shows us that, installed docker client and server versions are 20.10.14.

How to Check Docker Container Engine Status

Lets verify the docker service running or not as below.

[email protected]:~$ sudo systemctl status docker

Output:

docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Tue 2022-04-12 11:29:29 IST; 8min ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 5610 (dockerd)
      Tasks: 7
     Memory: 27.2M
     CGroup: /system.slice/docker.service
             └─5610 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Apr 12 11:29:28 ubuntu dockerd[5610]: time="2022-04-12T11:29:28.581818190+05:30" level=info msg="Loading containers: start."
Apr 12 11:29:29 ubuntu dockerd[5610]: time="2022-04-12T11:29:29.236502225+05:30" level=info msg="Default bridge (docker0) is assigned with an>
Apr 12 11:29:29 ubuntu dockerd[5610]: time="2022-04-12T11:29:29.411016540+05:30" level=info msg="Loading containers: done."
Apr 12 11:29:29 ubuntu dockerd[5610]: time="2022-04-12T11:29:29.562719980+05:30" level=info msg="Docker daemon" commit=87a90dc graphdriver(s)>
Apr 12 11:29:29 ubuntu dockerd[5610]: time="2022-04-12T11:29:29.563224477+05:30" level=info msg="Daemon has completed initialization"
Apr 12 11:29:29 ubuntu systemd[1]: Started Docker Application Container Engine.
Apr 12 11:29:29 ubuntu dockerd[5610]: time="2022-04-12T11:29:29.614746507+05:30" level=info msg="API listen on /run/docker.sock"

That’s it, hope this tutorial post helped you to understand how to install docker on Ubuntu 20.04.

If you are interested in learning, Request you to go through the below recommended tutorial.

DevOps Full Course Tutorial for Beginners – DevOps Free Training Online
Docker Full Course Tutorial for Beginners – Docker Free Training Online
Kubernetes Full Course Tutorial for Beginners – Kubernetes Free Training Online
Ansible Full Course Tutorial for Beginners – Ansible Free Training Online
Openstack Full Course Tutorial for Beginners – Openstack Free Training Online

Keep practicing and have fun. Leave your comments if any.

Support Us: Share with your friends and groups.

Stay connected with us on social networking sites, Thank you.

YouTube | Facebook | Twitter | Pinterest | Telegram