Configuring HTTPD Server on Docker Container

Aditya Raj
4 min readNov 13, 2020

--

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.

Step 1: Install Docker-CE software on Redhat 8

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.

Step 2: Install the docker-ce software on Redhat 8

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

Step 3: Start the status of Docker

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.

Step 4: Pull any Docker Image from the docker repository

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.

Step 5: Launch the docker container with centos image

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.

Step 6: Install apache httpd software

To install the httpd sotware we can use yum command.

yum install httpd -y

Step 7: Put the web page inside /var/www/html directory

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.

Step 8: Start the httpd service

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 !!

--

--

Aditya Raj

I'm passionate learner diving into the concepts of computing 💻