RHEL 7 Install docker

Uninstall old versions if exist

sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \

Install from repository

# Install yum utils which has config manager tool
sudo yum install -y yum-utils

# Add to docker repo
sudo yum-config-manager \
    --add-repo \

# Run install commands
sudo yum install docker-ce docker-ce-cli containerd.io docker-compose-plugin

# Start docker
sudo systemctl start docker

# Verify
sudo docker run hello-world

Manager docker as non root user

# Create the docker group.
sudo groupadd docker

# Add current logged in user to docker group
sudo usermod -aG docker $USER

# If you have a dedicated agent to run docker command, eg. Jenkins, add jenkins user to docker group
sudo usermod -aG docker jenkins

# Active changes to group
newgrp docker 

# Verify docker can run without sudo
docker run hello-world

# Example output
[example@rhel7~]$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Already exists 
Digest: sha256:53f1bbee2f52c39e41682ee1d388285290c5c8a76cc92b42687eecf38e0af3f0
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Run docker when system start (as a servcie)

sudo systemctl enable docker.service
sudo systemctl enable containerd.service