Formatting and consistency fixes to CLI and RUN references
| ... | ... |
@@ -199,26 +199,26 @@ To kill the container, use `docker kill`. |
| 199 | 199 |
--rm=true Remove intermediate containers after a successful build |
| 200 | 200 |
-t, --tag="" Repository name (and optionally a tag) to be applied to the resulting image in case of success |
| 201 | 201 |
|
| 202 |
-Use this command to build Docker images from a Dockerfile |
|
| 203 |
-and a "context". |
|
| 204 |
- |
|
| 205 |
-The files at `PATH` or `URL` are called the "context" of the build. The build |
|
| 206 |
-process may refer to any of the files in the context, for example when using an |
|
| 207 |
-[*ADD*](/reference/builder/#dockerfile-add) instruction. When a single Dockerfile is |
|
| 208 |
-given as `URL` or is piped through STDIN (`docker build - < Dockerfile`), then |
|
| 209 |
-no context is set. |
|
| 210 |
- |
|
| 211 |
-When a Git repository is set as `URL`, then the |
|
| 212 |
-repository is used as the context. The Git repository is cloned with its |
|
| 213 |
-submodules (git clone –recursive). A fresh git clone occurs in a |
|
| 214 |
-temporary directory on your local host, and then this is sent to the |
|
| 215 |
-Docker daemon as the context. This way, your local user credentials and |
|
| 216 |
-vpn's etc can be used to access private repositories. |
|
| 217 |
- |
|
| 218 |
-If a file named ``.dockerignore`` exists in the root of ``PATH`` then it is |
|
| 219 |
-interpreted as a newline-separated list of exclusion patterns. Exclusion |
|
| 220 |
-patterns match files or directories relative to ``PATH`` that will be excluded |
|
| 221 |
-from the context. Globbing is done using Go's |
|
| 202 |
+Use this command to build Docker images from a Dockerfile and a |
|
| 203 |
+"context". |
|
| 204 |
+ |
|
| 205 |
+The files at `PATH` or `URL` are called the "context" of the build. The |
|
| 206 |
+build process may refer to any of the files in the context, for example |
|
| 207 |
+when using an [*ADD*](/reference/builder/#dockerfile-add) instruction. |
|
| 208 |
+When a single Dockerfile is given as `URL` or is piped through `STDIN` |
|
| 209 |
+(`docker build - < Dockerfile`), then no context is set. |
|
| 210 |
+ |
|
| 211 |
+When a Git repository is set as `URL`, then the repository is used as |
|
| 212 |
+the context. The Git repository is cloned with its submodules (`git |
|
| 213 |
+clone -recursive`). A fresh `git clone` occurs in a temporary directory |
|
| 214 |
+on your local host, and then this is sent to the Docker daemon as the |
|
| 215 |
+context. This way, your local user credentials and VPN's etc can be |
|
| 216 |
+used to access private repositories. |
|
| 217 |
+ |
|
| 218 |
+If a file named `.dockerignore` exists in the root of `PATH` then it |
|
| 219 |
+is interpreted as a newline-separated list of exclusion patterns. |
|
| 220 |
+Exclusion patterns match files or directories relative to `PATH` that |
|
| 221 |
+will be excluded from the context. Globbing is done using Go's |
|
| 222 | 222 |
[filepath.Match](http://golang.org/pkg/path/filepath#Match) rules. |
| 223 | 223 |
|
| 224 | 224 |
See also: |
| ... | ... |
@@ -304,15 +304,14 @@ and the tag will be `2.0` |
| 304 | 304 |
|
| 305 | 305 |
$ sudo docker build - < Dockerfile |
| 306 | 306 |
|
| 307 |
-This will read a Dockerfile from STDIN without |
|
| 308 |
-context. Due to the lack of a context, no contents of any local |
|
| 309 |
-directory will be sent to the `docker` daemon. Since |
|
| 310 |
-there is no context, a Dockerfile `ADD` |
|
| 311 |
-only works if it refers to a remote URL. |
|
| 307 |
+This will read a Dockerfile from `STDIN` without context. Due to the |
|
| 308 |
+lack of a context, no contents of any local directory will be sent to |
|
| 309 |
+the Docker daemon. Since there is no context, a Dockerfile `ADD` only |
|
| 310 |
+works if it refers to a remote URL. |
|
| 312 | 311 |
|
| 313 | 312 |
$ sudo docker build - < context.tar.gz |
| 314 | 313 |
|
| 315 |
-This will build an image for a compressed context read from STDIN. |
|
| 314 |
+This will build an image for a compressed context read from `STDIN`. |
|
| 316 | 315 |
Supported formats are: bzip2, gzip and xz. |
| 317 | 316 |
|
| 318 | 317 |
$ sudo docker build github.com/creack/docker-firefox |
| ... | ... |
@@ -518,7 +517,7 @@ by default. |
| 518 | 518 |
|
| 519 | 519 |
### Filtering |
| 520 | 520 |
|
| 521 |
-The filtering flag (-f or --filter) format is of "key=value". If there are more |
|
| 521 |
+The filtering flag (`-f` or `--filter`) format is of "key=value". If there are more |
|
| 522 | 522 |
than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`) |
| 523 | 523 |
|
| 524 | 524 |
Current filters: |
| ... | ... |
@@ -562,11 +561,10 @@ NOTE: Docker will warn you if any containers exist that are using these untagged |
| 562 | 562 |
|
| 563 | 563 |
Create an empty filesystem image and import the contents of the tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then optionally tag it. |
| 564 | 564 |
|
| 565 |
-URLs must start with `http` and point to a single |
|
| 566 |
-file archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, or .txz) containing a |
|
| 567 |
-root filesystem. If you would like to import from a local directory or |
|
| 568 |
-archive, you can use the `-` parameter to take the |
|
| 569 |
-data from STDIN. |
|
| 565 |
+URLs must start with `http` and point to a single file archive (.tar, |
|
| 566 |
+.tar.gz, .tgz, .bzip, .tar.xz, or .txz) containing a root filesystem. If |
|
| 567 |
+you would like to import from a local directory or archive, you can use |
|
| 568 |
+the `-` parameter to take the data from `STDIN`. |
|
| 570 | 569 |
|
| 571 | 570 |
### Examples |
| 572 | 571 |
|
| ... | ... |
@@ -578,7 +576,7 @@ This will create a new untagged image. |
| 578 | 578 |
|
| 579 | 579 |
**Import from a local file:** |
| 580 | 580 |
|
| 581 |
-Import to docker via pipe and STDIN. |
|
| 581 |
+Import to docker via pipe and `STDIN`. |
|
| 582 | 582 |
|
| 583 | 583 |
$ cat exampleimage.tgz | sudo docker import - exampleimagelocal:new |
| 584 | 584 |
|
| ... | ... |
@@ -681,7 +679,7 @@ contains complex json object, so to grab it as JSON, you use |
| 681 | 681 |
|
| 682 | 682 |
-s, --signal="KILL" Signal to send to the container |
| 683 | 683 |
|
| 684 |
-The main process inside the container will be sent SIGKILL, or any |
|
| 684 |
+The main process inside the container will be sent `SIGKILL`, or any |
|
| 685 | 685 |
signal specified with option `--signal`. |
| 686 | 686 |
|
| 687 | 687 |
## load |
| ... | ... |
@@ -739,8 +737,8 @@ The `docker logs` command batch-retrieves all logs |
| 739 | 739 |
present at the time of execution. |
| 740 | 740 |
|
| 741 | 741 |
The ``docker logs --follow`` command will first return all logs from the |
| 742 |
-beginning and then continue streaming new output from the container's stdout |
|
| 743 |
-and stderr. |
|
| 742 |
+beginning and then continue streaming new output from the container's `STDOUT` |
|
| 743 |
+and `STDERR`. |
|
| 744 | 744 |
|
| 745 | 745 |
## port |
| 746 | 746 |
|
| ... | ... |
@@ -1074,7 +1072,7 @@ This will create and run a new container with the container name being |
| 1074 | 1074 |
|
| 1075 | 1075 |
The `--link` flag will link the container named `/redis` into the newly |
| 1076 | 1076 |
created container with the alias `redis`. The new container can access the |
| 1077 |
-network and environment of the redis container via environment variables. |
|
| 1077 |
+network and environment of the `redis` container via environment variables. |
|
| 1078 | 1078 |
The `--name` flag will assign the name `console` to the newly created |
| 1079 | 1079 |
container. |
| 1080 | 1080 |
|
| ... | ... |
@@ -1087,19 +1085,19 @@ optionally suffixed with `:ro` or `:rw` to mount the volumes in read-only |
| 1087 | 1087 |
or read-write mode, respectively. By default, the volumes are mounted in |
| 1088 | 1088 |
the same mode (read write or read only) as the reference container. |
| 1089 | 1089 |
|
| 1090 |
-The `-a` flag tells `docker run` to bind to the container's stdin, stdout or |
|
| 1091 |
-stderr. This makes it possible to manipulate the output and input as needed. |
|
| 1090 |
+The `-a` flag tells `docker run` to bind to the container's `STDIN`, `STDOUT` or |
|
| 1091 |
+`STDERR`. This makes it possible to manipulate the output and input as needed. |
|
| 1092 | 1092 |
|
| 1093 | 1093 |
$ echo "test" | sudo docker run -i -a stdin ubuntu cat - |
| 1094 | 1094 |
|
| 1095 | 1095 |
This pipes data into a container and prints the container's ID by attaching |
| 1096 |
-only to the container'sstdin. |
|
| 1096 |
+only to the container's `STDIN`. |
|
| 1097 | 1097 |
|
| 1098 | 1098 |
$ sudo docker run -a stderr ubuntu echo test |
| 1099 | 1099 |
|
| 1100 |
-This isn't going to print anything unless there's an error because We've |
|
| 1101 |
-only attached to the stderr of the container. The container's logs still |
|
| 1102 |
- store what's been written to stderr and stdout. |
|
| 1100 |
+This isn't going to print anything unless there's an error because we've |
|
| 1101 |
+only attached to the `STDERR` of the container. The container's logs |
|
| 1102 |
+still store what's been written to `STDERR` and `STDOUT`. |
|
| 1103 | 1103 |
|
| 1104 | 1104 |
$ cat somefile | sudo docker run -i -a stdin mybuilder dobuild |
| 1105 | 1105 |
|
| ... | ... |
@@ -5,13 +5,13 @@ page_keywords: docker, run, configure, runtime |
| 5 | 5 |
# Docker Run Reference |
| 6 | 6 |
|
| 7 | 7 |
**Docker runs processes in isolated containers**. When an operator |
| 8 |
-executes `docker run`, she starts a process with its |
|
| 9 |
-own file system, its own networking, and its own isolated process tree. |
|
| 10 |
-The [*Image*](/terms/image/#image-def) which starts the process may |
|
| 11 |
-define defaults related to the binary to run, the networking to expose, |
|
| 12 |
-and more, but `docker run` gives final control to |
|
| 13 |
-the operator who starts the container from the image. That's the main |
|
| 14 |
-reason [*run*](/reference/commandline/cli/#cli-run) has more options than any |
|
| 8 |
+executes `docker run`, she starts a process with its own file system, |
|
| 9 |
+its own networking, and its own isolated process tree. The |
|
| 10 |
+[*Image*](/terms/image/#image-def) which starts the process may define |
|
| 11 |
+defaults related to the binary to run, the networking to expose, and |
|
| 12 |
+more, but `docker run` gives final control to the operator who starts |
|
| 13 |
+the container from the image. That's the main reason |
|
| 14 |
+[*run*](/reference/commandline/cli/#cli-run) has more options than any |
|
| 15 | 15 |
other `docker` command. |
| 16 | 16 |
|
| 17 | 17 |
## General Form |
| ... | ... |
@@ -36,10 +36,10 @@ The list of `[OPTIONS]` breaks down into two groups: |
| 36 | 36 |
2. Setting shared between operators and developers, where operators can |
| 37 | 37 |
override defaults developers set in images at build time. |
| 38 | 38 |
|
| 39 |
-Together, the `docker run [OPTIONS]` give complete |
|
| 40 |
-control over runtime behavior to the operator, allowing them to override |
|
| 41 |
-all defaults set by the developer during `docker build` |
|
| 42 |
-and nearly all the defaults set by the Docker runtime itself. |
|
| 39 |
+Together, the `docker run [OPTIONS]` give complete control over runtime |
|
| 40 |
+behavior to the operator, allowing them to override all defaults set by |
|
| 41 |
+the developer during `docker build` and nearly all the defaults set by |
|
| 42 |
+the Docker runtime itself. |
|
| 43 | 43 |
|
| 44 | 44 |
## Operator Exclusive Options |
| 45 | 45 |
|
| ... | ... |
@@ -54,10 +54,8 @@ following options. |
| 54 | 54 |
- [PID Equivalent](#pid-equivalent) |
| 55 | 55 |
- [Network Settings](#network-settings) |
| 56 | 56 |
- [Clean Up (--rm)](#clean-up-rm) |
| 57 |
- - [Runtime Constraints on CPU and |
|
| 58 |
- Memory](#runtime-constraints-on-cpu-and-memory) |
|
| 59 |
- - [Runtime Privilege and LXC |
|
| 60 |
- Configuration](#runtime-privilege-and-lxc-configuration) |
|
| 57 |
+ - [Runtime Constraints on CPU and Memory](#runtime-constraints-on-cpu-and-memory) |
|
| 58 |
+ - [Runtime Privilege and LXC Configuration](#runtime-privilege-and-lxc-configuration) |
|
| 61 | 59 |
|
| 62 | 60 |
## Detached vs Foreground |
| 63 | 61 |
|
| ... | ... |
@@ -78,28 +76,28 @@ container in the detached mode, then you cannot use the `--rm` option. |
| 78 | 78 |
|
| 79 | 79 |
### Foreground |
| 80 | 80 |
|
| 81 |
-In foreground mode (the default when `-d` is not specified), `docker run` |
|
| 82 |
-can start the process in the container and attach the console to the process's |
|
| 83 |
-standard input, output, and standard error. It can even pretend to be a TTY |
|
| 84 |
-(this is what most command line executables expect) and pass along signals. All |
|
| 85 |
-of that is configurable: |
|
| 81 |
+In foreground mode (the default when `-d` is not specified), `docker |
|
| 82 |
+run` can start the process in the container and attach the console to |
|
| 83 |
+the process's standard input, output, and standard error. It can even |
|
| 84 |
+pretend to be a TTY (this is what most command line executables expect) |
|
| 85 |
+and pass along signals. All of that is configurable: |
|
| 86 | 86 |
|
| 87 |
- -a=[] : Attach to ``stdin``, ``stdout`` and/or ``stderr`` |
|
| 87 |
+ -a=[] : Attach to `STDIN`, `STDOUT` and/or `STDERR` |
|
| 88 | 88 |
-t=false : Allocate a pseudo-tty |
| 89 | 89 |
--sig-proxy=true: Proxify all received signal to the process (even in non-tty mode) |
| 90 | 90 |
-i=false : Keep STDIN open even if not attached |
| 91 | 91 |
|
| 92 |
-If you do not specify `-a` then Docker will [attach everything (stdin,stdout,stderr)]( |
|
| 93 |
-https://github.com/dotcloud/docker/blob/ |
|
| 94 |
-75a7f4d90cde0295bcfb7213004abce8d4779b75/commands.go#L1797). You can specify to which |
|
| 95 |
-of the three standard streams (`stdin`, `stdout`, `stderr`) you'd like to connect |
|
| 96 |
-instead, as in: |
|
| 92 |
+If you do not specify `-a` then Docker will [attach all standard |
|
| 93 |
+streams]( https://github.com/dotcloud/docker/blob/ |
|
| 94 |
+75a7f4d90cde0295bcfb7213004abce8d4779b75/commands.go#L1797). You can |
|
| 95 |
+specify to which of the three standard streams (`STDIN`, `STDOUT`, |
|
| 96 |
+`STDERR`) you'd like to connect instead, as in: |
|
| 97 | 97 |
|
| 98 | 98 |
$ docker run -a stdin -a stdout -i -t ubuntu /bin/bash |
| 99 | 99 |
|
| 100 |
-For interactive processes (like a shell) you will typically want a tty as well as |
|
| 101 |
-persistent standard input (`stdin`), so you'll use `-i -t` together in most |
|
| 102 |
-interactive cases. |
|
| 100 |
+For interactive processes (like a shell) you will typically want a tty |
|
| 101 |
+as well as persistent standard input (`STDIN`), so you'll use `-i -t` |
|
| 102 |
+together in most interactive cases. |
|
| 103 | 103 |
|
| 104 | 104 |
## Container Identification |
| 105 | 105 |
|
| ... | ... |
@@ -113,19 +111,18 @@ The operator can identify a container in three ways: |
| 113 | 113 |
- Name ("evil_ptolemy")
|
| 114 | 114 |
|
| 115 | 115 |
The UUID identifiers come from the Docker daemon, and if you do not |
| 116 |
-assign a name to the container with `--name` then |
|
| 117 |
-the daemon will also generate a random string name too. The name can |
|
| 118 |
-become a handy way to add meaning to a container since you can use this |
|
| 119 |
-name when defining |
|
| 120 |
-[*links*](/userguide/dockerlinks/#working-with-links-names) |
|
| 121 |
-(or any other place you need to identify a container). This works for |
|
| 122 |
-both background and foreground Docker containers. |
|
| 116 |
+assign a name to the container with `--name` then the daemon will also |
|
| 117 |
+generate a random string name too. The name can become a handy way to |
|
| 118 |
+add meaning to a container since you can use this name when defining |
|
| 119 |
+[*links*](/userguide/dockerlinks/#working-with-links-names) (or any |
|
| 120 |
+other place you need to identify a container). This works for both |
|
| 121 |
+background and foreground Docker containers. |
|
| 123 | 122 |
|
| 124 |
-### PID Equivalent |
|
| 123 |
+### PID Equivalent |
|
| 125 | 124 |
|
| 126 |
-And finally, to help with automation, you can have Docker write the |
|
| 125 |
+Finally, to help with automation, you can have Docker write the |
|
| 127 | 126 |
container ID out to a file of your choosing. This is similar to how some |
| 128 |
-programs might write out their process ID to a file (you`ve seen them as |
|
| 127 |
+programs might write out their process ID to a file (you've seen them as |
|
| 129 | 128 |
PID files): |
| 130 | 129 |
|
| 131 | 130 |
--cidfile="": Write the container ID to the file |
| ... | ... |
@@ -141,14 +138,14 @@ PID files): |
| 141 | 141 |
|
| 142 | 142 |
By default, all containers have networking enabled and they can make any |
| 143 | 143 |
outgoing connections. The operator can completely disable networking |
| 144 |
-with `docker run --net none` which disables all incoming and |
|
| 145 |
-outgoing networking. In cases like this, you would perform I/O through |
|
| 146 |
-files or STDIN/STDOUT only. |
|
| 144 |
+with `docker run --net none` which disables all incoming and outgoing |
|
| 145 |
+networking. In cases like this, you would perform I/O through files or |
|
| 146 |
+`STDIN` and `STDOUT` only. |
|
| 147 | 147 |
|
| 148 | 148 |
Your container will use the same DNS servers as the host by default, but |
| 149 | 149 |
you can override this with `--dns`. |
| 150 | 150 |
|
| 151 |
-Supported networking modes are: |
|
| 151 |
+Supported networking modes are: |
|
| 152 | 152 |
|
| 153 | 153 |
* none - no networking in the container |
| 154 | 154 |
* bridge - (default) connect the container to the bridge via veth interfaces |
| ... | ... |
@@ -156,35 +153,40 @@ Supported networking modes are: |
| 156 | 156 |
* container - use another container's network stack |
| 157 | 157 |
|
| 158 | 158 |
#### Mode: none |
| 159 |
-With the networking mode set to `none` a container will not have a access to |
|
| 160 |
-any external routes. The container will still have a `loopback` interface |
|
| 161 |
-enabled in the container but it does not have any routes to external traffic. |
|
| 159 |
+ |
|
| 160 |
+With the networking mode set to `none` a container will not have a |
|
| 161 |
+access to any external routes. The container will still have a |
|
| 162 |
+`loopback` interface enabled in the container but it does not have any |
|
| 163 |
+routes to external traffic. |
|
| 162 | 164 |
|
| 163 | 165 |
#### Mode: bridge |
| 164 |
-With the networking mode set to `bridge` a container will use docker's default |
|
| 165 |
-networking setup. A bridge is setup on the host, commonly named `docker0`, |
|
| 166 |
-and a pair of veth interfaces will be created for the container. One side of |
|
| 167 |
-the veth pair will remain on the host attached to the bridge while the other |
|
| 168 |
-side of the pair will be placed inside the container's namespaces in addition |
|
| 169 |
-to the `loopback` interface. An IP address will be allocated for containers |
|
| 170 |
-on the bridge's network and trafic will be routed though this bridge to the |
|
| 171 |
-container. |
|
| 166 |
+ |
|
| 167 |
+With the networking mode set to `bridge` a container will use docker's |
|
| 168 |
+default networking setup. A bridge is setup on the host, commonly named |
|
| 169 |
+`docker0`, and a pair of `veth` interfaces will be created for the |
|
| 170 |
+container. One side of the `veth` pair will remain on the host attached |
|
| 171 |
+to the bridge while the other side of the pair will be placed inside the |
|
| 172 |
+container's namespaces in addition to the `loopback` interface. An IP |
|
| 173 |
+address will be allocated for containers on the bridge's network and |
|
| 174 |
+traffic will be routed though this bridge to the container. |
|
| 172 | 175 |
|
| 173 | 176 |
#### Mode: host |
| 177 |
+ |
|
| 174 | 178 |
With the networking mode set to `host` a container will share the host's |
| 175 |
-network stack and all interfaces from the host will be available to the |
|
| 176 |
-container. The container's hostname will match the hostname on the host |
|
| 177 |
-system. Publishing ports and linking to other containers will not work |
|
| 178 |
-when sharing the host's network stack. |
|
| 179 |
+network stack and all interfaces from the host will be available to the |
|
| 180 |
+container. The container's hostname will match the hostname on the host |
|
| 181 |
+system. Publishing ports and linking to other containers will not work |
|
| 182 |
+when sharing the host's network stack. |
|
| 179 | 183 |
|
| 180 | 184 |
#### Mode: container |
| 181 |
-With the networking mode set to `container` a container will share the |
|
| 182 |
-network stack of another container. The other container's name must be |
|
| 185 |
+ |
|
| 186 |
+With the networking mode set to `container` a container will share the |
|
| 187 |
+network stack of another container. The other container's name must be |
|
| 183 | 188 |
provided in the format of `--net container:<name|id>`. |
| 184 | 189 |
|
| 185 |
-Example running a redis container with redis binding to localhost then |
|
| 186 |
-running the redis-cli and connecting to the redis server over the |
|
| 187 |
-localhost interface. |
|
| 190 |
+Example running a Redis container with Redis binding to `localhost` then |
|
| 191 |
+running the `redis-cli` command and connecting to the Redis server over the |
|
| 192 |
+`localhost` interface. |
|
| 188 | 193 |
|
| 189 | 194 |
$ docker run -d --name redis example/redis --bind 127.0.0.1 |
| 190 | 195 |
$ # use the redis container's network stack to access localhost |
| ... | ... |
@@ -211,15 +213,14 @@ container: |
| 211 | 211 |
-c=0 : CPU shares (relative weight) |
| 212 | 212 |
|
| 213 | 213 |
The operator can constrain the memory available to a container easily |
| 214 |
-with `docker run -m`. If the host supports swap |
|
| 215 |
-memory, then the `-m` memory setting can be larger |
|
| 216 |
-than physical RAM. |
|
| 214 |
+with `docker run -m`. If the host supports swap memory, then the `-m` |
|
| 215 |
+memory setting can be larger than physical RAM. |
|
| 217 | 216 |
|
| 218 | 217 |
Similarly the operator can increase the priority of this container with |
| 219 |
-the `-c` option. By default, all containers run at |
|
| 220 |
-the same priority and get the same proportion of CPU cycles, but you can |
|
| 221 |
-tell the kernel to give more shares of CPU time to one or more |
|
| 222 |
-containers when you start them via Docker. |
|
| 218 |
+the `-c` option. By default, all containers run at the same priority and |
|
| 219 |
+get the same proportion of CPU cycles, but you can tell the kernel to |
|
| 220 |
+give more shares of CPU time to one or more containers when you start |
|
| 221 |
+them via Docker. |
|
| 223 | 222 |
|
| 224 | 223 |
## Runtime Privilege and LXC Configuration |
| 225 | 224 |
|
| ... | ... |
@@ -277,19 +278,20 @@ commandline: |
| 277 | 277 |
|
| 278 | 278 |
$ docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG...] |
| 279 | 279 |
|
| 280 |
-This command is optional because the person who created the `IMAGE` may have |
|
| 281 |
-already provided a default `COMMAND` using the Dockerfile `CMD`. As the |
|
| 282 |
-operator (the person running a container from the image), you can override that |
|
| 283 |
-`CMD` just by specifying a new `COMMAND`. |
|
| 280 |
+This command is optional because the person who created the `IMAGE` may |
|
| 281 |
+have already provided a default `COMMAND` using the Dockerfile `CMD` |
|
| 282 |
+instruction. As the operator (the person running a container from the |
|
| 283 |
+image), you can override that `CMD` instruction just by specifying a new |
|
| 284 |
+`COMMAND`. |
|
| 284 | 285 |
|
| 285 |
-If the image also specifies an `ENTRYPOINT` then the `CMD` or `COMMAND` get |
|
| 286 |
-appended as arguments to the `ENTRYPOINT`. |
|
| 286 |
+If the image also specifies an `ENTRYPOINT` then the `CMD` or `COMMAND` |
|
| 287 |
+get appended as arguments to the `ENTRYPOINT`. |
|
| 287 | 288 |
|
| 288 | 289 |
## ENTRYPOINT (Default Command to Execute at Runtime) |
| 289 | 290 |
|
| 290 | 291 |
--entrypoint="": Overwrite the default entrypoint set by the image |
| 291 | 292 |
|
| 292 |
-The ENTRYPOINT of an image is similar to a `COMMAND` because it |
|
| 293 |
+The `ENTRYPOINT` of an image is similar to a `COMMAND` because it |
|
| 293 | 294 |
specifies what executable to run when the container starts, but it is |
| 294 | 295 |
(purposely) more difficult to override. The `ENTRYPOINT` gives a |
| 295 | 296 |
container its default nature or behavior, so that when you set an |
| ... | ... |
@@ -310,10 +312,10 @@ or two examples of how to pass more parameters to that ENTRYPOINT: |
| 310 | 310 |
|
| 311 | 311 |
## EXPOSE (Incoming Ports) |
| 312 | 312 |
|
| 313 |
-The Dockerfile doesn't give much control over networking, only providing the |
|
| 314 |
-`EXPOSE` instruction to give a hint to the operator about what incoming ports |
|
| 315 |
-might provide services. The following options work with or override the |
|
| 316 |
-Dockerfile's exposed defaults: |
|
| 313 |
+The Dockerfile doesn't give much control over networking, only providing |
|
| 314 |
+the `EXPOSE` instruction to give a hint to the operator about what |
|
| 315 |
+incoming ports might provide services. The following options work with |
|
| 316 |
+or override the Dockerfile's exposed defaults: |
|
| 317 | 317 |
|
| 318 | 318 |
--expose=[]: Expose a port from the container |
| 319 | 319 |
without publishing it to your host |
| ... | ... |
@@ -324,34 +326,34 @@ Dockerfile's exposed defaults: |
| 324 | 324 |
(use 'docker port' to see the actual mapping) |
| 325 | 325 |
--link="" : Add link to another container (name:alias) |
| 326 | 326 |
|
| 327 |
-As mentioned previously, `EXPOSE` (and `--expose`) make a port available **in** |
|
| 328 |
-a container for incoming connections. The port number on the inside of the |
|
| 329 |
-container (where the service listens) does not need to be the same number as the |
|
| 330 |
-port exposed on the outside of the container (where clients connect), so inside |
|
| 331 |
-the container you might have an HTTP service listening on port 80 (and so you |
|
| 332 |
-`EXPOSE 80` in the Dockerfile), but outside the container the port might be |
|
| 333 |
-42800. |
|
| 327 |
+As mentioned previously, `EXPOSE` (and `--expose`) make a port available |
|
| 328 |
+**in** a container for incoming connections. The port number on the |
|
| 329 |
+inside of the container (where the service listens) does not need to be |
|
| 330 |
+the same number as the port exposed on the outside of the container |
|
| 331 |
+(where clients connect), so inside the container you might have an HTTP |
|
| 332 |
+service listening on port 80 (and so you `EXPOSE 80` in the Dockerfile), |
|
| 333 |
+but outside the container the port might be 42800. |
|
| 334 | 334 |
|
| 335 |
-To help a new client container reach the server container's internal port |
|
| 336 |
-operator `--expose`'d by the operator or `EXPOSE`'d by the developer, the |
|
| 337 |
-operator has three choices: start the server container with `-P` or `-p,` or |
|
| 338 |
-start the client container with `--link`. |
|
| 335 |
+To help a new client container reach the server container's internal |
|
| 336 |
+port operator `--expose`'d by the operator or `EXPOSE`'d by the |
|
| 337 |
+developer, the operator has three choices: start the server container |
|
| 338 |
+with `-P` or `-p,` or start the client container with `--link`. |
|
| 339 | 339 |
|
| 340 | 340 |
If the operator uses `-P` or `-p` then Docker will make the exposed port |
| 341 |
-accessible on the host and the ports will be available to any client that |
|
| 342 |
-can reach the host. To find the map between the host ports and the exposed |
|
| 343 |
-ports, use `docker port`) |
|
| 341 |
+accessible on the host and the ports will be available to any client |
|
| 342 |
+that can reach the host. To find the map between the host ports and the |
|
| 343 |
+exposed ports, use `docker port`) |
|
| 344 | 344 |
|
| 345 |
-If the operator uses `--link` when starting the new client container, then the |
|
| 346 |
-client container can access the exposed port via a private networking interface. |
|
| 347 |
-Docker will set some environment variables in the client container to help |
|
| 348 |
-indicate which interface and port to use. |
|
| 345 |
+If the operator uses `--link` when starting the new client container, |
|
| 346 |
+then the client container can access the exposed port via a private |
|
| 347 |
+networking interface. Docker will set some environment variables in the |
|
| 348 |
+client container to help indicate which interface and port to use. |
|
| 349 | 349 |
|
| 350 | 350 |
## ENV (Environment Variables) |
| 351 | 351 |
|
| 352 |
-The operator can **set any environment variable** in the container by using one |
|
| 353 |
-or more `-e` flags, even overriding those already defined by the developer with |
|
| 354 |
-a Dockerfile `ENV`: |
|
| 352 |
+The operator can **set any environment variable** in the container by |
|
| 353 |
+using one or more `-e` flags, even overriding those already defined by |
|
| 354 |
+the developer with a Dockerfile `ENV`: |
|
| 355 | 355 |
|
| 356 | 356 |
$ docker run -e "deep=purple" --rm ubuntu /bin/bash -c export |
| 357 | 357 |
declare -x HOME="/" |
| ... | ... |
@@ -420,18 +422,19 @@ mechanism to communicate with a linked container by its alias: |
| 420 | 420 |
If "container-dir" is missing, then docker creates a new volume. |
| 421 | 421 |
--volumes-from="": Mount all volumes from the given container(s) |
| 422 | 422 |
|
| 423 |
-The volumes commands are complex enough to have their own documentation in |
|
| 424 |
-section [*Share Directories via Volumes*](/userguide/dockervolumes/#volume-def). |
|
| 425 |
-A developer can define one or more `VOLUME's associated with an image, but only the |
|
| 426 |
-operator can give access from one container to another (or from a container to a |
|
| 423 |
+The volumes commands are complex enough to have their own documentation |
|
| 424 |
+in section [*Share Directories via |
|
| 425 |
+Volumes*](/userguide/dockervolumes/#volume-def). A developer can define |
|
| 426 |
+one or more `VOLUME`'s associated with an image, but only the operator |
|
| 427 |
+can give access from one container to another (or from a container to a |
|
| 427 | 428 |
volume mounted on the host). |
| 428 | 429 |
|
| 429 | 430 |
## USER |
| 430 | 431 |
|
| 431 |
-The default user within a container is `root` (id = 0), but if the developer |
|
| 432 |
-created additional users, those are accessible too. The developer can set a |
|
| 433 |
-default user to run the first process with the `Dockerfile USER` command, |
|
| 434 |
-but the operator can override it: |
|
| 432 |
+The default user within a container is `root` (id = 0), but if the |
|
| 433 |
+developer created additional users, those are accessible too. The |
|
| 434 |
+developer can set a default user to run the first process with the |
|
| 435 |
+Dockerfile `USER` instruction, but the operator can override it: |
|
| 435 | 436 |
|
| 436 | 437 |
-u="": Username or UID |
| 437 | 438 |
|