Configuring HTTPD Server on Docker Container
Apache HTTPD is an HTTP server daemon produced by the Apache Foundation. It is a piece of software that listens for network requests (which are expressed using the Hypertext Transfer Protocol) and responds to them. It is open source and many entities use it to host their websites.
Step 1
I deployed a container with an image CentOS:v7 .Now basically I have an OS on top of which I can host a webpage .The most intresting thing is I deployed the container in just 1 sec .
docker run -it centos:7
STEP 2
I installed HTTPD software by the use of yum as yum command is configured at the time of installation of Docker.
yum install httpd -y
STEP 3
I configured httpd by going to /etc/var/html folder and there I created a small Web page .
vi arth.html
STEP 4
Now the only thing left is to start the daemon of httpd but before that I disabled SELinux .
setenforce 0
But before using setenforce command we have to find out which software provides this command and install the software .
yum whatprovides setenforce
STEP 5
I started the service ie, httpd daemon ,as it is a service, docker container doesnot support service command , systemctl command doesnot works here .
As we know to any command there is a software and to that software there is program file where we can find the internal what happens when we write systemctl command ….and I found out /usr/sbin/httpd is the internal file which is starting the execution .
So by using /usr/sbin/httpd I have started the httpd daemon .
How we can see the status as actual command is systemctl status httpd ???
Answer is simple by using netstat -tlnp we can see all the ports running
netstat -tlnp
To access my web page we need theIP and we know in linux we can find IP by ifconfig again the software is not installed ,So first we need to install the software and use the command .
ifconfig eth0
Now the client can access the web page hosted in container .
ip/arth.html
Likewise we use systemctl stop httpd ,as service command is not supported we can also use killall httpd to stop the daemon ,Again the same thing install the software and you will get the command .
killall httpd
Thankyou for going through my blog
For any query or suggestions dm me .