Running python code in Docker
- Create app.py using
vi app.py
with just the following line of python code:
print "Hello, world here!!!"
-
Press
<Esc>
-
Type
:x
- Create a docker file using
vi Dockerfile
and 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-world
is the image name and you will get the results as shown below: -
Run the docker image using
docker run python-new-world
and you will get the following output in terminal window as shown below: