Configuring HTTPD Server on Docker Container
STEP I : Install the docker software
Use this command :
yum install docker-ce --nobest
STEP II : Start the docker service
systemctl start docker
And now check the status of docker whether it is active or not by commnd
systemctl status docker
STEP III : Download centos image
Use this command to list the installed docker images
docker images
In my case , I have only ubuntu image. So I can download the centos image by using the command
docker pull centos
[Note : Docker hub does not have Redhat image. So we can use the centos which is similar to the Redhat]
If we didn’t mention the version while downloading the image, then by default the latest version of os will get downloaded
After downloading, check with docker images command
STEP IV : Launch one container of Centos
docker run -it --name <container_name> <image_name:version>
STEP V : Install ifconfig command
Docker container do not have ifconfig command by default. We have to install it.
Use this command to install :
yum install whatprovides ifconfig
For ifconfig command we need to install net-tools software and we can install it by using yum or dnf. Command is -
yum install net-tools
Now use ifconfig command
Here my main network card is eth0 . So my ip of centos container is 172.17.0.2
STEP VI : Install httpd
For installing Apache webserver , use command :-
yum install httpd
After installation check by the rpm command whether it is installed or not
rpm -q httpd
STEP VII : Write html page
Write html pages inside /var/www/html directory
cd /var/www/html
Use vi command to write a html file
vi page.html
After writing the page , then go to the browser and write <ip>/<file_name.html>
eg. 172.17.0.2/page.html