This is a bit roundabout and requires some fiddling with the repo files as docker the company seems to have moved some of the rhel files around.
The first step is to add the docker repo.
yum install -y yum-utils yum-config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo
We need to do two things, the first is to add a repository to get some extra utilities that docker requires. This will be a centos repo.
The second thing is we need to change the rhel urls to centos urls. Docker has moved the rhel files but not the centos files.
Add the following to /etc/yum.repos.d/docker-ce.repo.
[centos-extras] name=Centos extras - $basearch baseurl=http://mirror.centos.org/centos/7/extras/x86_64 enabled=1 gpgcheck=1 gpgkey=http://centos.org/keys/RPM-GPG-KEY-CentOS-7
This will let us download the extra utilities needed to install docker.
Next do a search and replace of rhel in the file for centos.
Should be changed to:
This will be across the board for all the urls in the file.
Now we can install docker.
yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Once installed, we can start and enable docker.
systemctl start docker systemctl enable docker
We can test docker by pulling a hello world image.
docker run hello-world
With that we should now have docker installed and ready to go!