Python on docker container
Posted By : Vinay Mann | 24-Jun-2022
We will configure HTTPD Server and Python Interpreter on Docker Container
These are the steps to setup HTTPS server on docker container:
Before everything firstly we need to start our docker service on the server:
#systemctl start docker
So to start any service firstly we need a container where we deploy our application.
We will launch a container with centOS image on port number 80
and also assign a name to our container.
Command to lauch the container
: #docker run -it - -name my0s2 -p 99:80 centos
Now we can see that our container get launched now we need to
Configure HTTPD service
So firstly we will install the service
Command to install the service: # yum install httpd
So our httpd service get installed successfully, we can also confirm that by using the command below
Command for confirmation : #rpm -q httpd
Now we will move the configuration file of our httpd service and make changes in it to see the working of our HTTPD server.
We need to write something in the configuration file to see its working
Commands to enter into the directory : #cd /var/www/html
You can use any editor to make changes in the file, or you can install it
such as vi or vim
When you try to run the ifconfig command it will display out an error which can be resolved by installing the net-tools command
Command : #yum install net-tools
Now you have to restart the httpd service but systemctl command doesn’t work on it so this is the command to restart it.
services here we use command : #/usr/sbin/httpd
As we have installed the net-tools successfully now we can able to see the ip of our container using the ifconfig command.
Search : #172.17.02/myweb.html
Now if you are able to see the output on the webpage it means your service is installed and running successfully.
Now we setup python interpreter on container and run the code on it:
To run python interpreter first we need to install python.
Command to install: #yum install python3
Now you can see that python is installed over the docker and now we can run out code onto it
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
Vinay Mann
Vinay is a highly experienced DevOps Engineer with expertise in various industry-standard tools and technologies. His skill set includes Linux administration, AWS services, Docker, Kubernetes, Ansible, Git, Jenkins, Terraform, Python, and Shell scripting. He has contributed to projects like Oodles dashboard, Communication Scaffold, and Oodles.com. Vinay has also earned certifications in AWS Solution Architect and RHCSA, demonstrating his proficiency in these domains. He plays a crucial role in ensuring the seamless functioning of software development and deployment processes.