The main purpose of a Operating System is to run a program. Therefore, in order to run a program we need to boot up a system which takes a lot of time.
In today’s dynamic and fast world we cannot use the older approach of provisioning an OS which takes a long time. Now is the time of Containerization where the OS is provisioned within seconds.
Docker is one such containerization technology which helps us in using containers. Other containerization technology includes Podman, CRIO.
📌 In this blog I am going to show how we can setup a Python interpreter 🐍inside a Docker container 🚢 and run a python code.🤩
Before starting with it, first we need Docker installed in our system.
📍 Refer to my below article where I can explained how to install Docker in a RHEL 8 system and run a container.
Now I believe you have Docker installed in your system. So lets proceed ahead.
Run the below command to start a container -
docker run -it --rm --name pythonos centos:latest
When you run this command in your host system, a new container provisions and you are landed in that containers terminal.
Now you are at the containers terminal. Run the following command to install python3 in the container.
yum install python3 -y
This will successfully install python version 3 in the container. You can confirm that by running the python REPL.
Now let’s create a simple python program which will print the IP address of the container and run that program in the container.
This way we successfully installed the Python 🐍 interpreter and executed a python code 📝 inside the docker container. 🚢
I hope you liked this article.💖
Would definitely like to hear your views on this and feedbacks so that I can improve on those points in future articles. 🙌 Comment your views below.
You can also check my LinkedIn profile and connect with me.
Follow me on medium as I will come up with articles on various technologies like Cloud Computing, DevOps, Automation and their integration.
That’s all for now. Thank You !! 😊✌