Docker Installation on Ubuntu Linux.

Hi hope you are doing well, lets learn about “Docker installation on Ubuntu 20.04 Linux”, the Docker is the fastest growing technology in the IT market. Docker is the container technology.

So 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 Linux Step by Step Guide.


Docker Installation on Ubuntu Linux.

STEP 1: Update the Repository for the Docker installation on Ubuntu 20.04 Linux.

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 https://download.docker.com/linux/ubuntu/gpg | 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 for installation in Ubuntu 20.04.

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

OUTPUT :
deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu   focal stable
Docker Installation on Ubuntu Linux.
Added the Repo for the docker in Ubuntu 20.04.
$ sudo apt update

Now update the repository for the installation of docker on Ubuntu.


STEP 2: Installation for Docker CE on Ubuntu 20.04 via apt command.

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

$ sudo apt install docker-ce docker-ce-cli containerd.io
Docker Installation on Ubuntu Linux.
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 Ubuntu
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
OUTPUT:
Docker version 20.10.8, build 3967b7d

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

So lets check the installation with the docker info command, which gives the information about the Docker.

$ docker info
Docker Installation on Ubuntu Linux.
docker info

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


STEP 4: Pull MongoDB Docker Image.

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

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 MongoDB Docker Container in Ubuntu linux.

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

$ docker run -d mongo

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

$ docker ps 
docker ps command

So we have done with the installation for docker on Ubuntu, also run the MongoDB Docker container. Now let’s Install Docker Compose in Ubuntu linux.


Docker Compose Installation on Ubuntu Linux.

So lets see the installation of Docker Compose on Ubuntu Linux, with the curl command.

$ sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

So, the above command will install docker compose in “/usr/local/bin” directory, now give the executable permission to the “docker-compose” script.

$ sudo chmod +x /usr/local/bin/docker-compose

Now lets create soft link for “docker-compose”, and check the docker compose version.

$ sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

$ docker-compose –version

OUTPUT:
docker-compose version 1.29.2, build 5becea4c

So, in this Post We have seen the Installation of Docker, Install MongoDB Docker on Docker Container, Installation of Docker Compose on Ubuntu linux.

f 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.


Give your valuable time