How to Configure HTTPD Server on Docker Container
The first step is to launch a container of your choice here centos is used for launching the container we have to first download the image using the command
docker pull centos
After downloading the image we have to launch the container from the command
docker run -it --name osname centos
Here is the example
For getting the IP address of the container we have to run the ifconfig command but by default, it is not available in the centos docker container for using this command we have to install a software called net-tools. For installing software in centos we use dnf command.
So the command for installing net-tools is
dnf install net-tools
Now we have done with the installation of net-tools software for verification we can run ifconfig command.
After this, we have to install the Apache webserver for this we can execute the command
dnf install httpd
We successfully are done with the installation of the Apache HTTPD Server on the top of the docker container. Now we have to configure the configuration directory for httpd server is /var/www/html where we have to put the static website data.
And the final step is to start the service. Generally in centos, we use systemctl command to start or stop the services but in the docker container, this command is not supported so instead of using systemctl we execute
to start the services.
Here we have done with the configuring the httpd web server on the docker container.