There are actually three ways in total with the help of which we can install docker on CentOS 7, and in this post we are going to discuss the same via going through each method, so that at the end of the day we must have all the available options.
Note: But before going next, make sure you have configured your CentOS 7 machine by following the following post -> Things to do after installing CentOS 7 Server – post installation
Method 1: Install docker on CentOS 7 using “official docker repository”.
In order to properly install docker, we need to install some required packages, and those are:
Step 1: Install required packages.
yum-utils = It is simply a collection of tools for yum to manage things.
device-mapper-persistent-data = This helps in providing a framework, which in turn helps the Linux kernel to map physical block device to logical volumes.
lvm2 = provides logical volume management for Linux kernel.
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
Step 2: Add docker’s official repository to yum’s repository list.
sudo yum-config-manager –add-repo https://download.docker.com/linux/centos/docker-ce.repo
Step 3: Now with the help of yum, install it.
sudo yum -y install docker-ce
Step 4: Start the docker service and enable it so that next time the system reboots it starts automatically.
sudo systemctl start docker && sudo systemctl enable docker
Method 2: Install docker on CentOS 7 using “using the script”.
curl -fsSL https://get.docker.com -o get-docker.sh
Now, after installing docker, you need to “start docker“, “enable docker service” and check the “docker version“, moreover to verify you can check for “docker service running status” by running the following commands as shown in the picture below.
Method 3: Install docker on CentOS 7 using “using extra repository”.
This is the simplest method, as it does not require any extra efforts, simply execute the following commands as shown in the picture below.