How to Install Docker on Ubuntu 20.04.

Hi hope you are doing well, lets learn about “How to Setup and Install Docker on Ubuntu 20.04”, the Docker is the fastest growing technology in the IT market. Docker is the container technology.

Many industries are moving towards docker from the normal EC2 instances. It is PAAS (Platform as a Service), which uses a OS virtualisation to deliver software in packages called containers.

The containers are the bundle of the packages, library files, and some configuration files. It was first started in 2013 and developed by Docker, Inc.

So lets have the Setup of Docker CE on Ubuntu 20.04 Step by Step Guide.

Setup and Install Docker CE on Ubuntu 20.04

STEP 1: Update the Repository for the Docker to setup and Install on Ubuntu 20.04.

So firstly we will update the repository and install some of packages with the apt command.

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

Let’s add the Docker’s official GPG key:

$ curl -fsSL | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

Now Update the repo and use cat command to check the added docker repo to install in Ubuntu 20.04.

echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
cat /etc/apt/sources.list.d/docker.list

deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg]   focal stable
Added the Repo for the docker in Ubuntu 20.04.
$ sudo apt update

Now update the repository for the docker and Install Docker on Ubuntu 20.04.

STEP 2: Setup and Install Docker CE on Ubuntu 20.04 via apt command.

So, install docker-ce, docker-ce-cli and packages in Ubuntu.

$ sudo apt install docker-ce docker-ce-cli
apt install for Docker CE.

Once the docker installation get’s completed , check the status of services for the docker and enable it after rebooting the System.

$ sudo systemctl status  docker.service
Install Docker on Rocky Linux 8
Check the Docker Status

So we have check the status for docker, and it is active running on the Ubuntu 20.04, so enable the service for docker at the time of booting.

$ sudo systemctl enable docker.service

STEP 3: Add the User in Docker Group.

Now lets add user “tastethelinux” into the docker group.

$ sudo usermod -aG docker $USER

“$USER” is the username tastethelinux, you can use whoami to check the username.

docker --version
Docker version 20.10.8, build 3967b7d

So then check version using docker command without sudo, you will get the version for the docker.

Let’s check the installation with the docker info command, which gives the information about the Docker.

$ docker info
docker info

So we have successfully install Docker CE on Ubuntu 20.04, lets create a Container for the MongoDB.

STEP 4: Test Docker by Pulling Images.

So here we will create a container for MongoDB on docker, let’s use the pull command to pull the MongoDB image first.

Install Docker on Rocky Linux 8
docker pull image_name
$ docker pull mongo

So we have pulled the images for mongo from the docker, Once it’s completed you can check the image by using “docker images”.

$ docker images

STEP 5: Run Docker Container in Ubuntu 20.04.

Now let’s run the docker container by using docker run command.

$ docker run -d mongo

So we have successfully run the docker container in Ubuntu 20.04 for MongoDB, now if we have to verify the container is running or not use “docker ps” command.

$ docker ps 

Run the container for MongoDB server on Ubuntu 20.04.

If you want to install MongoDB on EC2 instances follow the link, Install Docker on CentOS 8, Want to Install Docker CE on Rocky linux 8, Install Docker Compose on Rocky Linux 8, Install Docker on CentOS 7. Thanks to Read the article. Keep Supporting US.

4 Replies to “How to Install Docker on Ubuntu 20.04.

  1. Thanks, this is the only guide not throwing errors galore for me when used. I did have to reference another article on the user docker group thing, but well done.

    sudo usermod -aG docker ${USER}.
    su – ${USER}

Give your valuable time