How to install Docker CE on ubuntu 16.04/18.04/20.04 LTS

Docker is an open-source lightweight virtualization tool. It is containerizing platform in which user can run and deploy application and its dependencies and form containers to run over any linux infrastructure.

Developed by: Docker, Inc.
Cross Platform  Linux OS, Mac SO, Window OS
Initial release: March 20, 2013

Docker hardware requirements

* Linux kernel version 3.10 or higher
* 8.00 GB of RAM for manager nodes or nodes running DTR
* 4.00 GB of RAM for worker nodes
* 3.00 GB of available disk space
* A static IP address

Add Docker Repository

You need to install some important packages, Use the given commands to install required packages.

sudo apt-get install curl -y
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable” 

Install Docker CE

Update the Ubuntu repository and install the Docker packages by using the following the commands.

sudo apt-get update -y
apt-cache policy docker-ce
sudo apt-get install -y docker-ce -y

Controlling Docker Daemon

To check docker service status 

sudo systemctl status docker.service

To start the docker service.

sudo systemctl start docker.service

To stop the Docker service.

sudo systemctl stop docker.service

To restart the Docker service.

sudo systemctl restart docker.service

To enable on boot the Docker service.

sudo systemctl enable docker.service

To disable on boot the Docker service.

sudo systemctl disable docker.service

Install Docker CE using bash script on ubuntu 16.04

You need to create a bash file called docker.sh and paste the given collection of commands, To do that use the below commands.

vim docker.sh

Now paste the given commands and save exit from vim editor.

sudo apt-get install curl -y
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –
sudo add-apt-repository “deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable”

sudo apt-get update -y

apt-cache policy docker-ce
sudo apt-get install -y docker-ce -y

To install Docker CE execute the docker.sh bash script by following the commands.

sh docker.sh

Docker Hub

Docker Hub is the world’s largest library and community for container images. Browse over 100,000 container images from software vendors, On docker hub we find the lots of os images like ubuntu, centOS, redhat, pre install apache/nginx, and tomcat packages.

To check images status in local machine, We need to use given commands.

To check local images use the following the commands.

sudo docker images

To download Docker image from Docker hub use the following commands.

sudo docker pull image_name_here

Example – sudo docker pull ubuntu 

To remove the docker images use the following commands.

sudo docker rmi image_name_here

Example – sudo docker rmi ubuntu

Creating first Docker container using ubuntu docker image.

To create ubuntu os docker container, Need to use following commands.

docker run -it ubuntu

To check status of the Docker container use the following commands for offline docker container. 

docker ps -a

To get status of running Docker container use the following commands.

docker ps  

To delete or remove docker container use the following commands, First you need to stop the running Docker container and then remove the container. 


docker stop docker_id   

docker rm docker_id or name

Port Mapping Using Docker 

To configure host port and docker port use the following commands.


docker run -p 7777:80 -it ubuntu

For multiple port use the following commands.

docker run -p 7777:80 -p 7878:3600 -it ubuntu

Mounting Using Docker

To mount host directory to docker container use the following commands.


mkdir /tmp/docker_mount
echo “I am from Mounted from host-machine” > /tmp/docker_mount/index.html 

docker run -v /tmp/docker_mount:/var/www/html -p 7777:80 –hostname wordpress –name wordpress -it ubuntu

How to install Docker CE on ubuntu 16.04/18.04/20.04 LTS

2 thoughts on “How to install Docker CE on ubuntu 16.04/18.04/20.04 LTS

Leave a Reply

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

Scroll to top