Docker-DCO-1.1-Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au> (github: SvenDowideit)
| ... | ... |
@@ -9,7 +9,7 @@ Python Web App |
| 9 | 9 |
|
| 10 | 10 |
.. include:: example_header.inc |
| 11 | 11 |
|
| 12 |
-While using Dockerfiles is the preffered way to create maintainable |
|
| 12 |
+While using Dockerfiles is the preferred way to create maintainable |
|
| 13 | 13 |
and repeatable images, its useful to know how you can try things out |
| 14 | 14 |
and then commit your live changes to an image. |
| 15 | 15 |
|
| ... | ... |
@@ -62,8 +62,8 @@ Commit the container to create a new image |
| 62 | 62 |
------------------------------------------ |
| 63 | 63 |
|
| 64 | 64 |
Save the changes we just made in the container to a new image called |
| 65 |
-``/builds/github.com/hykes/helloflask/master``. You now have 3 different |
|
| 66 |
-ways to refer to the container, name, short-id ``c8b2e8228f11``, or |
|
| 65 |
+``/builds/github.com/shykes/helloflask/master``. You now have 3 different |
|
| 66 |
+ways to refer to the container: name ``pybuilder_run``, short-id ``c8b2e8228f11``, or |
|
| 67 | 67 |
long-id ``c8b2e8228f11b8b3e492cbf9a49923ae66496230056d61e07880dc74c5f495f9``. |
| 68 | 68 |
|
| 69 | 69 |
.. code-block:: bash |
| ... | ... |
@@ -76,12 +76,11 @@ Run the new image to start the web worker |
| 76 | 76 |
----------------------------------------- |
| 77 | 77 |
|
| 78 | 78 |
Use the new image to create a new container with |
| 79 |
-network port 5000, and return the container ID and store in the |
|
| 80 |
-``WEB_WORKER`` variable (rather than naming a container/image, you can use the ID's). |
|
| 79 |
+network port 5000 mapped to a local port |
|
| 81 | 80 |
|
| 82 | 81 |
.. code-block:: bash |
| 83 | 82 |
|
| 84 |
- $ WEB_WORKER=$(sudo docker run -d -p 5000 /builds/github.com/hykes/helloflask/master /usr/local/bin/runapp) |
|
| 83 |
+ $ sudo docker run -d -p 5000 --name web_worker /builds/github.com/shykes/helloflask/master /usr/local/bin/runapp |
|
| 85 | 84 |
|
| 86 | 85 |
|
| 87 | 86 |
- **"docker run -d "** run a command in a new container. We pass "-d" |
| ... | ... |
@@ -94,7 +93,7 @@ network port 5000, and return the container ID and store in the |
| 94 | 94 |
View the container logs |
| 95 | 95 |
----------------------- |
| 96 | 96 |
|
| 97 |
-View the logs for the new container using the ``WEB_WORKER`` variable, and |
|
| 97 |
+View the logs for the new ``web_worker`` container and |
|
| 98 | 98 |
if everything worked as planned you should see the line ``Running on |
| 99 | 99 |
http://0.0.0.0:5000/`` in the log output. |
| 100 | 100 |
|
| ... | ... |
@@ -103,7 +102,7 @@ terminal and continue with the example while watching the result in the logs. |
| 103 | 103 |
|
| 104 | 104 |
.. code-block:: bash |
| 105 | 105 |
|
| 106 |
- $ sudo docker logs -f $WEB_WORKER |
|
| 106 |
+ $ sudo docker logs -f web_worker |
|
| 107 | 107 |
* Running on http://0.0.0.0:5000/ |
| 108 | 108 |
|
| 109 | 109 |
|
| ... | ... |
@@ -118,7 +117,7 @@ should see the line ``Hello world!`` inside of your console. |
| 118 | 118 |
|
| 119 | 119 |
.. code-block:: bash |
| 120 | 120 |
|
| 121 |
- $ WEB_PORT=$(sudo docker port $WEB_WORKER 5000 | awk -F: '{ print $2 }')
|
|
| 121 |
+ $ WEB_PORT=$(sudo docker port web_worker 5000 | awk -F: '{ print $2 }')
|
|
| 122 | 122 |
|
| 123 | 123 |
# install curl if necessary, then ... |
| 124 | 124 |
$ curl http://127.0.0.1:$WEB_PORT |
| ... | ... |
@@ -137,8 +136,8 @@ running, it will still be listed here with a status of 'Exit 0'. |
| 137 | 137 |
|
| 138 | 138 |
.. code-block:: bash |
| 139 | 139 |
|
| 140 |
- $ sudo docker stop $WEB_WORKER |
|
| 141 |
- $ sudo docker rm $WEB_WORKER pybuilder_run |
|
| 140 |
+ $ sudo docker stop web_worker |
|
| 141 |
+ $ sudo docker rm web_worker pybuilder_run |
|
| 142 | 142 |
$ sudo docker rmi /builds/github.com/shykes/helloflask/master shykes/pybuilder:latest |
| 143 | 143 |
|
| 144 | 144 |
And now stop the running web worker, and delete the containers, so that we can |