Configure webserver+python Inside docker container

 


Docker :

In 2013, Docker introduced what would become the industry standard for containers. Containers are a standardized unit of software that allows developers to isolate their app from its environment, solving the “it works on my machine” headache. For millions of developers today, Docker is the de facto standard to build and share containerized apps - from desktop, to the cloud. We are building on our unique connected experience from code to cloud for developers and developer teams

Apache web server

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. It has celebrated its 25th birthday as a project in February 2020.

so Now a days everybody use these two tools but if we setup our httpd sever on main o.s then it take the resources from the o.s . If any bug come in our program then hacker access our data easily . So it is good practice to launch an o.s for only one program but this take lots of money so instead of main o.s we use docker for configure the server .

Lets start with the task 

                     Task description :

🌀 7.2: Docker Task

🔅Configuring HTTPD Server on Docker Container

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


STEP 1 : In this we need to launch one docker in our redhat o.s . we give the name "arth-task7.2" and port number 6036


after launching the o.s we install httpd using command #yum install httpd 


STEP-2 : - After succesfully setup the httpd we create a html file and give the name index.html


This is the content of html . we write this for testing 


But we have 1 problem in this . we don't have access to directly start the httpd service in docker it shows some D-BUS kind of error .

STEP- 3 : - we install the python3 inside the docker using yum install python3


STEP-4 :- After installing the python we start the python interpreter and write some code.



            Now again come to our httpd configuration part 

So setup the httpd sever we need to do something with our this .


STEP-5 : - We create an docker image from this O.S. so we commit the o.s into new image

command : docker commit arth-task7.2 webserver:v1

                   

 Now the new image is created and we give the name "webserver" with version v1

STEP-6 :- Now launch the new O.S with port 6036 and dedicated only for webserver 

docker run -p 6036:80 webserver:v1 /usr/sbin/httpd -D FOREGROUND


After doing this you clearly see that our website is launching with Docker ip(that we get from the docker session under the command
 #ifconfig in base OS)



 

THANK YOU FOR READING HOPE YOU FIND THIS INTRESTING

If any doubt related to this you can ask me on linkedin (https://www.linkedin.com/in/sahid-khan-92456918a)

Comments