Configuring HTTPD Server and setting up Python Interpreter and running Python Code on Docker Container
Let’s understand few concepts related to this task
Why we use Docker?
Docker is a container management service. The whole idea of Docker is for developers to easily develop applications, ship them into containers which can then be deployed anywhere within few seconds.
- This technology was created by Solomon Hykes,March 2013.
- You can deploy Docker containers anywhere, on any physical and virtual machines and even on the cloud.
Since Docker containers are pretty lightweight, they are very easily scalable.
What is the use of Apache server? How it works?
- The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.
- The Apache HTTP Server (“httpd”) was launched in 1995 and it has been the most popular web server on the Internet since April 1996.
- While there’s a lot of complexity underpinning how a web server functions, the basic job of all web servers is to accept requests from clients (e.g. a visitor’s web browser) and then send the response to that request (e.g. the components of the page that a visitor wants to see).
- Virtual hosting is one such feature that allows a single Apache Web Server to serve a number of different websites.
Let’s move towards our practical part:
Step 1: Start and run docker container
Command - docker run -it --name containername imagename
Step 2: Install httpd on container
Command- yum install httpd -y
Step 3: Install net-tools
Command- yum install net-tools -y
Step 4: Start httpd server
Command- /usr/sbin/httpd or httpd
Step 5: Check in which port httpd is running
Command- netstat -tnlp
Step 6: Create one html file.
Step 7: Check the ip of container
Step 8: Check whether the webpage is configured or not.
URL- https://C_IP/html_file_name
Hence, our httpd server is configured.
Now, Let's set up python interpreter on Docker
Step 1: Install python
Command- yum install python3 -y
Step 2: Type Command python3 for live interpreter.
Step 3: Creating and running python file
Command for running - python3 filename
Hence, Python Interpreter has also been set on docker.
Thanks for reading!!
Former SDE Intern @Raja Software Labs, Pune
3 年Great Explained !!!
Site Reliability Engineer at Crest data systems
3 年Great work