Configuring webserver and python inside container.
Yash Dwivedi
RHCA | Quantum Computing | OpenShift | DevSecOps | DevOps | MLOps | Big Data | Hybrid Multi Cloud | AWS | GCP | Python | Terraform | Ansible | Kubernetes | MongoDB | GIT & GitHub
??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.
After container launch install httpd package on docker.
yum install httpd or dnf install httpd
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
/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.
run firefox command from baseos to check webserver and we can access webpage.
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.
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
Here I run some random code to check python it's working great!
Thank You!