Configuring webserver and python inside container.

Configuring webserver and python inside container.

??Configuring Httpd Server on Docker Container

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

We have to first launch container for launching container I used CentOS image. so pull the image from docker hub, by command given

docker pull centos:8

Now we can run container using the image.

No alt text provided for this image

After container launch install httpd package on docker.

yum install httpd
 or 
dnf install httpd
No alt text provided for this image
No alt text provided for this image

Press y and it will install for you and after that in document root of webserver put your code and then start the service.

/var/www/html -> Document root put your code here

#/usr/sbin/httpd
No alt text provided for this image

/usr/sbin/httpd is the file which executed by systemctl command behind the scene so execute the file directly because container engine by default don't support systemctl command. it will give you warning but not the error.

Now check the container ip and get webpage from baseos to check webserver.

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

run firefox command from baseos to check webserver and we can access webpage.

No alt text provided for this image

Webserver is successfully configured, now it's time to install python.

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

for running python we need to launch container, I used new container launched from centos image as above mentioned.

so, we directly jump to installing python package.

No alt text provided for this image
No alt text provided for this image
yum install python36

this is the command to install python package it will provide python interpreter to container.

for running python interpreter we just need to run python command.

python3
No alt text provided for this image

Here I run some random code to check python it's working great!

Thank You!

要查看或添加评论,请登录

Yash Dwivedi的更多文章

社区洞察

其他会员也浏览了