Docker – How to install Docker CE on CentOS 7 server

Docker is an open source platform, allowing the execution of isolated code inside a container. Very light, it does not ship operating system and relies on the core of its host.

The advantage is the very fast deployment of containers according to their needs.

Information : The installation already exists on the official web site. To have experienced it, it is very well explained.
 

Installation requirements

Before installing DockerCE on your machine, you must configure the appropriates repository. Then, you can install and update package (docker) from this repository.

First, install the prerequisites : yum-utilsdevice-mapper-persistent-data and lvm2

sudo yum install -y yum-utils device-mapper-persistent-data lvm2


 

Then, use the following command to configure the stable repository

sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo


 

Install Docker CE

This step allows you to install the latest version of Docker CE and containerd.

You must download the associated .rpm file for specific version. See chapter : Do you have multiple Docker repositories ?

sudo yum install docker-ce docker-ce-cli containerd.io


 

 
If you need to accept the GPG key, check that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35. If so, accept it.

You can view the software version with the command :

docker --version


 

Do you have multiple Docker repositories ?

If you have multiple repositories enabled, installing or updating without specifying a version in the update command always installs the highest version, which may be inconsistent with your requirements.

To install a specific version, you should list the versions available in the repo and install it.

In this example, results are sorted by version, from largest to smallest.

yum list docker-ce --showduplicates | sort -r
docker-ce.x86_64 3:18.09.1-3.el7 docker-ce-stable
docker-ce.x86_64 3:18.09.0-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.1.ce-3.el7 docker-ce-stable
docker-ce.x86_64 18.06.0.ce-3.el7 docker-ce-stable


 
You can sort on stable versions with the grep command


The list above depends on the activated repositories as well as your version of CentOS.

To install a specific package :

sudo yum install docker-ce-version_string docker-ce-cli-version_string containerd.io

Docker is installed, but not started. The docker group is created, but no users are added to it.
 

Start the service

First, start Docker service

Sudo systemctl start docker

Secondly, activate service when starting the machine

Sudo systemctl enable docker


 
Check that DockerCE is correctly installed. For that, run the hello-world image :

sudo docker run hello-word

With this command, you download a test image and runs it in a container. When it works, it displays an informational message.


 
You have done. DockerCE is now installed and running.
 

Please follow and like us:
Microsoft engineer and Virtualization, I am at first computer-savvy. I share my time between this website, my engineering job and an intense sporting activity.