Apache (HTTPD) Web Server Configuration on Docker Container

Hello there, After Reading this full article, You will be able to configure Web-Server on The top of Docker Container.


  • Docker Must be installed, basic Knowledge of how to launch docker container.
  • So Without any further delay, Let’s get started.
  • Here For performing this task I am using REDHAT 8 as the BaseOS.

Step-1: Start The Docker Service in Redhat 8 Operating System.

Step-2: Pull the Docker Image

  • To launch any isolated container we must have an image downloaded on our local system. Here I am pulling CentOS image from docker hub.

Step-3: Launch the container on the top of Redhat 8

  • Here the Command to launch a container with name as webserver can be seen below.

Step-4: Install Apache Httpd software.

  • Here Before installing make sure to stop firewall in Base OS. In Redhat 8 to stop firewall we use “systemctl stop firewalld” command.
  • To install httpd software, run “yum install httpd -y” command inside the docker container.

Step-5: Start The HTTPD service

  • Normally in Redhat 8, to start this service we always use “systemctl start httpd” command but in docker we don’t have that command hence instead we use the command which is mentioned in the image below.

Step-6: Navigate to /var/www/html

  • In this directory we have to put the webpages created by us. Here I have created one webpage called index.html.
  • The HTML code of this file looks like this. In this way you can also but various webpages in this folder.

Step-7: Install The net-tools software

  • This software provides the command to see IP of container.

Step-8: Access the webpage in Browser

  • Now we can access the webpage in browser as below, syntax is IP/filename.html

Setting up Python Interpreter and running Python Code on Docker Container —

  • We saw how to configure webserver on the top of docker container. Now we can also Setup Python interpreter and hence run python code on the top of docker container.
  • We can install python3 on docker container using yum command.
  • Finally ! Python 3 is installed in Docker Container, Now you can create a python file and simply run it.
  • The Final Outcome looks like below.
  • Thank You So Much, hope you learned something new today.



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
Tilwani Hardik

Tilwani Hardik