# Switch into Sudo mode
sudo su

# Disable the built-in firewall as it will block DNS resolution inside Docker
sudo systemctl disable firewalld

# Add Docker Repo
sudo dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo

# Manually install the dependency
# Check this URL for the latest version of containerd: https://download.docker.com/linux/centos/7/x86_64/stable/Packages/
containerdSource=https://download.docker.com/linux/centos/7/x86_64/stable/Packages/containerd.io-1.2.13-3.2.el7.x86_64.rpm
sudo dnf install $containerdSource -y
sudo dnf install docker-ce docker-ce-cli -y

# Start Docker at bootup
systemctl start docker
sudo systemctl enable --now docker
systemctl is-enabled docker

# Adding a user into the docker group to allow execution of docker commands
user=kim
# adduser will create user, group with same name, and create home directory in one command
sudo adduser $user -g docker
sudo passwd $user
sudo usermod -aG docker $user

# Optional add user to wheel group to allow 'sudo su' privilege elevation
sudo gpasswd -a $user wheel

# Validate
id  $user

# Alternative validation command
[root@server01 ~]# sudo lid -g docker
 elephant(uid=1003)

# Sample output
root@server01 ~]# id $user
uid=1003(elephant) gid=986(docker) groups=986(docker)

Some possible errors and explanations:

# Normal commands to install Docker with the --nobest switch to ensure that compatible versions are selected
dnf install docker-ce --nobest -y

# Unfortunately Cento 8 currently blocks Containerd.io
[root@server01 ~]# dnf install docker-ce --nobest -y
Last metadata expiration check: 0:01:00 ago on Fri 21 Feb 2020 02:03:18 PM PST.
Dependencies resolved.
Problem: package docker-ce-3:19.03.6-3.el7.x86_64 requires containerd.io >= 1.2.2-3, but none of the providers can be installed
- cannot install the best candidate for the job
- package containerd.io-1.2.10-3.2.el7.x86_64 is excluded
- package containerd.io-1.2.2-3.3.el7.x86_64 is excluded
- package containerd.io-1.2.2-3.el7.x86_64 is excluded
- package containerd.io-1.2.4-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.5-3.1.el7.x86_64 is excluded
- package containerd.io-1.2.6-3.3.el7.x86_64 is excluded
# Output of a successful Docker-CE install
[root@server01 ~]# sudo dnf install docker-ce docker-ce-cli -y
Last metadata expiration check: 0:13:19 ago on Fri 21 Feb 2020 02:03:18 PM PST.
Package docker-ce-3:18.09.1-3.el7.x86_64 is already installed.
Package docker-ce-cli-1:19.03.6-3.el7.x86_64 is already installed.
Dependencies resolved.
=================================================================================
Package Architecture Version Repository Size
=================================================================================
Upgrading:
docker-ce x86_64 3:19.03.6-3.el7 docker-ce-stable 24 M

Transaction Summary
=================================================================================
Upgrade 1 Package

Total download size: 24 M
Downloading Packages:
docker-ce-19.03.6-3.el7.x86_64.rpm 19 MB/s | 24 MB 00:01
---------------------------------------------------------------------------------
Total 19 MB/s | 24 MB 00:01
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Preparing : 1/1
Running scriptlet: docker-ce-3:19.03.6-3.el7.x86_64 1/1
Upgrading : docker-ce-3:19.03.6-3.el7.x86_64 1/2
Running scriptlet: docker-ce-3:19.03.6-3.el7.x86_64 1/2
Running scriptlet: docker-ce-3:18.09.1-3.el7.x86_64 2/2
/usr/bin/dockerd has not been configured as an alternative for dockerd

Cleanup : docker-ce-3:18.09.1-3.el7.x86_64 2/2
Running scriptlet: docker-ce-3:18.09.1-3.el7.x86_64 2/2
Verifying : docker-ce-3:19.03.6-3.el7.x86_64 1/2
Verifying : docker-ce-3:18.09.1-3.el7.x86_64 2/2

Upgraded:
docker-ce-3:19.03.6-3.el7.x86_64

Complete!