Configuring HTTPD Server on Docker Container

In this blog, I am going to configure the HTTPD web server on the Docker container. For this practical, I am going to use Redhat 8 Operating System and Apache HTTPD software for the webserver.

We directly cannot install the docker-ce software on Redhat 8. To install the docker-ce software on Redhat 8 first we have to create the repo for the software.

Now let’s list the repolist, It will show how many software have.

In this step, we will install the docker-ce software. To install we will use yum command.

yum install docker-ce — nobest -y

Now we can check the version of the docker software.

docker — version

In this step, I will start the docker status with the systemctl command. Also we will check the docker status.

systemctl start docker

systemctl start docker

Now enable the docker service so that the docker service will be running after the system restarts. To enable the service we have to use the enable option.

systemctl enable docker

Here we can see that the docker service is enabled.

In this step, I am going to pull the centos image from the docker repository. Let me first show how many docker images are available.

To list the docker images available we have to use the image command.

docker images

We can see that there is no docker image available, now let’s download the centos image.

docker pull centos

Now we can check that the centos image is downloaded or not.

We can see that the centos image with the latest tag is downloaded.

In this step, I will launch a docker container with centos image.

docker run -it — name webos centos

We can check the container is running or not, to check we can use docker ps command.

docker ps

By default, the centos image that we have don’t contain ifconfig command. So we can install the software which provides ifconfig command.

net-tools is the software that provides ifconfig command. So, we can install this software with yum command.

yum install net-tools -y

Now we can check the IP of the container.

Now we can check the IP of the container.

To install the httpd sotware we can use yum command.

yum install httpd -y

By default httpd software reads the HTML file from /var/www/html directory. So we have to put the HTML file inside the /var/www/html directory.

Here i have created aditya.html file inside /var/www/html directory.

Now at last we have to start the service of httpd service. By default, systemctl command is not present. So we can use /usr/sbin/httpd file because systemctl internally loads this file to start the service.

Now we can access the web page from the browser.

We can see that we can easily access the web page which is there on the docker container.

Thank You !!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store