Have you ever experience that in just one second your entire operating system is ready to use?
Yes, you heard it right Docker gives you the facilities to use a new operating system in one second. Docker is a program that uses your base OS resources and only consumes 20MB – 50MB RAM to launch a new OS. In this article, we’ll show you how to install the docker inside Redhat Linux, how to start docker services, how to pull images from the docker hub, and finally how to launch a new container.
In this article, we will discuss the “Hello World” for Docker.
These are the steps to achieve the goal.
- Basic terminologies like docker container, docker image, dockerfile.
- Docker installation on Redhat/centos.
- How to start docker services.
- How to pull Hello-world image from docker hub.
- Hello-world.
Let’s start with the key terminologies that you must know.
Basic terminologies
1. Docker container
Docker container is a separate virtualized environment that is used to test, run and deploy the applications. basically, the docker container is used in application development. If any problem or bug comes then it does not affect our Base OS and it also gives extra security. we can easily create new containers with help of docker images. we can also destroy these containers easily.
2. Docker image
Docker images are like snapshots in VMs. Docker images are executable files that are used to create separate containers in Docker. We create lots of containers using single docker images. Docker hub is a centralized location that is maintaining docker images. You can find Docker images of Hello-world, Ubuntu, Centos, etc. We also create our own customize image using the docker commit command and using Dockerfile and publish or push them on the docker hub.
3. Dockerfile
Dockerfile is a scripted text file that is used to customize our container and install desire software inside the docker container. we just write the commands in Dockerfile and using this file we build our own image. Later we use this image in our container as well as we push the image on Dockerhub.
Docker installation in centos/Redhat
As we discuss earlier Dockerhub has the Hello-world official image so let’s see how to install docker and create containers. First of all, we configure a repo that has docker-ce software using the following command:
sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
After the repository add you can check the repo in (/etc/yum.repos.d/) location. Now you can easily download the docker using the yum command:
sudo yum install docker
Just in your case if the above command gives some error then try the below command
sudo yum install docker-ce --nobest
Start and enable the docker services:
Use the below commands to enable and start docker respectively:
sudo systemctl enable docker sudo systemctl start docker
Pull the hello-world image
Now pull the hello-world image from docker use the below command:
docker pull hello-world
Execute Hello world:
Use the below command to run the hello-world file in docker:
docker run hello-world
After running the above command you see some message that prints hello-world which means your docker is successfully installed in your Centos or Redhat Linux.
Hope you understand my explanation.Thanks for reading.