Configuring WebServer And Python Interpreter On Top Of Docker.

Tribhuban Mishra
4 min readMar 18, 2021

Hello guys!!

This Article is on how to Configure HTTPD Server on docker Container & to setup python interpreter and running python code on docker container.

Before further proceeding to configuration,lets see the basic concept of docker :-

What is Docker?

Docker is a tool designed to make it easier to create, deploy, and run applications by using containers. Containers allow a developer to package up an application with all of the parts it needs, such as libraries and other dependencies, and deploy it as one package.Docker is a container management service. The keywords of Docker are develop, ship and run anywhere. With docker , you can manage your infrastructure in the same ways you manage your applications.

What is Apache HTTPD Server?

Apache HTTPD is an HTTP server daemon produced by the Apache Foundation .HTTP Daemon is a software program that runs in the background of a web server and waits for the incoming server requests. The daemon answers the request automatically and serves the hypertext and multimedia documents over the Internet using HTTP.

Let’s Start with the Configuration Of HTTPD Server on Docker Container.

Platform Used : RHEL8

Step-1 : First We have to Configure the repository file to install the docker community edition.

vi /etc/yum.repos.d/config.repo

Step-2 :- Install the Docker Community Edition.

yum install docker-ce — nobest -y

Step-3 :- Start the Docker Service and Check the Status.

systemctl start docker

systemctl status docker

Step-4 :- To install the OS on top of container OS image needed and from OS image we install operating system and these operating system is technically known as Container& we will download or pull the OS image from docker repository via following command and check the downloaded image via cmd “docker images”:-

docker pull {OS_name}:{OS_version}

docker pull centos:latest

Step-5 :-Launch and run the container using centos image.

docker run -it — name Webserver centos:latest

In above Command the option -it creates the interactive connection and Terminal inside docker container.

Step-6 :-Install the HTTPD Software using yum Command on top of the newly launched Container.But, any error occur then run the following command and then run “yum install httpd -y” because If we want to download anything from the internet on the top of the docker container then we have to get the permission from the red hat firewall.

firewall-cmd — zone=public — add-masquerade — permanent

firewall-cmd — zone=public — add-port=80/tcp

firewall-cmd — zone=public — add-port=443/tcp

firewall-cmd — reload

systemctl restart docker

yum install httpd -y

Step-8 :-Create a docker.html file in /var/www/html/ directory where /var/www/html/ is default document directory of apache web server.

vi /var/www/html/docker.html

This is the test page(docker.html) you put the entire website code in this document directory.

Step-9 :- Start the Webserver Service.Since the command “systemctl start docker” is not working, because Docker doesn’t support systemctl, so to start the service we have to directly give the path of the software.

/usr/sbin/httpd

Step-10 : Check the ip of docker Container .To do this we use “ifconfig” command but it shows command not found.To solve this we know every command comes from a software and by using command “yum whatprovides ifconfig” we can find out the software name which provide ifconfig command.

ip of docker container

Now ,Open the browser and check the webpage by using URL :

172.17.0.2/docker.html

Hence, HTTPD server has been configured Successfully and working fine.

Now, Setup the Python Interpreter to Python Code on Docker Container

Step-1 : Install the python3 software.

yum install python3

Step-2 : Start the python Interpreter & Write some python code on interpreter.

python3

Hence , I have Successfully configured HTTPD server & Python interpreter on top of docker container.

Thanks for reading….

--

--