File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -63,30 +63,43 @@ Docker version 17.12.0-ce, build c97c6d6
6363## Dockerfile
6464
6565```
66+ # this is an official Python runtime, used as the parent image
6667FROM python:3.6.4-slim
6768
69+ # set the working directory in the container to /app
6870WORKDIR /app
6971
72+ # add the current directory to the container as /app
7073ADD . /app
7174
75+ # execute everyone's favorite pip command, pip install -r
7276RUN pip install --trusted-host pypi.python.org -r requirements.txt
7377
78+ # unblock port 80 for the Flask app to run on
7479EXPOSE 80
7580
76- ENV DEBUG True
77-
81+ # execute the Flask app
7882CMD ["python", "app.py"]
7983```
8084
85+ Save the Dockerfile so that we can run our next command with the completed
86+ contents of the file. On the commandline run:
87+
8188```
8289docker build -t flaskdock .
8390```
8491
92+ The above ` docker build ` file uses the ` -t ` flag to tag the image with
93+ the name of ` flaskdock ` .
94+
8595
8696## Running the Container
87- Make sure to replace the absolute path for the volume to your own directory.
97+ Now that we have our image in hand we can run it as a container with the
98+ ` docker run ` command. Execute the following command, making sure to replace
99+ the absolute path for the volume to your own directory.
100+
88101```
89- docker run -p 4000 :80 --volume=/Users/matt/devel/py/flaskdocker:/app flaskdock
102+ docker run -p 5000 :80 --volume=/Users/matt/devel/py/flaskdocker:/app flaskdock
90103```
91104
92105## What's Next?
You can’t perform that action at this time.
0 commit comments