Configuring Apache HTTPD server on Docker
✪Docker is an open platform for developing, shipping, and running applications. Docker enables you to separate your applications from your infrastructure so you can deliver software quickly.
✪Docker provides completely isolated & secure environment per containers(Operating System).It is real quick that it launches complete OS with full boot, and launch other applications in it in less than a second.
So we will configure OS with HTTPD server running in one of the container on top of Docker.
✔Install Docker
✔Install RHEL8
🟌NOTE: MAKE SURE YUM IS CONFIGURED🟌
✌Now we are good to go!
➤So let us launch a container(Centos OS) inside Docker with the name myos & expose it to the public world so it can be accessed by the clients .
docker run -it -p 81:80 --name myos centos:latest
Open a new tab & use this command to check containers running on Docker:
docker ps
➤We have launched our container successfully using the centos image(or iso-just like we install windows or Linux )named myos & exposed it to the port-81.
➣Observe that as soon as we launch/run our container then then localhost changes to the container id.
➤Now we will install Apache HTTP Server inside our container using YUM.
yum install httpd -y
➤As we want to create our html webpage so we necessarily have to create it inside the /var/www/html directory.
cd /var/www/html
vi profile.html
-name of html page.html
- Press i to insert/write the html code in the editor
Example:
☝️ Press :wq in the editor to save the code.
❓To know the ip in the redhat VM : Run ⮕ ifconfig enp0s3.
➤Now go to any browser and use the ip of the VM in which the docker is running:
Format: hostip:portno/htmlpage name
“Now our HTTPD server is running safely on Docker in secure OS, which can be launched anytime we want within a second”
Hope it was helpful, in case of any doubts reach me out:
Email- sandeshjain174@gmail.com
Thank You 😃 ✋