Steps to Install DOCKER in RHEL8(Red Hat Enterprise Linux)
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
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
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.
5. Update the yum repository using command: 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.
8. Reload the firewall.
9. Restart and Enable Docker
10. Pull Docker image using docker pull centos:latest
(you can pull any version, eg. centos:8).
11. Check if image is pulled or no using command: docker images
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
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
.
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
.
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>
.
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.