Setting up Python Interpreter and running Python Code on Docker Container
PYTHON
Python is an interpreted, high-level and general-purpose programming language. Python’s design philosophy emphasizes code readability with its notable use of significant indentation. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects.
Python is dynamically-typed and garbage-collected. It supports multiple programming paradigms, including structured (particularly, procedural), object-oriented and functional programming. Python is often described as a “batteries included” language due to its comprehensive standard library.
DOCKER
Docker is a set of the platform as a service (PaaS) products that use OS-level virtualization to deliver software in packages called containers.Containers are isolated from one another and bundle their own software, libraries, and configuration files; they can communicate with each other through well-defined channels. Because all of the containers share the services of a single operating system kernel, they use fewer resources than virtual machines.[8]
We have to create an image that gives us a python interpreter.
MAKING OUR DOCKER IMAGE
=>Creating a Dockerfile for python REPL
FROM centos: latest
RUN yum install python3 -y
CMD [“/usr/bin/python3”
Save this in a file named dockerfile.
Now build the image using the command
docker build -t myrepl:v1 .
let’s run it
=>We have to create one more image to run a python file in our docker container
FROM centos: latest
RUN yum install python3 -y
WORKDIR /code
ENTRYPOINT [“/usr/bin/python3”]
CMD [“ — version”]
Save this code in a file named dockerfile and run the command
docker build -t name: tag.
Let’s run this container
It is working…