Docker Installation

Docker is available in two editions:

  1. Community Edition (CE)
  2. Enterprise Edition (EE)

Docker Community Edition (CE) is ideal for individual developers and small teams looking to get started with Docker and experimenting with container-based apps.

Docker Enterprise Edition (EE) is designed for enterprise development and IT teams who build, ship, and run business critical applications in production at scale.

Let’s see how to install Docker CE on Linux.

Step 1 : Uninstall old versions

Older versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated dependencies.

CentOS :

$ sudo yum remove docker 

Ubuntu :

$ sudo apt-get remove docker docker-engine

Step 2 : Set up the Repository.

CentOS :

  1. Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
    $ sudo yum install -y yum-utils 
  2. Use the following command to set up the stable repository. You always need the stable repository.
    $ sudo yum-config-manager 

Ubuntu :

  1. Update the apt package index:
    $ sudo apt-get update
  2. Install packages to allow apt to use a repository over HTTPS:
    $ sudo apt-get install 
  3. Add Docker’s official GPG key:
    $ curl -fsSL | sudo apt-key add -Use the following command to set up the stable repository.
  4. Use the following command to set up the stable repository.
    $ sudo add-apt-repository 
       "deb [arch=amd64] 
       $(lsb_release -cs) 

Step 3 : Install Docker CE

CentOS :

$ sudo yum install docker-ce

Ubuntu :

  1. Update the apt package index.
    $ sudo apt-get update
  2. Install the latest version of Docker CE.
    $ sudo apt-get install docker-ce

Step 4 : Start Docker

$ sudo systemctl start docker
$ sudo systemctl enable docker

Step 5 : Verify Docker

  1. Verify that Docker CE is installed correctly by running the hello-world image.
$ sudo docker run hello-world

Uninstalling Docker CE

Ubuntu :

  1. Uninstall the Docker CE package:
    $ sudo apt-get purge docker-ce
  2. Images, containers, volumes, or customized configuration files on your host are not automatically removed. To delete all images, containers, and volumes:
    $ sudo rm -rf /var/lib/docker


  1. Uninstall the Docker EE package:
    $ sudo yum -y remove docker-ce
  2. Delete all images, containers, and volumes (because these are not automatically removed from your host):
    $ sudo rm -rf /var/lib/docker
  3. If desired, remove the devicemapper thin pool and reformat the block devices that were part of it.

Installation Script

The easiest way to install docker with installation script. Below is the script url. Make sure the user should have sudo privileges.

Execute the below two commands to install docker.

$ curl -fsSL -o
$ sh

$ curl -fsSL -o
$ sh
# Executing docker install script, commit: fc04d2c
+ sudo -E sh -c 'yum install -y -q yum-utils'
Package yum-utils-1.1.31-42.el7.noarch already installed and latest version
+ sudo -E sh -c 'yum-config-manager --add-repo'
Loaded plugins: fastestmirror
adding repo from:
grabbing file to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
+ '[' edge '!=' stable ']'
+ sudo -E sh -c 'yum-config-manager --enable docker-ce-edge'
Loaded plugins: fastestmirror

Start docker 

$ sudo systemctl start docker

Check version of Docker

$ docker --version 
Docker version 18.02.0-ce, build fc4de44

After installation completed, execute below command to run docker commands as non root.

$ sudo usermod -aG docker centos

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s