How to install Docker on CentOS

Let's walk you through how to install and configure Docker on CentOS 7 and CentOS 8. We shall be installing Docker Community Edition, which is a FOSS (Free and Open-Source Software).

Docker is an open-source containerization application that is designed to create, deploy, and run application processes in a container, like a virtual machine, but using the same kernel as the host operating system. Docker containers allow a developer to package all parts of the application, libraries, and its dependencies into one package and deploy it.

Docker has an image repository with a preconfigured Docker image for almost all famous open-source applications and operating systems. Docker has two editions, the Docker CE (Community Edition), which is a free and open-source version, and the other is Docker EE (Enterprise Edition), which comes with support, certification, etc. and is paid.

Installing Docker on CentOS

In this tutorial, we will show you step by step guide to install Docker CE on CentOS 7 and CentOS 8.


  • A maintained version of CentOS (Docker does not support outdated versions)
  • A user account with ‘sudo’ privileges.

Step 1: Install Yum Utils

First of all, we need to install ‘yum utils’ package for using yum-config-manager to enable CentOS extras. Use the following command:

sudo yum install yum-utils -y


installing yum utils package
installing yum-utils package

As you can see from the above screenshot, yum-utils are installed.

Step 2: Enable CentOS extras

To enable CentOS extras, use the yum-config-manager command:

sudo yum-config-manager --enable extras

To confirm whether extras are enabled use following command:

sudo yum repolist


centos extra repo enabled
centos extra repo enabled

Step 3: Install Docker Dependencies

Now we need to install device-mapper-persistent-data, and lvm2 package as Docker depends on these two packages. Use the below command:

sudo yum install device-mapper-persistent-data lvm2


installing data-mapper and lvm2 package

From the above screenshot, you can see these packages were already installed.

Step 4: Add Docker Official Repo

We shall now add Docker official repository to CentOS using yum-config-manager:

sudo yum-config-manager --add-repo


adding docker repo into centos
adding docker repo into centos

Docker repository should be added by now.

Step 5: Only for CentOS 8 and above

If you are installing Docker on CentOS 7 or lower, you can skip this step, but for CentOS 8, we need to correct Docker compatibility with the package. We have to manually download the package and then have to install it using yum.

First, we navigate to /tmp directory:

$ cd /tmp

We shall download the latest package from the official CentOS 7 package repository of Docker CE with the following command:



download package
download package

Remember to replace the link in the above command with the latest link from the official webpage. Once the latest package is downloaded, we will install it from /tmp using the following command:

sudo yum install ./


There you go, you have the newest version of installed.

Step 6: Install Docker!

With everything set, we can finally install Docker using below command:

sudo yum install docker-ce


installing docker-ce packages confirmation prompt
installing docker-ce packages confirmation prompt

To confirm the installation, press Y and then press <Enter>. Yum package manager will start downloading packages.

downloading docker-ce packages during installation
downloading docker-ce packages during installation

It may take a while to complete, and at some point, you may be asked to accept GPG Key of Docker.

accepting docker gpg key
accepting docker gpg key

Press ‘y’ and than <Enter> to continue and after a short time docker will be installed.

docker installation completed
docker installation completed

You can see in the above screenshot that our docker installation on CentOS is completed successfully.

Step 6: Now, we will verify the Docker installation:

docker -v


docker installation confirmation

Docker is installed in our test system; you can notice the Docker version in the above screenshot.

Configuring Docker on CentOS

First of all, we will see the Docker service status using:

sudo systemctl status docker


checking docker service status
checking docker service status

You might have noticed, by default, Docker is disabled after installation. To enable it, use the below command:

sudo systemctl start docker

To start docker service on system boot:

sudo systemctl enable docker

After that, we will recheck the status using the command:

sudo systemctl status docker


start docker service
start docker service

You can see the Docker service is active and running now. It will auto-start on system boot as well.

If you were able to come this far, you should have successfully installed Docker on your CentOS 7 or CentOS 8 machine. You can now explore Docker further.

Tip! If you’re going to use Docker on a production machine, then we will recommend you not to upgrade to CentOS 8. Try to keep using CentOS 7 until Docker has official support for CentOS 8.

Habib Ahmed
He is a professional writer with more than seven years of experience in the field. He also enjoys technical writing/ manuals, white papers, and scientific presentations.


Please enter your comment!
Please enter your name here





Buyers who wish to go for a machine that is based on Linux often show interest in Chromebooks due to the form factor and extended battery life capabilities. Although ChromeOS power these machines, users can still miss out on a more genuine Linux experience. For those who happen to agree, the new Lemur Pro by System76 might get some heads turning.
Linux is growing faster than ever. As per the latest report, there is a drop in the Windows 10 market share for the first time, and Linux's market share has improved to 2.87% this month. Most of the features in the list were rolled out in the Pop OS 20.04. Let's a detailed look into the new features, how to upgrade, and a ride through video.

The 10 Best Programming Languages for Hacking

One of the significant entities we have in Cyber Security is Ethical Hacking (ETH). It is the process of detecting and finding flaws or vulnerabilities in a system that a hacker would exploit.

3 Best Ways to Uninstall Software on Ubuntu

Uninstallation of programs can be done by graphical way using the Ubuntu Software Center, and the Synaptic Package manager. Command-line way of doing it is also possible using apt-get and aptitude commands. We shall discuss each one of them in detail.

[Guide] apt vs apt-get commands, and which one to use?

Most Linux users, both veterans, and newbies, often get confused about what the difference between the Linux commands apt, and apt-get are and when they should use one or the other.

6 Best CPU Stress Test and Performance Benchmark Linux Tools

Do you want to push your Linux system to its maximum limits? Or are you interested in evaluating your Linux PC in terms of performance? Either way, benchmark apps and stress test tools can give you a quantitative understanding of the performance of your Linux PC.