November 24, 2020
How to install Docker CE on Ubuntu 20.04

How To Install Docker On Ubuntu 20.04 LTS

On this article we will discuss how to install Docker Community Edition on Ubuntu 20.04 LTS Focal Fossa.

Introduction

Docker is an open-source platform for building, testing, and running applications. Docker enables us to separate the applications from infrastructure boundaries so we can deliver applications quickly. With Docker, we can manage our infrastructure in the same ways as we manage our applications. By taking advantage of Docker’s methodologies for shipping, testing, and deploying code quickly, we can significantly reduce the delay between writing code and running it in production.

In this article we will discuss how to install Docker (Community Edition) on Linux Ubuntu 20.04 Operating system.  Docker source has been available on the standard Ubuntu 20.04 repositories, but we will choose the Docker source from the official Docker’s repositories. The reason for this option because, we want an updated version since Docker via Ubuntu repositories may not always be the latest version. There will be several steps for installing Docker on Ubuntu 20.04 LTS, it will be described deeply below :

  • Prerequisite
  • Installing Docker on Ubuntu 20.04
  • Executing Docker Commands as a Non-Root User
  • Verifying the Installation

Prerequisite

Before continuing  Docker installation tutorial, we have to prepare our Ubuntu 20.04 (Focal Fossa) environment first. Docker installation requires a user with sudo privileges, sufficient space and the last update of good internet connection for downloading required package. In our environment we have all the necessary requirements.

Installing Docker on Ubuntu 20.04

After all prerequisite are met, the next step is to enable the Docker repository, import the repository GPG key, and install the package. Firstly we have to update the packages index and install the dependencies necessary, by submitting command line below.

ramans@ubuntu:~$ sudo apt update
ramans@ubuntu:~$ sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common

Ubuntu 20.04 apt update

ubuntu 20.04 install dependecies

And then the import repository’s GPG key using the following curl command line below.

ramans@ubuntu:~$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add

Docker Ubuntu repo GPG

And finally we add the Docker APT repository to our Ubuntu 20.04 system:

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

Add Docker Repository

Until now, the Docker repository has been added, to verify it, we will check the file below.

ramans@ubuntu:~$ more /etc/apt/sources.list

The output will be as follow :

# deb cdrom:[Ubuntu 20.04 LTS _Focal Fossa_ - Release amd64 (20200423)]/ focal main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ focal main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ focal universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal universe
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ focal multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu focal partner
# deb-src http://archive.canonical.com/ubuntu focal partner

deb http://security.ubuntu.com/ubuntu focal-security main restricted
# deb-src http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
# deb-src http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse
# deb-src http://security.ubuntu.com/ubuntu focal-security multiverse

# This system was installed using small removable media
# (e.g. netinst, live or single CD). The matching "deb cdrom"
# entries were disabled at the end of the installation process.
# For information about how to configure apt package sources,
# see the sources.list(5) manual.
deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable
# deb-src [arch=amd64] https://download.docker.com/linux/ubuntu focal stable

Now, the prerequisite packages and repositories has been enabled, and we will continue to install. The installation process will through several process, as explained below.

1. Update the Ubuntu system to mention the last repositories added, with the command line below.

ramans@ubuntu:~$ sudo apt update

2. install Docker Community Edition with the command line below.

ramans@ubuntu:~$ sudo apt install docker-ce docker-ce-cli containerd.io

Docker CE installation on Ubuntu 20.04

 

The output will be as follow. The docker version while this article is written is (5:19.03.9~3-0~ubuntu-focal).

...
Setting up pigz (2.4-1) ...
Setting up git-man (1:2.25.1-1ubuntu3) ...
Setting up cgroupfs-mount (1.4) ...
Setting up docker-ce (5:19.03.9~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.
Setting up git (1:2.25.1-1ubuntu3) ...
Processing triggers for systemd (245.4-4ubuntu3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...

After the installation is completed, the Docker service will start automatically. You can verify it by typing:

ramans@ubuntu:~$ sudo systemctl status docker

Docker systemctl

So far, the installation of Docker open platform on Ubuntu 20.04 LTS has been done succesfully.

Happy Eid Mubarak !!

 

Share this article via :

Leave a Reply

Your email address will not be published. Required fields are marked *