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.
Step-2) Now we will run docker run -it –name myos1 centos:7 to run the container.
Step-3) Next Step is to configure the httpd command using yum install httpd.
Step-4) After this we installed net-tools -y which gives the ifconfig command.
Step-5) After this we checked the IP of the container using ifconfig command.
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.
Step-7) After that we created Task7.html file inside /var/www/html/ and got the the Output.
Now The Page is accessible and user can enter commands like date, cal etc.
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.
Step-2) After installing We created a python file using vi command.
Step-3) In this python file we write the code.
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.
So Through these steps we can launch the Container, Configure it and Run Python Program.
AWS Solutions Architect Professional | Certified Kubernetes Security Specialist | Certified Kubernetes Administrator | Azure Administrator
4y✌