Steps to Install DOCKER in RHEL8(Red Hat Enterprise Linux)

Yash Lahoti
4 min readMay 27, 2021

Dear Readers,

I would suggest you to first install RHEL-8 on your Virtual Machine/System and then go through this article as we are installing docker on RHEL-8.

1. Open RHEL-8 terminal.

2. Type the following command: vim /etc/yum.repos.d/docker.repo

Fig 1. RHEL-8 Terminal

3. Press ‘i’ to insert and then type the following command:

[docker]
name=Softwares from docker
baseurl=https://download.docker.com/linux/centos/7/x86_64/stable
gpgcheck=0
Fig 2. Press i to insert the text inside the space

4. Press Escape button and type :wq to save and exit, :w to save and continue editing and :q to simply quit without saving and press ENTER.

Fig 3. Type :wq and press ENTER

5. Update the yum repository using command: yum repolist.

Fig 4. yum repolist

6. Download the community version docker, docker-ce using the command: yum install docker -ce

7. To avoid any sort of difficulty inside the Docker container, we need to add firewall rules to activate Masquerade, Port 80 and Port 443.

Fig 5. firewall-cmd –zone=public –add-masquerade –permanent
Fig 6. firewall-cmd –zone=public –add-port=80/tcp –permanent
Fig 7. firewall-cmd –zone=public –add-port=80/tcp –permanent

8. Reload the firewall.

Fig 8. Reload firewall

9. Restart and Enable Docker

Fig 9. Restart and Enable Docker

10. Pull Docker image using docker pull centos:latest (you can pull any version, eg. centos:8).

Fig 10. Pull Docker Image

11. Check if image is pulled or no using command: docker images

Fig 11. Image Pull Check

12. Now, launch a container using command:
(i) To launch a container with a name you want-
docker run -it –name <container_name> centos:latest
(ii) To launch a container with a random name-
docker run -it centos:latest

Fig 12. Start a new container

13. You will notice that [root@localhost ~] has now changed to [root@containerid /], which means that now you are inside the container.

14. To install any software inside, use command:
yum install vim -y.

Fig 13. Steps to Install any software inside container

15. To come out of the container, type exit.

16. To check if containers that are in running state, we can use the command :
docker ps and to check containers that are available, we can use the command: docker ps -a.

Fig 14. Check running and exit state containers

17. To start running an exit-status container, use command:
docker start <container_name/container_id> and to work/access the container, use command: docker attach <container_name/container_id>.

Fig 15. docker start and docker attach

18. To access RHEL-8 terminal when you are inside the container, you can use Left Control Button+p+q in the container terminal.

And now we have successfully installed docker inside RHEL-8 terminal; and have also seen how we can Enter and Exit the container terminal.

--

--