Browse code

Add gists provided by Mary

This adds the example gists, provided by Mary Anthony,
also fixes a link to the old /terms/

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2015/08/18 07:16:11
Showing 1 changed files
... ...
@@ -16,15 +16,14 @@ parent = "mn_reference"
16 16
 </style>
17 17
 # Docker run reference
18 18
 
19
-**Docker runs processes in isolated containers**. When an operator
20
-executes `docker run`, she starts a process with its own file system,
21
-its own networking, and its own isolated process tree.  The
22
-[*Image*](/reference/glossary/#image) which starts the process may define
23
-defaults related to the binary to run, the networking to expose, and
24
-more, but `docker run` gives additional control to the operator who starts
25
-the container from the image. That's the main reason
26
-[*run*](/reference/commandline/run) has more options than any
27
-other `docker` command.
19
+Docker runs processes in isolated containers. A container is a process
20
+which runs on a host. The host may be local or remote. When an operator
21
+executes `docker run`, the container process that runs is isolated in
22
+that it has its own file system, its own networking, and its own
23
+isolated process tree separate from the host.
24
+
25
+This page details how to use the `docker run` command to define the
26
+container's resources at runtime.
28 27
 
29 28
 ## General form
30 29
 
... ...
@@ -32,27 +31,33 @@ The basic `docker run` command takes this form:
32 32
 
33 33
     $ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
34 34
 
35
-To learn how to interpret the types of `[OPTIONS]`,
36
-see [*Option types*](/reference/commandline/cli/#option-types).
37
-
38
-The `run` options control the image's runtime behavior in a container. These
39
-settings affect:
35
+The `docker run` command must specify an [*IMAGE*](/reference/glossary/#image)
36
+to derive the container from. An image developer can define image
37
+defaults related to:
40 38
 
41 39
  * detached or foreground running
42 40
  * container identification
43 41
  * network settings
44 42
  * runtime constraints on CPU and memory
45 43
  * privileges and LXC configuration
46
- 
47
-An image developer may set defaults for these same settings when she creates the
48
-image using the `docker build` command. Operators can use the `run` options to override most of the
49
-defaults set by the developer. And, operators can override nearly all the defaults set by the Docker runtime itself.
50 44
 
51
-Finally, depending on your Docker system configuration, you may be required to
52
-preface each `docker` command with `sudo`. To avoid having to use `sudo` with
53
-the `docker` command, your system administrator can create a Unix group called
54
-`docker` and add users to it. For more information about this configuration,
55
-refer to the Docker installation documentation for your operating system.
45
+With the `docker run [OPTIONS]` an operator can add to or override the
46
+image defaults set by a developer. And, additionally, operators can
47
+override nearly all the defaults set by the Docker runtime itself. The
48
+operator's ability to override image and Docker runtime defaults is why
49
+[*run*](/reference/commandline/cli/run/) has more options than any
50
+other `docker` command.
51
+
52
+To learn how to interpret the types of `[OPTIONS]`, see [*Option
53
+types*](/reference/commandline/cli/#option-types).
54
+
55
+> **Note**: Depending on your Docker system configuration, you may be
56
+> required to preface the `docker run` command with `sudo`. To avoid
57
+> having to use `sudo` with the `docker` command, your system
58
+> administrator can create a Unix group called `docker` and add users to
59
+> it. For more information about this configuration, refer to the Docker
60
+> installation documentation for your operating system.
61
+
56 62
 
57 63
 ## Operator exclusive options
58 64
 
... ...
@@ -971,45 +976,59 @@ or two examples of how to pass more parameters to that ENTRYPOINT:
971 971
 
972 972
 ### EXPOSE (incoming ports)
973 973
 
974
-The Dockerfile doesn't give much control over networking, only providing
975
-the `EXPOSE` instruction to specify incoming ports that provide services.
976 974
 The following `run` command options work with container networking:
977 975
 
978
-    --expose=[]: Expose a port or a range of ports from the container,
979
-                in addition to ports exposed by the `EXPOSE` Dockerfile instruction
976
+    --expose=[]: Expose a port or a range of ports inside the container.
977
+                 These are additional to those exposed by the `EXPOSE` instruction
980 978
     -P=false   : Publish all exposed ports to the host interfaces
981 979
     -p=[]      : Publish a container᾿s port or a range of ports to the host
982 980
                    format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort
983
-                   Both hostPort and containerPort can be specified as a range of ports.
984
-                   When specifying ranges for both, the number of container ports in the range must match the number of host ports in the range. (e.g., `-p 1234-1236:1234-1236/tcp`)
985
-                   When specifying a range for hostPort only, the containerPort must not be a range.  In this case the container port is published somewhere within the specified hostPort range. (e.g., `-p 1234-1236:1234/tcp`)
981
+                   Both hostPort and containerPort can be specified as a
982
+                   range of ports. When specifying ranges for both, the
983
+                   number of container ports in the range must match the
984
+                   number of host ports in the range, for example:
985
+                       -p 1234-1236:1234-1236/tcp
986
+
987
+                   When specifying a range for hostPort only, the
988
+                   containerPort must not be a range.  In this case the
989
+                   container port is published somewhere within the
990
+                   specified hostPort range. (e.g., `-p 1234-1236:1234/tcp`)
991
+
986 992
                    (use 'docker port' to see the actual mapping)
993
+
987 994
     --link=""  : Add link to another container (<name or id>:alias or <name or id>)
988 995
 
989
-As mentioned previously, `EXPOSE` (and `--expose`) makes ports available
990
-**in** a container for incoming connections. The port number on the
991
-inside of the container (where the service listens) does not need to be
992
-the same number as the port exposed on the outside of the container
993
-(where clients connect), so inside the container you might have an HTTP
994
-service listening on port 80 (and so you `EXPOSE 80` in the Dockerfile),
995
-but outside the container the port might be 42800.
996
-
997
-To help a new client container reach the server container's internal
998
-port operator `--expose`'d by the operator or `EXPOSE`'d by the
999
-developer, the operator has three choices: start the server container
1000
-with `-P` or `-p,` or start the client container with `--link`.
1001
-
1002
-If the operator uses `-P` or `-p` then Docker will make the exposed port
1003
-accessible on the host and the ports will be available to any client that can
1004
-reach the host. When using `-P`, Docker will bind the exposed port to a random
1005
-port on the host within an *ephemeral port range* defined by
1006
-`/proc/sys/net/ipv4/ip_local_port_range`. To find the mapping between the host
1007
-ports and the exposed ports, use `docker port`.
1008
-
1009
-If the operator uses `--link` when starting the new client container,
996
+With the exception of the `EXPOSE` directive, an image developer hasn't
997
+got much control over networking. The `EXPOSE` instruction defines the
998
+initial incoming ports that provide services. These ports are available
999
+to processes inside the container. An operator can use the `--expose`
1000
+option to add to the exposed ports.
1001
+
1002
+To expose a container's internal port, an operator can start the
1003
+container with the `-P` or `-p` flag. The exposed port is accessible on
1004
+the host and the ports are available to any client that can reach the
1005
+host.
1006
+
1007
+The `-P` option publishes all the ports to the host interfaces. Docker
1008
+binds each exposed port to a random port on the host. The range of
1009
+ports are within an *ephemeral port range* defined by
1010
+`/proc/sys/net/ipv4/ip_local_port_range`. Use the `-p` flag to
1011
+explicitly map a single port or range of ports.
1012
+
1013
+The port number inside the container (where the service listens) does
1014
+not need to match the port number exposed on the outside of the
1015
+container (where clients connect). For example, inside the container an
1016
+HTTP service is listening on port 80 (and so the image developer
1017
+specifies `EXPOSE 80` in the Dockerfile). At runtime, the port might be
1018
+bound to 42800 on the host. To find the mapping between the host ports
1019
+and the exposed ports, use `docker port`.
1020
+
1021
+If the operator uses `--link` when starting a new client container,
1010 1022
 then the client container can access the exposed port via a private
1011
-networking interface.  Docker will set some environment variables in the
1012
-client container to help indicate which interface and port to use.
1023
+networking interface. Docker will set some environment variables in the
1024
+client container to help indicate which interface and port to use. For
1025
+more information on linking, see [the guide on linking container
1026
+together](/userguide/dockerlinks/)
1013 1027
 
1014 1028
 ### ENV (environment variables)
1015 1029