Docker is a containerization technology that allows you to quickly build, test and deploy applications as portable, self-sufficient containers that can virtually run everywhere.

In this tutorial we’ll go through how to install Docker CE on CentOS 7 and explore the basic Docker concepts and commands.

Prerequisites.

Although the Docker package is available in the official CentOS 7 repository it may not always be the latest version. The recommended approach is to install Docker from the Docker’s repositories.

Start by updating your system packages and install the required dependencies:

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

Next, run the following command which will add the Docker stable repository to your system:

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

Install Docker CE

Now that the Docker repository is enabled, install the latest version of Docker CE (Community Edition) using yum by typing:

sudo yum install docker-ce

Once the Docker package is installed, start the Docker daemon and enable it to automatically start at boot time:

sudo systemctl start docker
sudo systemctl enable docker

To verify that the Docker service is running type:

sudo systemctl status docker

The output will be something similar as below.

[[email protected] ~]$ sudo systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2019-01-24 14:46:55 CET; 7h ago
     Docs: https://docs.docker.com
 Main PID: 7399 (dockerd)
    Tasks: 25
   Memory: 251.6M
   CGroup: /system.slice/docker.service
           ├─ 7399 /usr/bin/dockerd -H fd://

Final

Docker commands needs to be run by sudo. However if you add your user to docker group, then you can run docker without having to do sudo. So Lets get that done now as follows:

sudo usermod -aG docker $USER

At this point you now have docker fully installed and all that is left is to start using it.