Skip to content

Commit 2ad82e0

Browse files
committed
working on next blog post
1 parent 6dc5de5 commit 2ad82e0

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

‎content/posts/180309-flask-docker-macos.markdown‎

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff 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
6667
FROM python:3.6.4-slim
6768
69+
# set the working directory in the container to /app
6870
WORKDIR /app
6971
72+
# add the current directory to the container as /app
7073
ADD . /app
7174
75+
# execute everyone's favorite pip command, pip install -r
7276
RUN pip install --trusted-host pypi.python.org -r requirements.txt
7377
78+
# unblock port 80 for the Flask app to run on
7479
EXPOSE 80
7580
76-
ENV DEBUG True
77-
81+
# execute the Flask app
7882
CMD ["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
```
8289
docker 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?

0 commit comments

Comments
 (0)