Aniket kashyap
3 min readMar 10, 2021

--

Configuring Httpd server on docker container and setting up a python interpreter on docker to run python code

Docker+Httpd+Python

let’s take a look at the topics covered in this article.

🔅Running a Docker Container with Exposed Port
🔅Configuring HTTPD Server on Docker Container
🔅Setting up Python Interpreter and running
Python Code on Docker Container

🔅Running a Docker Container with Exposed Port

  • We can get a docker container using docker images from Docker hub . To get docker images we can use Pull command:

#docker pull <image name>:version

eg:-

docker pull centos:latest

Launching a container with exposed port

docker run -it --name <container name > -p 9999:80 <image name>:<version>

here i have used centos image

🔅Configuring HTTPD Server on Docker Container

* Run all the command on the container*

For configuring webserver we need to do follow some steps>

(1) Install httpd software

(2) Creating a webpages inside a html folder (/var/www/html/)

creating a html file inside html folder using vi command

#vi ani.html

this is docker

(3) starting the services

(docker doesn’t support systemctl command)

Accessing the WebPage

For accessing the webpage from a web browser. We need the IP of the host machine and the port number on which port 80 of the docker is exposed.

We need to search

# IP_Host:8080

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

Installing python interpreter using yum command

writing a code in python (writing a code in python that will give you current date and time)

created python file named as ani.py

Run a python

Finally,

Completed the following task

  • Running a Docker Container with Exposed Port
  • Configuring HTTPD Server on Docker Container
  • Setting up Python Interpreter and running
    Python Code on Docker Container

--

--