š„Setting up Python Interpreter and running Python Code on Docker Container.
Mar 15, 2021
Python is a programming language and many applications are developed in it because of many reasons. So it is important that docker must have a python interpreter to run the application on it.
For setup python interpreter on the docker follow these steps
Step 1: Launch a Docker container
docker run -it --name <container_name> <image>:<version>
The above command will launch a container on the host OS with your desired image. In my case, I have used centos:latest image.
Container name: pythonOS
Step 2. Install Python
yum install -y python36
The above command will install python 3.6 in the container.
Step 3. Write a code and run it
cat > first.py
print("First code")
I have created a file named first.py for demo only. Now, run it with the python3 command.
python3 first.py