Setting up Python Interpreter and running Python Code on Docker Container

Prerequisite:

  • Docker Installed

Step 1) Create a docker file

  • Install python and some basic tools.
FROM centos
RUN dnf install python36 -y
RUN dnf install net-tools vim which -y
  • Build Dockerfile
docker build -t IMAGE_NAME .

Step-2) Run above the docker container.

docker run -it --name NAME_OF_CONTAINER IMAGE_NAME

Output

  • Write the python code
  • Running the python code

--

--