Setting up Python Interpreter and running Python Code on Docker Container

Pre-Requisite:- Basic knowledge of Docker

In this task, we will see how we can setup and install Python interpreter on top of Docker container and then write one python code and execute it. For doing this you should know how to install Docker and pull images from Docker Hub.

Thus, our first step is to download docker on top of RHEL8 VM and for that we have to download it by going to link and configure yum for docker -> http://download.docker.com/linux/centos/7x86_64/stable

Then, to install the most stable version of docker, use command->

yum install docker-ce --nobest

After installing it, we have to start docker service using command->

systemctl start docker

Now, in this practical task we will have to use one of the docker image on top of which we will host our webserver. But, first we have to pull one of docker image from one of popular public repository of Docker called as Docker Hub. In our case, we will be using CentOS image which has almost similar commands and functions as that of RHEL8. For doing this, use command->

docker pull centos

After downloading this image we have to follow the process that is showed in below video. If you want to see how many docker images you have in your system, then use command->

docker images

docker run -it — name <cont_name> centos:<version> (In our case we are using latest version).

2. Now , as we want to install python interpreter on top of our docker container, then for that we have to install one software called “python36” in CentOS linux image.

yum install python36 -y

After this we can create one python file having ‘.py’ extension and write our code in that file and then execute that code using command->

python3 <filename>.py

THANK YOU FOR READING!!

THANK YOU VIMAL DAGA SIR FOR GIVING SUCH KNOWLEDGE.