Skip to content

Commit d9e6fdb

Browse files
committed
finish up flask/docker on mac tutorial
1 parent e96c8d8 commit d9e6fdb

File tree

3 files changed

+52
-16
lines changed

3 files changed

+52
-16
lines changed

content/pages/08-web-app-deployment/34-docker.markdown

+5-4
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,16 @@ on Amazon Web Services, Google Compute Engine, Linode, Rackspace or elsewhere.
4343

4444
* [Andrew Baker](https://github.com/atbaker) presented a fantastic tutorial
4545
at [PyOhio](http://andrewtorkbaker.com/pyohio-docker-101-tutorial) on
46-
[beginner and advanced Docker usage](https://github.com/atbaker/docker-tutorial).
47-
Andrew also wrote the article [what containers can do for you](http://radar.oreilly.com/2015/01/what-containers-can-do-for-you.html).
46+
[beginner and advanced Docker usage](https://github.com/atbaker/docker-tutorial).
47+
Andrew also wrote the article
48+
[what containers can do for you](http://radar.oreilly.com/2015/01/what-containers-can-do-for-you.html).
4849

4950
* [Docker curriculum](http://prakhar.me/docker-curriculum/) is a detailed
5051
tutorial created by a developer to show the exact steps for deploying an
5152
application that relies on [Elasticsearch](https://www.elastic.co/).
5253

53-
* [How to install Docker and get started](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-getting-started)
54-
provides a walkthrough for Ubuntu 13.04 for installing and beginning to
54+
* [How To Install and Use Docker on Ubuntu 16.04](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04)
55+
provides a walkthrough for Ubuntu 16.04 for installing and beginning to
5556
use Docker for development.
5657

5758
* [It Really is the Future](http://blog.circleci.com/it-really-is-the-future/)

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

+39-12
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@ slug: develop-flask-web-apps-docker-containers-macos
33
meta: Learn how to set up and develop a new Flask web application within a Docker container.
44
category: post
55
date: 2018-03-09
6-
modified: 2018-03-09
6+
modified: 2018-03-14
77
newsletter: False
88
headerimage: /img/180309-flask-docker/header.jpg
99
headeralt: Flask, Docker and Apple logos, copyright their respective owners.
1010

1111

1212
Adding [Docker](/docker.html) to your [Python](/why-use-python.html) and
13-
[Flask](/flask.html) [development environment's](/development-environments.html)
14-
workflow can be a bit confusing when you are just getting started with
15-
containers. Let's quickly get Docker installed and configured for developing
16-
Flask web applications on your local system.
13+
[Flask](/flask.html) [development environment](/development-environments.html)
14+
can be confusing when you are just getting started with containers. Let's
15+
quickly get Docker installed and configured for developing Flask web
16+
applications on your local system.
1717

1818

1919
## Our Tools
20-
This tutorial is written for [Python 3](/python-2-or-3.html). It may work with
20+
This tutorial is written for [Python 3](/python-2-or-3.html). It will work with
2121
Python 2 but I have not tested it with the
2222
[soon-to-be deprecated 2.7 version](https://pythonclock.org/).
2323

@@ -116,12 +116,29 @@ docker build -t flaskdock .
116116
The above `docker build` file uses the `-t` flag to tag the image with
117117
the name of `flaskdock`.
118118

119+
If the build worked successfully we can see the image in with the
120+
`docker image ls` command. Give that a try now:
121+
122+
```
123+
docker image ls
124+
```
125+
126+
We should then see our tag name in the images list:
127+
128+
```
129+
REPOSITORY TAG IMAGE ID CREATED SIZE
130+
flaskdock latest 24045e0464af 2 minutes ago 165MB
131+
```
132+
133+
Our image is ready to load up as a container so we can write a quick
134+
Flask app that we will use to test our environment by running it within
135+
the container.
136+
119137

120138
## Coding A Simple Flask app
121139
Time to put together a super simple "Hello, World!" Flask web app to test
122140
running Python code within our Docker container. Within the current
123-
project directory, create a file named `app.py` with the following
124-
contents:
141+
project directory, create a file named `app.py` with the following contents:
125142

126143
```python
127144
from flask import Flask, Response
@@ -139,9 +156,10 @@ if __name__ == "__main__":
139156
app.run("0.0.0.0", port=80, debug=True)
140157
```
141158

142-
The above 7 lines of code (not counting blank PEP8-compliant lines) allow our
143-
application to return a simple message when run with the Flask development
144-
server.
159+
The above 7 lines of code (not counting blank PEP8-compliant lines) in
160+
[app.py](https://github.com/fullstackpython/blog-code-examples/blob/master/docker-flask-mac/app.py)
161+
allow our application to return a simple message when run with the
162+
Flask development server.
145163

146164
Save the file and we can give the code a try.
147165

@@ -165,10 +183,19 @@ directory where your project files, especially `app.py`, are located.
165183
<img src="/img/180309-flask-docker/flask-app-response.png" width="100%"
166184
class="shot rnd" alt="Flask app responding to requests from within a Docker container.">
167185

186+
Everything worked when you see a simple text-based HTTP response like what
187+
is shown above in the screenshot of my Chrome browser.
188+
189+
168190
## What's Next?
169191
We just installed Docker and configured a Flask application to run inside a
170192
container. That is just the beginning of how you can integrate Docker into
171-
your workflow. Next up take a look at the [Docker](/docker.html) and
193+
your workflow. I strongly recommend reading the
194+
[Django with PostgreSQL quickstart](https://docs.docker.com/compose/django/)
195+
that will introduce you to Docker Swarm as well as the core Docker container
196+
service.
197+
198+
Next up take a look at the [Docker](/docker.html) and
172199
[deployment](/deployment.html) pages for more related tutorials.
173200

174201
Questions? Let me know via a GitHub
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="refresh" content="0; url=https://www.fullstackpython.com/blog/develop-flask-web-apps-docker-containers-macos.html">
5+
</head>
6+
<body>
7+
</body>
8+
</html>

0 commit comments

Comments
 (0)