From 36231345f17e6fdb08b0f756c4872294d4745048 Mon Sep 17 00:00:00 2001 From: Victor Vieux Date: Mon, 17 Jun 2013 22:05:58 +0200 Subject: [PATCH 1/3] add port redirection doc --- docs/sources/use/index.rst | 1 + docs/sources/use/port_redirection.rst | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 docs/sources/use/port_redirection.rst diff --git a/docs/sources/use/index.rst b/docs/sources/use/index.rst index a1086c1fd2..2f74f60718 100644 --- a/docs/sources/use/index.rst +++ b/docs/sources/use/index.rst @@ -14,6 +14,7 @@ Contents: basics workingwithrepository + port_redirection builder puppet diff --git a/docs/sources/use/port_redirection.rst b/docs/sources/use/port_redirection.rst new file mode 100644 index 0000000000..c0b4041e7c --- /dev/null +++ b/docs/sources/use/port_redirection.rst @@ -0,0 +1,23 @@ +:title: Port redirection +:description: usage about port redirection +:keywords: Usage, basic port, docker, documentation, examples + + +Port redirection +================ + +Port redirection is done on ``docker run`` using the -p flag. + +Here are the 3 ways to redirect a port: + +.. code-block:: bash + + # the port 80 in the container is mapped to a random port of the host + docker run -p 80 + + # the port 80 in the container is mapped to the port 80 of the host + docker run -p :80 + + # the port 80 in the container is mapped to the port 5555 of the host + docker run -p 5555:80 + From 862659875335c953bf6974af4cace397c7ec3902 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 17 Jun 2013 13:25:50 -0700 Subject: [PATCH 2/3] Added content to port redirect doc --- docs/sources/use/port_redirection.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/docs/sources/use/port_redirection.rst b/docs/sources/use/port_redirection.rst index c0b4041e7c..b866fe309d 100644 --- a/docs/sources/use/port_redirection.rst +++ b/docs/sources/use/port_redirection.rst @@ -6,18 +6,20 @@ Port redirection ================ +Docker can redirect public tcp ports to your container, so it can be reached over the network. Port redirection is done on ``docker run`` using the -p flag. -Here are the 3 ways to redirect a port: +A port redirect is specified as PUBLIC:PRIVATE, where tcp port PUBLIC will be redirected to +tcp port PRIVATE. As a special case, the public port can be omitted, in which case a random +public port will be allocated. .. code-block:: bash - # the port 80 in the container is mapped to a random port of the host + # A random PUBLIC port is redirected to PRIVATE port 80 on the container docker run -p 80 - # the port 80 in the container is mapped to the port 80 of the host - docker run -p :80 + # PUBLIC port 80 is redirected to PRIVATE port 80 + docker run -p 80:80 - # the port 80 in the container is mapped to the port 5555 of the host - docker run -p 5555:80 +Default port redirects can be built into a container with the EXPOSE build command. From cb58e63fc54fb3f1c620c8372269a8e308e43bee Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 17 Jun 2013 14:28:04 -0600 Subject: [PATCH 3/3] Typo --- docs/sources/use/port_redirection.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/sources/use/port_redirection.rst b/docs/sources/use/port_redirection.rst index b866fe309d..5cf848f9ea 100644 --- a/docs/sources/use/port_redirection.rst +++ b/docs/sources/use/port_redirection.rst @@ -19,7 +19,7 @@ public port will be allocated. docker run -p 80 # PUBLIC port 80 is redirected to PRIVATE port 80 - docker run -p 80:80 + docker run -p 80:80 Default port redirects can be built into a container with the EXPOSE build command.