From 4e538f07a850e568bf24993ebb89bcf798e14fea Mon Sep 17 00:00:00 2001 From: Flavio Castelli Date: Mon, 8 Apr 2013 17:39:30 +0200 Subject: [PATCH] Extend the documentation covering the web app example Make it clear how to access the web app running inside of the container from the host. Upstream-commit: 72fdb4106997799df49faffb96de1d076e8ad755 Component: engine --- .../docs/sources/examples/python_web_app.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/components/engine/docs/sources/examples/python_web_app.rst b/components/engine/docs/sources/examples/python_web_app.rst index 5f7a07ea1e..3adfeec6d6 100644 --- a/components/engine/docs/sources/examples/python_web_app.rst +++ b/components/engine/docs/sources/examples/python_web_app.rst @@ -45,6 +45,11 @@ Save the changed we just made in the container to a new image called "_/builds/g WEB_WORKER=$(docker run -d -p 5000 $BUILD_IMG /usr/local/bin/runapp) +- **"docker run -d "** run a command in a new container. We pass "-d" so it runs as a daemon. + **"-p 5000"* the web app is going to listen on this port, so it must be mapped from the container to the host system. +- **"$BUILD_IMG"** is the image we want to run the command inside of. +- **/usr/local/bin/runapp** is the command which starts the web app. + Use the new image we just created and create a new container with network port 5000, and return the container id and store in the WEB_WORKER variable. .. code-block:: bash @@ -54,6 +59,18 @@ Use the new image we just created and create a new container with network port 5 view the logs for the new container using the WEB_WORKER variable, and if everything worked as planned you should see the line "Running on http://0.0.0.0:5000/" in the log output. +.. code-block:: bash + + WEB_PORT=$(docker port $WEB_WORKER 5000) + +lookup the public-facing port which is NAT-ed store the private port used by the container and store it inside of the WEB_PORT variable. + +.. code-block:: bash + + curl http://`hostname`:$WEB_PORT + Hello world! + +access the web app using curl. If everything worked as planned you should see the line "Hello world!" inside of your console. **Video:**