From 862659875335c953bf6974af4cace397c7ec3902 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 17 Jun 2013 13:25:50 -0700 Subject: [PATCH] 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.