Running python code in Docker
-
Create app.py using
vi app.pywith just the following line of python code:print "Hello, world here!!!"-
Press
<Esc> -
Type
:x
-
-
Create a docker file using
vi Dockerfileand add the following:FROM python:2.7 ADD app.py / CMD [ "python", "./app.py" ]-
Press
<Esc> -
Type
:x
-
-
Build the docker image using
docker build -t python-new-world .wherepython-new-worldis the image name and you will get the results as shown below: -
Run the docker image using
docker run python-new-worldand you will get the following output in terminal window as shown below: