Setting Up Python Environment On Docker Container

Pawan Kumar

In this article I gonna setup python environment on docker container. I will use pyhton3 through this article..


  • Docker Insatlled and Service started
  • Centos Image Downloaded in Docker

Installing Python On Container

By default python are not installed on centos image of docker. To check whether the python is installed or not on container with command: rpm -q python3 in my case it is not installed.

Python3 Package not installed

So to install python3 I’m using yum program as: yum install python3 -y

Installing Python3 package

Writing Python Code

After installing python now we are good to go write and run code ..I’m creating simple code to print one line

Running Python Code

Now after saving file of python code we are good to run the python code.. Two ways to do so

  1. Attach to the container and run code there.
  2. By using exec command of docker we can run the code without attaching.

In my example I have run with both the ways:-

That’s it guys now you can run any code in docker container…

Leave a Comment

Your email address will not be published. Required fields are marked *