Python program in Docker Container

Python program in Docker Container

A container is a standard unit of software that packages up code and all its dependencies so the application runs quickly and reliably from one computing environment to another. But it provides very less number of packages pre-installed which does not consist of Python.

So to use Python in a Docker container first you have to install python by using yum command:-

yum install python3

python 3.jpg

This command will install python in Docker container, now next is to write some python code in Container. So we create a python file with a name test.py.

The test.py contains:-

print("This is a python program in docker container.")

cat.jpg Now run the python code with:-

python3 test.py

test.jpg Here you can see python code is working in the Docker Container.