Skip to content
Related Articles

Related Articles

Configuring HTTPD server on Docker Container and setting up Python Interpreter

View Discussion
Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 26 Dec, 2020
View Discussion
Improve Article
Save Article

In this article, we are going to discuss a step-by-step guide on how to configure the apache web server on top of a docker container, and setting up a Python interpreter. Basically, we are installing the product of apache which is HTTPD on the docker container.

What is Docker?

In simple words, if I have to define docker, is a tool that can launch an operating system (install any operating system) in seconds. If you have noticed when we install any operating system it takes around one hour to launch, but docker giving u the facility the convenience to launch any os within seconds, and httpd is just a product of apache web service which we are using for creating webpages.


  • You need Virtual Box installed in your os
  • And launch one Linux operating system(RHEL-8, Linux (64-bit)) in the VM to perform this practice.
  • Yum, should be configured in your VM.

How to configure the HTTPD server on the Docker Container?

  • First, we need to install docker in your VM so for that first use the following command to go inside the repo folder.
cd /etc/yum.repos.d/
  • Create a repo by giving any name by the command vim d.repo and give this URL. You have to add this URL in the docker repo as you can see below.

toDocker repo

  • After this, you can install docker by using the below command:
yum install docker-ce  --nobest
  • To check docker installed or not run the command:
rpm -q docker-ce
  • To start the service and to check the status of docker you can run the following commands:

Start docker service:

systemctl start docker

Check docker status:

systemctl status docker

Now to configure the webserver on the top of the docker container these are the steps:

  • Launch a docker container with an image
  • Inside which we install the webserver program(Apache server)
  • Starting the server
  • Inside the docker, we install python interpreter(python3)

Before launching the container in docker make sure to stop firewall and then restart docker.

Stop Firewalld

  • Now to launch one os /container on the top of docker we need an image you can use the image, we are using the ubuntu: 20.10 image, you can get it from, to download the image we have to use just one command
docker pull ubuntu:20.10
  • Now u can launch the container by this image: docker run -i -t -name taskd ubuntu:20.10, the command to come out of the container is exit, you can check how many oses stopped and running also by using the command:
docker ps -a

Lunch docker container

  • To go inside the exited docker container we have one command docker attach taskd here taskd is the name which you give while launching the container, you can give any name as per you want. Before you go inside the container you have to first start the stopped container by below the command:
docker start taskd

Going inside the docker container 

  • Now we can start the installation in the docker container first we use the command apt-get update, this command is used to download package information from all configured sources. So when you run the update command, it downloads the package information from the Internet. It is useful to get information on an updated version of packages or their dependencies.

apt-get update

  • Now we can install an apache web server on the top of docker container by the command, apt-get install apache2, in ubuntu we have this command apt-get to download and install any software.

Installing webserver(Apache) on the container

  • Now we have to install systemctl by using the command:
apt-get install systemctl

Installing systemctl command in container

  • The command: apt-get install net-tools will help you to run the ifconfig commands.

Installing net-tools 

Running ifconfig to see IP

  • Use the below command to install vim:
apt-get install vim

Install vim to create a file

  • Now after this installation part gets done we have to configure the webserver we need to go to cd /var/www/html/ and there we have to create a website using vim hello.html.

Creating a website

  • Now start the service by command, systemctl start appache2 and check the status, make sure it’s active.

Starting the web service

  • Now get the IP by ifconfig command and use the URL IP/hello.html in a browser.

See the website in the firefox

Setting up the Python Interpreter in the Docker Container 

  • First, we need to install python3 by the command:

  •  To see python3 is installed or not
python3 -V

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!