?? 7.2: Docker Task ??Configuring HTTPD Server on Docker Container ??Setting up Python Interpreter and running Python Code on Docker Container
Nitin Tilwani
Serving Notice Period | SDE@ DevOps engineer at Nykaa | Python | RHCSA | Docker | Kubernetes | Ansible | AWS | Kong || RHCE Certified
So by performing certain steps we can configure HTTPD Server on docker container
STEP1 :- So firstly we will pull our O.S by the command docker pull O.S_name:Version
STEP2 :- In this , we will start docker from base O.S and remember one thing that systemctl command does'nt work in all O.S , but it works on base O.S. So to start docker from base O.S , we will use the command systemctl start docker. And after that you can install, boot and login into your docker O.S by only one command , and that command is docker run -it O.S_name:Version and this is the power of docker , it can do all three steps by only one command
In this docker run -it centos:latest where i is used for interactive and t is used for terminal
And after that for configuring httpd , firstly we have to install it , so after configuring yum , the command used to install httpd is yum install httpd
STEP3 :- So now we have installed httpd , and now we have to start this service. But as i told you earlier, in centos systemctl does'nt work. So to start httpd we have to use /usr/sbin/httpd command
STEP4 :- Now i will configure the base file of httpd server by going in /var/www/html/. So i created a file named nitin.html and i wrote one line in this html file.
STEP5 :- Now we are ready to go. But we don't know the I.P of this O.S and as you can see the ifconfig command does'nt work here. So i asked yum that which software in this provides the ifconfig command by yum whatprovides ifconfig . So we get the answer i.e, net-tools , so i installed net-tools by yum install net-tools
STEP6 :- So after that i used ifconfig command to find my I.P of my centos O.S. and then we are ready to go to see that our sever launched or not. So we will check by the syntax I.P/html_filename on our browser. In my case my I.P is 172.17.0.2. So i searched 172.17.0.2/nitin.html on my browser.
So by these steps you can configure your HTTPD Server on Docker Container.
For Setting up Python Interpreter and running Python Code on Docker Container, we have again some steps and these are very easy to follow.
STEP1 :- Firstly we have to install python and to check that which software is there of python, i used the command yum install python3. So i have python3. so i installed it by yum install python3
STEP2 :- After that i started using python interpreter by the command python3. And after that you can do your python codes in centos. And to go out of this python interpreter use exit() function.
Like i have used print function to prove that python code will work here. Similarly you can do your python codes here.
Thankyou so much for reading my article .Hope It would benefit you in some way.
Thank you.
Software Engineer @ FinSpectra | Platform Developer-1 Certified Salesforce Developer | Salesforce QA Tester
4 年Appreciable Nitin.... Nice and informative Blog