How to Install Docker on Centos 7

Docker is an OS-level virtualization solution built around Linux kernel features like namespaces and cgroups to provide isolation for software packages called containers. In this article, we’ll be walking through the installation of Docker on CentOS 7.


  •     You need access to a Linux server, with sudo or root privileges.


We will be using yum-config-manager to setup Docker’s repository. The yum-config-manager command is in the yum-utils package. We will start off by installing yum-utils.

$ sudo yum install -y yum-utils

We can now add the Docker repository using yum-config-manager.

$ sudo yum-config-manager --add-repo

Install the Docker-CE package.

$ sudo yum install docker-ce docker-ce-cli


First, we must configure a user if we want to run docker without root privileges.  I have created a user called test_user.  The following command will add the user “test_user” to the docker group.

$ sudo usermod -a -G docker test_user

In order for the changes to be recognized, you must log out and back into your existing shell session or use the following command.

$ su test_user


We can use systemctl to ensure the docker service is started and set to enabled at boot.

$ sudo systemctl status docker.service

It is neither started or enabled at boot.

Start Docker.

$ sudo systemctl start docker

Enable Docker at boot.

$ sudo systemctl enable

Check which docker version is installed.

$ docker --version

Run a test container. If this completes successfully, then you have successfully configured the docker service.

$ docker run hello-world


In this article, you learned how to install, configure, and verify the docker service on Centos 7.  Check out the official Docker documentation for more information.