Configuring HTTPD Server on Docker Container & Setting up Python Interpreter and running Python Code on Docker Container.

Configuring HTTPD Server on Docker Container & Setting up Python Interpreter and running Python Code on Docker Container.

7.2: Docker Task

🔅Configuring HTTPD Server on Docker Container

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

7.2.1 To configure HTTPD Server on Docker use following Steps:

Step-1) Run docker ps command which will give info about all the container running but here in this case no container is running.

After that we used the command docker pull centos:7 which is the docker image of centos 7. This will pull the image. 

No alt text provided for this image

Step-2) Now we will run docker run -it –name myos1 centos:7 to run the container.

No alt text provided for this image

Step-3) Next Step is to configure the httpd command using yum install httpd.

No alt text provided for this image
No alt text provided for this image

Step-4) After this we installed net-tools -y which gives the ifconfig command.

No alt text provided for this image
No alt text provided for this image

Step-5) After this we checked the IP of the container using ifconfig command.

No alt text provided for this image

Step-6) Since to configure httpd we have to use systemctl start httpd but that doesn’t work so we used /usr/sbin/httpd to start httpd.

No alt text provided for this image

Step-7) After that we created Task7.html file inside /var/www/html/ and got the the Output.

No alt text provided for this image

Now The Page is accessible and user can enter commands like date, cal etc.

No alt text provided for this image
No alt text provided for this image
No alt text provided for this image
So through these steps we can Configure HTTPD Server on Docker Container.

7.2.2 Setting up Python Interpreter and running Python Code on Docker Container.

Step-1) Now in the same container which is launched we will run a Python Program But for that we will first install python3 by using command yum install python3.

No alt text provided for this image
No alt text provided for this image

Step-2) After installing We created a python file using vi command.

No alt text provided for this image

Step-3) In this python file we write the code.

No alt text provided for this image

Step-4) After this for running use python3 Task7.2.py. It will initially ask for password and then the command to run and will run that command in the container using Python.

No alt text provided for this image
No alt text provided for this image
So Through these steps we can launch the Container, Configure it and Run Python Program. 
No alt text provided for this image



Ayush Ganatra

AWS Solutions Architect Professional | Certified Kubernetes Security Specialist | Certified Kubernetes Administrator | Azure Administrator

4y

To view or add a comment, sign in

More articles by Shrishti Kapoor

Insights from the community

Others also viewed

Explore topics