Setup Python Interpreter On Docker Container
In the last blog, we have already seen how we can install docker in Linux especially in RedHat
https://all-about-devops.blogspot.com/2021/03/setup-apache-web-server-in-docker.html
Task Objective:-
Setting up Python Interpreter and running Python Code on Docker Container
What is Python?
Python is an interpreted, object-oriented, high-level programming language with dynamic semantics.
What is an interpreter?
An interpreter is a kind of program that executes other programs. When you write Python programs, it converts source code written by the developer into an intermediate language which is again translated into the native language/machine language that is executed we got output.
Let’s Get Started
To Perform this practical you need the Docker Tool.
Step 1: pull one image to run your containers on top of the image
docker pull “image name ex. centos”
Step 2: Now launch a container using this image
docker run -it — name “any name to container” “image name ex. centos”
Step 3: you will get a docker prompt as you can see on the above image and the following are the steps performed inside the container for the Python interpreter
So we got our container Now we need to install a python interpreter as we have mentioned in the title
Please run the following command in the container to install the python interpreter:
yum install python3
Step 4: Start interpreter using the following command
python3
so we will make the interpreter permanent so it will auto start the interpreter on container boot
Step 5: In this step, we make this service permanent
In the following file just update the path of your web server:
file: /root/.bashrc
path: /usr/bin/python3
so whenever you launch the same container python interpreter automatically start so you don’t need to start it again and again
Conclusion:-
With the Docker concept, we have launched the python interpreter on the container and we have applied all the necessary concepts that need to apply ultimately we able to Launch an interpreter on the Docker container.
No comments