How to Install Docker on Ubuntu 20.04 Focal Fossa

1776
Share:
how-to-install-docker-on-ubuntu-20-04-focal-fossa

As published on Wikipedia, Docker is a set of platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files; they can communicate with each other through well-defined channels. All containers are run by a single operating-system kernel and are thus more lightweight than virtual machines.

We'll cover the installation of Docker on Ubuntu 20.04 Focal Fossa in this article.

Update Local Packages and Install Dependencies

First, make sure our packages are up-to-date. Then, install all the packages used by Docker as dependencies. Open up a terminal and type this command:

$ sudo apt update
$ sudo apt upgrade
$ sudo apt install apt-transport-https ca-certificates curl gnupg lsb-release

Update Ubuntu Package

Upgrade Ubuntu Packages

Install Dependencies

The upgrade process could take some time, depends on how frequent your system being updated and your internet connection.

Add Docker GPG Key and Repository

We need to add Docker GPG key used for signing Docker packages and add Docker upstream repository to our Ubuntu 20.04 Focal Fossa. This is necessary step so we can install the latest stable release of Docker.

First, let's import Docker's GPG key into our system:

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

Next, we need to create Docker's repository configuration file:

$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable"

Import Docker Repository

Docker Installation

Now we're at the main installation process. We will install the latest version of Docker. But before proceed further, we must make sure that we're using Docker repository instead of default Ubuntu's one.

$ apt-cache policy docker-ce

Update apt-cache

From the command response, we know that docker-ce is not installed, but the candidate for installation is from the Docker repository for Ubuntu 20.04 (Focal Fossa).

Once we are sure that we're using Docker repository, if your system has Docker installed from the Debian repository before, you must remove it using the command below:

$ sudo apt remove docker docker-engine docker.io containerd runc

Now we can install the latest version of Docker:

$ sudo apt install docker-ce

Docker Installation

To continue with installation, press "Y" followed by "Enter".

Let's sit back and relax until this process completed. When it's completed, the docker group is created but no users are added. To be able to use Docker, add our normal user to the group to run Docker commands as non-privileged user.

$ sudo usermod -aG docker $USER

To make this change effective, we need to log out and log back in so that our group membership is re-evaluated.

Verify Installation

Next step is verify that our installation is successful. Back to our terminal, enter this command:

$ systemctl is-enabled docker
$ systemctl status docker

If everything is correct, it should respond with something like below:

Verify Installation

Now, let's run a test Docker container:

$ docker run --rm -it  --name test alpine:latest /bin/sh

It should respond with something like this:

Alpine Linux Docker

If it does, congratulations, we've successfully installed Docker Community Edition on our Ubuntu 20.04 Focal Fossa.

Final Words

Well, that's it. I hope that you now know how to install Docker Community Edition on Ubuntu 20.04 Focal Fossa. If you run into any issues or have any feedback feel free to drop a comment below.

Tags Linux
Share:

0 comment

Leave a reply

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