Signed-off-by: Mary Anthony <mary@docker.com>
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,91 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "attach" |
|
| 2 |
+description = "The attach command description and usage" |
|
| 3 |
+keywords = ["attach, running, container"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# attach |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker attach [OPTIONS] CONTAINER |
|
| 12 |
+ |
|
| 13 |
+ Attach to a running container |
|
| 14 |
+ |
|
| 15 |
+ --no-stdin=false Do not attach STDIN |
|
| 16 |
+ --sig-proxy=true Proxy all received signals to the process |
|
| 17 |
+ |
|
| 18 |
+The `docker attach` command allows you to attach to a running container using |
|
| 19 |
+the container's ID or name, either to view its ongoing output or to control it |
|
| 20 |
+interactively. You can attach to the same contained process multiple times |
|
| 21 |
+simultaneously, screen sharing style, or quickly view the progress of your |
|
| 22 |
+daemonized process. |
|
| 23 |
+ |
|
| 24 |
+You can detach from the container and leave it running with `CTRL-p CTRL-q` |
|
| 25 |
+(for a quiet exit) or with `CTRL-c` if `--sig-proxy` is false. |
|
| 26 |
+ |
|
| 27 |
+If `--sig-proxy` is true (the default),`CTRL-c` sends a `SIGINT` to the |
|
| 28 |
+container. |
|
| 29 |
+ |
|
| 30 |
+> **Note:** |
|
| 31 |
+> A process running as PID 1 inside a container is treated specially by |
|
| 32 |
+> Linux: it ignores any signal with the default action. So, the process |
|
| 33 |
+> will not terminate on `SIGINT` or `SIGTERM` unless it is coded to do |
|
| 34 |
+> so. |
|
| 35 |
+ |
|
| 36 |
+It is forbidden to redirect the standard input of a `docker attach` command |
|
| 37 |
+while attaching to a tty-enabled container (i.e.: launched with `-t`). |
|
| 38 |
+ |
|
| 39 |
+#### Examples |
|
| 40 |
+ |
|
| 41 |
+ $ docker run -d --name topdemo ubuntu /usr/bin/top -b |
|
| 42 |
+ $ docker attach topdemo |
|
| 43 |
+ top - 02:05:52 up 3:05, 0 users, load average: 0.01, 0.02, 0.05 |
|
| 44 |
+ Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie |
|
| 45 |
+ Cpu(s): 0.1%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st |
|
| 46 |
+ Mem: 373572k total, 355560k used, 18012k free, 27872k buffers |
|
| 47 |
+ Swap: 786428k total, 0k used, 786428k free, 221740k cached |
|
| 48 |
+ |
|
| 49 |
+ PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND |
|
| 50 |
+ 1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top |
|
| 51 |
+ |
|
| 52 |
+ top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05 |
|
| 53 |
+ Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie |
|
| 54 |
+ Cpu(s): 0.0%us, 0.2%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st |
|
| 55 |
+ Mem: 373572k total, 355244k used, 18328k free, 27872k buffers |
|
| 56 |
+ Swap: 786428k total, 0k used, 786428k free, 221776k cached |
|
| 57 |
+ |
|
| 58 |
+ PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND |
|
| 59 |
+ 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top |
|
| 60 |
+ |
|
| 61 |
+ |
|
| 62 |
+ top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05 |
|
| 63 |
+ Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie |
|
| 64 |
+ Cpu(s): 0.2%us, 0.3%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st |
|
| 65 |
+ Mem: 373572k total, 355780k used, 17792k free, 27880k buffers |
|
| 66 |
+ Swap: 786428k total, 0k used, 786428k free, 221776k cached |
|
| 67 |
+ |
|
| 68 |
+ PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND |
|
| 69 |
+ 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top |
|
| 70 |
+ ^C$ |
|
| 71 |
+ $ echo $? |
|
| 72 |
+ 0 |
|
| 73 |
+ $ docker ps -a | grep topdemo |
|
| 74 |
+ 7998ac8581f9 ubuntu:14.04 "/usr/bin/top -b" 38 seconds ago Exited (0) 21 seconds ago topdemo |
|
| 75 |
+ |
|
| 76 |
+And in this second example, you can see the exit code returned by the `bash` |
|
| 77 |
+process is returned by the `docker attach` command to its caller too: |
|
| 78 |
+ |
|
| 79 |
+ $ docker run --name test -d -it debian |
|
| 80 |
+ 275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab |
|
| 81 |
+ $ docker attach test |
|
| 82 |
+ $$ exit 13 |
|
| 83 |
+ exit |
|
| 84 |
+ $ echo $? |
|
| 85 |
+ 13 |
|
| 86 |
+ $ docker ps -a | grep test |
|
| 87 |
+ 275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test |
|
| 88 |
+ |
| 0 | 89 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,249 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "build" |
|
| 2 |
+description = "The build command description and usage" |
|
| 3 |
+keywords = ["build, docker, image"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# build |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker build [OPTIONS] PATH | URL | - |
|
| 12 |
+ |
|
| 13 |
+ Build a new image from the source code at PATH |
|
| 14 |
+ |
|
| 15 |
+ -f, --file="" Name of the Dockerfile (Default is 'PATH/Dockerfile') |
|
| 16 |
+ --force-rm=false Always remove intermediate containers |
|
| 17 |
+ --no-cache=false Do not use cache when building the image |
|
| 18 |
+ --pull=false Always attempt to pull a newer version of the image |
|
| 19 |
+ -q, --quiet=false Suppress the verbose output generated by the containers |
|
| 20 |
+ --rm=true Remove intermediate containers after a successful build |
|
| 21 |
+ -t, --tag="" Repository name (and optionally a tag) for the image |
|
| 22 |
+ -m, --memory="" Memory limit for all build containers |
|
| 23 |
+ --memory-swap="" Total memory (memory + swap), `-1` to disable swap |
|
| 24 |
+ -c, --cpu-shares CPU Shares (relative weight) |
|
| 25 |
+ --cpuset-mems="" MEMs in which to allow execution, e.g. `0-3`, `0,1` |
|
| 26 |
+ --cpuset-cpus="" CPUs in which to allow execution, e.g. `0-3`, `0,1` |
|
| 27 |
+ --cgroup-parent="" Optional parent cgroup for the container |
|
| 28 |
+ |
|
| 29 |
+Builds Docker images from a Dockerfile and a "context". A build's context is |
|
| 30 |
+the files located in the specified `PATH` or `URL`. The build process can refer |
|
| 31 |
+to any of the files in the context. For example, your build can use an |
|
| 32 |
+[*ADD*](/reference/builder/#add) instruction to reference a file in the |
|
| 33 |
+context. |
|
| 34 |
+ |
|
| 35 |
+The `URL` parameter can specify the location of a Git repository; the repository |
|
| 36 |
+acts as the build context. The system recursively clones the repository and its |
|
| 37 |
+submodules using a `git clone --depth 1 --recursive` command. This command runs |
|
| 38 |
+in a temporary directory on your local host. After the command succeeds, the |
|
| 39 |
+directory is sent to the Docker daemon as the context. Local clones give you the |
|
| 40 |
+ability to access private repositories using local user credentials, VPNs, and |
|
| 41 |
+so forth. |
|
| 42 |
+ |
|
| 43 |
+Git URLs accept context configuration in their fragment section, separated by a |
|
| 44 |
+colon `:`. The first part represents the reference that Git will check out, |
|
| 45 |
+this can be either a branch, a tag, or a commit SHA. The second part represents |
|
| 46 |
+a subdirectory inside the repository that will be used as a build context. |
|
| 47 |
+ |
|
| 48 |
+For example, run this command to use a directory called `docker` in the branch |
|
| 49 |
+`container`: |
|
| 50 |
+ |
|
| 51 |
+ $ docker build https://github.com/docker/rootfs.git#container:docker |
|
| 52 |
+ |
|
| 53 |
+The following table represents all the valid suffixes with their build |
|
| 54 |
+contexts: |
|
| 55 |
+ |
|
| 56 |
+Build Syntax Suffix | Commit Used | Build Context Used |
|
| 57 |
+--------------------|-------------|------------------- |
|
| 58 |
+`myrepo.git` | `refs/heads/master` | `/` |
|
| 59 |
+`myrepo.git#mytag` | `refs/tags/mytag` | `/` |
|
| 60 |
+`myrepo.git#mybranch` | `refs/heads/mybranch` | `/` |
|
| 61 |
+`myrepo.git#abcdef` | `sha1 = abcdef` | `/` |
|
| 62 |
+`myrepo.git#:myfolder` | `refs/heads/master` | `/myfolder` |
|
| 63 |
+`myrepo.git#master:myfolder` | `refs/heads/master` | `/myfolder` |
|
| 64 |
+`myrepo.git#mytag:myfolder` | `refs/tags/mytag` | `/myfolder` |
|
| 65 |
+`myrepo.git#mybranch:myfolder` | `refs/heads/mybranch` | `/myfolder` |
|
| 66 |
+`myrepo.git#abcdef:myfolder` | `sha1 = abcdef` | `/myfolder` |
|
| 67 |
+ |
|
| 68 |
+Instead of specifying a context, you can pass a single Dockerfile in the `URL` |
|
| 69 |
+or pipe the file in via `STDIN`. To pipe a Dockerfile from `STDIN`: |
|
| 70 |
+ |
|
| 71 |
+ docker build - < Dockerfile |
|
| 72 |
+ |
|
| 73 |
+If you use STDIN or specify a `URL`, the system places the contents into a file |
|
| 74 |
+called `Dockerfile`, and any `-f`, `--file` option is ignored. In this |
|
| 75 |
+scenario, there is no context. |
|
| 76 |
+ |
|
| 77 |
+By default the `docker build` command will look for a `Dockerfile` at the root |
|
| 78 |
+of the build context. The `-f`, `--file`, option lets you specify the path to |
|
| 79 |
+an alternative file to use instead. This is useful in cases where the same set |
|
| 80 |
+of files are used for multiple builds. The path must be to a file within the |
|
| 81 |
+build context. If a relative path is specified then it must to be relative to |
|
| 82 |
+the current directory. |
|
| 83 |
+ |
|
| 84 |
+In most cases, it's best to put each Dockerfile in an empty directory. Then, |
|
| 85 |
+add to that directory only the files needed for building the Dockerfile. To |
|
| 86 |
+increase the build's performance, you can exclude files and directories by |
|
| 87 |
+adding a `.dockerignore` file to that directory as well. For information on |
|
| 88 |
+creating one, see the [.dockerignore file](/reference/builder#dockerignore-file). |
|
| 89 |
+ |
|
| 90 |
+If the Docker client loses connection to the daemon, the build is canceled. |
|
| 91 |
+This happens if you interrupt the Docker client with `ctrl-c` or if the Docker |
|
| 92 |
+client is killed for any reason. |
|
| 93 |
+ |
|
| 94 |
+> **Note:** |
|
| 95 |
+> Currently only the "run" phase of the build can be canceled until pull |
|
| 96 |
+> cancellation is implemented). |
|
| 97 |
+ |
|
| 98 |
+## Return code |
|
| 99 |
+ |
|
| 100 |
+On a successful build, a return code of success `0` will be returned. When the |
|
| 101 |
+build fails, a non-zero failure code will be returned. |
|
| 102 |
+ |
|
| 103 |
+There should be informational output of the reason for failure output to |
|
| 104 |
+`STDERR`: |
|
| 105 |
+ |
|
| 106 |
+ $ docker build -t fail . |
|
| 107 |
+ Sending build context to Docker daemon 2.048 kB |
|
| 108 |
+ Sending build context to Docker daemon |
|
| 109 |
+ Step 0 : FROM busybox |
|
| 110 |
+ ---> 4986bf8c1536 |
|
| 111 |
+ Step 1 : RUN exit 13 |
|
| 112 |
+ ---> Running in e26670ec7a0a |
|
| 113 |
+ INFO[0000] The command [/bin/sh -c exit 13] returned a non-zero code: 13 |
|
| 114 |
+ $ echo $? |
|
| 115 |
+ 1 |
|
| 116 |
+ |
|
| 117 |
+See also: |
|
| 118 |
+ |
|
| 119 |
+[*Dockerfile Reference*](/reference/builder). |
|
| 120 |
+ |
|
| 121 |
+## Examples |
|
| 122 |
+ |
|
| 123 |
+ $ docker build . |
|
| 124 |
+ Uploading context 10240 bytes |
|
| 125 |
+ Step 1 : FROM busybox |
|
| 126 |
+ Pulling repository busybox |
|
| 127 |
+ ---> e9aa60c60128MB/2.284 MB (100%) endpoint: https://cdn-registry-1.docker.io/v1/ |
|
| 128 |
+ Step 2 : RUN ls -lh / |
|
| 129 |
+ ---> Running in 9c9e81692ae9 |
|
| 130 |
+ total 24 |
|
| 131 |
+ drwxr-xr-x 2 root root 4.0K Mar 12 2013 bin |
|
| 132 |
+ drwxr-xr-x 5 root root 4.0K Oct 19 00:19 dev |
|
| 133 |
+ drwxr-xr-x 2 root root 4.0K Oct 19 00:19 etc |
|
| 134 |
+ drwxr-xr-x 2 root root 4.0K Nov 15 23:34 lib |
|
| 135 |
+ lrwxrwxrwx 1 root root 3 Mar 12 2013 lib64 -> lib |
|
| 136 |
+ dr-xr-xr-x 116 root root 0 Nov 15 23:34 proc |
|
| 137 |
+ lrwxrwxrwx 1 root root 3 Mar 12 2013 sbin -> bin |
|
| 138 |
+ dr-xr-xr-x 13 root root 0 Nov 15 23:34 sys |
|
| 139 |
+ drwxr-xr-x 2 root root 4.0K Mar 12 2013 tmp |
|
| 140 |
+ drwxr-xr-x 2 root root 4.0K Nov 15 23:34 usr |
|
| 141 |
+ ---> b35f4035db3f |
|
| 142 |
+ Step 3 : CMD echo Hello world |
|
| 143 |
+ ---> Running in 02071fceb21b |
|
| 144 |
+ ---> f52f38b7823e |
|
| 145 |
+ Successfully built f52f38b7823e |
|
| 146 |
+ Removing intermediate container 9c9e81692ae9 |
|
| 147 |
+ Removing intermediate container 02071fceb21b |
|
| 148 |
+ |
|
| 149 |
+This example specifies that the `PATH` is `.`, and so all the files in the |
|
| 150 |
+local directory get `tar`d and sent to the Docker daemon. The `PATH` specifies |
|
| 151 |
+where to find the files for the "context" of the build on the Docker daemon. |
|
| 152 |
+Remember that the daemon could be running on a remote machine and that no |
|
| 153 |
+parsing of the Dockerfile happens at the client side (where you're running |
|
| 154 |
+`docker build`). That means that *all* the files at `PATH` get sent, not just |
|
| 155 |
+the ones listed to [*ADD*](/reference/builder/#add) in the Dockerfile. |
|
| 156 |
+ |
|
| 157 |
+The transfer of context from the local machine to the Docker daemon is what the |
|
| 158 |
+`docker` client means when you see the "Sending build context" message. |
|
| 159 |
+ |
|
| 160 |
+If you wish to keep the intermediate containers after the build is complete, |
|
| 161 |
+you must use `--rm=false`. This does not affect the build cache. |
|
| 162 |
+ |
|
| 163 |
+ $ docker build . |
|
| 164 |
+ Uploading context 18.829 MB |
|
| 165 |
+ Uploading context |
|
| 166 |
+ Step 0 : FROM busybox |
|
| 167 |
+ ---> 769b9341d937 |
|
| 168 |
+ Step 1 : CMD echo Hello world |
|
| 169 |
+ ---> Using cache |
|
| 170 |
+ ---> 99cc1ad10469 |
|
| 171 |
+ Successfully built 99cc1ad10469 |
|
| 172 |
+ $ echo ".git" > .dockerignore |
|
| 173 |
+ $ docker build . |
|
| 174 |
+ Uploading context 6.76 MB |
|
| 175 |
+ Uploading context |
|
| 176 |
+ Step 0 : FROM busybox |
|
| 177 |
+ ---> 769b9341d937 |
|
| 178 |
+ Step 1 : CMD echo Hello world |
|
| 179 |
+ ---> Using cache |
|
| 180 |
+ ---> 99cc1ad10469 |
|
| 181 |
+ Successfully built 99cc1ad10469 |
|
| 182 |
+ |
|
| 183 |
+This example shows the use of the `.dockerignore` file to exclude the `.git` |
|
| 184 |
+directory from the context. Its effect can be seen in the changed size of the |
|
| 185 |
+uploaded context. The builder reference contains detailed information on |
|
| 186 |
+[creating a .dockerignore file](../../builder/#dockerignore-file) |
|
| 187 |
+ |
|
| 188 |
+ $ docker build -t vieux/apache:2.0 . |
|
| 189 |
+ |
|
| 190 |
+This will build like the previous example, but it will then tag the resulting |
|
| 191 |
+image. The repository name will be `vieux/apache` and the tag will be `2.0` |
|
| 192 |
+ |
|
| 193 |
+ $ docker build - < Dockerfile |
|
| 194 |
+ |
|
| 195 |
+This will read a Dockerfile from `STDIN` without context. Due to the lack of a |
|
| 196 |
+context, no contents of any local directory will be sent to the Docker daemon. |
|
| 197 |
+Since there is no context, a Dockerfile `ADD` only works if it refers to a |
|
| 198 |
+remote URL. |
|
| 199 |
+ |
|
| 200 |
+ $ docker build - < context.tar.gz |
|
| 201 |
+ |
|
| 202 |
+This will build an image for a compressed context read from `STDIN`. Supported |
|
| 203 |
+formats are: bzip2, gzip and xz. |
|
| 204 |
+ |
|
| 205 |
+ $ docker build github.com/creack/docker-firefox |
|
| 206 |
+ |
|
| 207 |
+This will clone the GitHub repository and use the cloned repository as context. |
|
| 208 |
+The Dockerfile at the root of the repository is used as Dockerfile. Note that |
|
| 209 |
+you can specify an arbitrary Git repository by using the `git://` or `git@` |
|
| 210 |
+schema. |
|
| 211 |
+ |
|
| 212 |
+ $ docker build -f Dockerfile.debug . |
|
| 213 |
+ |
|
| 214 |
+This will use a file called `Dockerfile.debug` for the build instructions |
|
| 215 |
+instead of `Dockerfile`. |
|
| 216 |
+ |
|
| 217 |
+ $ docker build -f dockerfiles/Dockerfile.debug -t myapp_debug . |
|
| 218 |
+ $ docker build -f dockerfiles/Dockerfile.prod -t myapp_prod . |
|
| 219 |
+ |
|
| 220 |
+The above commands will build the current build context (as specified by the |
|
| 221 |
+`.`) twice, once using a debug version of a `Dockerfile` and once using a |
|
| 222 |
+production version. |
|
| 223 |
+ |
|
| 224 |
+ $ cd /home/me/myapp/some/dir/really/deep |
|
| 225 |
+ $ docker build -f /home/me/myapp/dockerfiles/debug /home/me/myapp |
|
| 226 |
+ $ docker build -f ../../../../dockerfiles/debug /home/me/myapp |
|
| 227 |
+ |
|
| 228 |
+These two `docker build` commands do the exact same thing. They both use the |
|
| 229 |
+contents of the `debug` file instead of looking for a `Dockerfile` and will use |
|
| 230 |
+`/home/me/myapp` as the root of the build context. Note that `debug` is in the |
|
| 231 |
+directory structure of the build context, regardless of how you refer to it on |
|
| 232 |
+the command line. |
|
| 233 |
+ |
|
| 234 |
+> **Note:** |
|
| 235 |
+> `docker build` will return a `no such file or directory` error if the |
|
| 236 |
+> file or directory does not exist in the uploaded context. This may |
|
| 237 |
+> happen if there is no context, or if you specify a file that is |
|
| 238 |
+> elsewhere on the Host system. The context is limited to the current |
|
| 239 |
+> directory (and its children) for security reasons, and to ensure |
|
| 240 |
+> repeatable builds on remote Docker hosts. This is also the reason why |
|
| 241 |
+> `ADD ../file` will not work. |
|
| 242 |
+ |
|
| 243 |
+When `docker build` is run with the `--cgroup-parent` option the containers |
|
| 244 |
+used in the build will be run with the [corresponding `docker run` |
|
| 245 |
+flag](/reference/run/#specifying-custom-cgroups). |
|
| 246 |
+ |
| ... | ... |
@@ -1,14 +1,14 @@ |
| 1 | 1 |
<!--[metadata]> |
| 2 | 2 |
+++ |
| 3 |
-title = "Command Line Interface" |
|
| 3 |
+title = "Using the command line" |
|
| 4 | 4 |
description = "Docker's CLI command description and usage" |
| 5 | 5 |
keywords = ["Docker, Docker documentation, CLI, command line"] |
| 6 | 6 |
[menu.main] |
| 7 |
-parent = "mn_reference" |
|
| 7 |
+parent = "smn_cli" |
|
| 8 | 8 |
+++ |
| 9 | 9 |
<![end-metadata]--> |
| 10 | 10 |
|
| 11 |
-# Docker Command Line |
|
| 11 |
+# Using the command line |
|
| 12 | 12 |
|
| 13 | 13 |
> **Note:** if you are using a remote Docker daemon, such as Boot2Docker, |
| 14 | 14 |
> then _do not_ type the `sudo` before the `docker` commands shown in the |
| ... | ... |
@@ -146,2504 +146,3 @@ Sometimes, multiple options can call for a more complex value string as for |
| 146 | 146 |
Options like `--name=""` expect a string, and they |
| 147 | 147 |
can only be specified once. Options like `-c=0` |
| 148 | 148 |
expect an integer, and they can only be specified once. |
| 149 |
- |
|
| 150 |
-## daemon |
|
| 151 |
- |
|
| 152 |
- Usage: docker [OPTIONS] COMMAND [arg...] |
|
| 153 |
- |
|
| 154 |
- A self-sufficient runtime for linux containers. |
|
| 155 |
- |
|
| 156 |
- Options: |
|
| 157 |
- --api-cors-header="" Set CORS headers in the remote API |
|
| 158 |
- -b, --bridge="" Attach containers to a network bridge |
|
| 159 |
- --bip="" Specify network bridge IP |
|
| 160 |
- -D, --debug=false Enable debug mode |
|
| 161 |
- -d, --daemon=false Enable daemon mode |
|
| 162 |
- --default-gateway="" Container default gateway IPv4 address |
|
| 163 |
- --default-gateway-v6="" Container default gateway IPv6 address |
|
| 164 |
- --dns=[] DNS server to use |
|
| 165 |
- --dns-search=[] DNS search domains to use |
|
| 166 |
- --default-ulimit=[] Set default ulimit settings for containers |
|
| 167 |
- -e, --exec-driver="native" Exec driver to use |
|
| 168 |
- --exec-opt=[] Set exec driver options |
|
| 169 |
- --exec-root="/var/run/docker" Root of the Docker execdriver |
|
| 170 |
- --fixed-cidr="" IPv4 subnet for fixed IPs |
|
| 171 |
- --fixed-cidr-v6="" IPv6 subnet for fixed IPs |
|
| 172 |
- -G, --group="docker" Group for the unix socket |
|
| 173 |
- -g, --graph="/var/lib/docker" Root of the Docker runtime |
|
| 174 |
- -H, --host=[] Daemon socket(s) to connect to |
|
| 175 |
- -h, --help=false Print usage |
|
| 176 |
- --icc=true Enable inter-container communication |
|
| 177 |
- --insecure-registry=[] Enable insecure registry communication |
|
| 178 |
- --ip=0.0.0.0 Default IP when binding container ports |
|
| 179 |
- --ip-forward=true Enable net.ipv4.ip_forward |
|
| 180 |
- --ip-masq=true Enable IP masquerading |
|
| 181 |
- --iptables=true Enable addition of iptables rules |
|
| 182 |
- --ipv6=false Enable IPv6 networking |
|
| 183 |
- -l, --log-level="info" Set the logging level |
|
| 184 |
- --label=[] Set key=value labels to the daemon |
|
| 185 |
- --log-driver="json-file" Default driver for container logs |
|
| 186 |
- --log-opt=[] Log driver specific options |
|
| 187 |
- --mtu=0 Set the containers network MTU |
|
| 188 |
- -p, --pidfile="/var/run/docker.pid" Path to use for daemon PID file |
|
| 189 |
- --registry-mirror=[] Preferred Docker registry mirror |
|
| 190 |
- -s, --storage-driver="" Storage driver to use |
|
| 191 |
- --selinux-enabled=false Enable selinux support |
|
| 192 |
- --storage-opt=[] Set storage driver options |
|
| 193 |
- --tls=false Use TLS; implied by --tlsverify |
|
| 194 |
- --tlscacert="~/.docker/ca.pem" Trust certs signed only by this CA |
|
| 195 |
- --tlscert="~/.docker/cert.pem" Path to TLS certificate file |
|
| 196 |
- --tlskey="~/.docker/key.pem" Path to TLS key file |
|
| 197 |
- --tlsverify=false Use TLS and verify the remote |
|
| 198 |
- --userland-proxy=true Use userland proxy for loopback traffic |
|
| 199 |
- -v, --version=false Print version information and quit |
|
| 200 |
- |
|
| 201 |
-Options with [] may be specified multiple times. |
|
| 202 |
- |
|
| 203 |
-The Docker daemon is the persistent process that manages containers. Docker |
|
| 204 |
-uses the same binary for both the daemon and client. To run the daemon you |
|
| 205 |
-provide the `-d` flag. |
|
| 206 |
- |
|
| 207 |
-To run the daemon with debug output, use `docker -d -D`. |
|
| 208 |
- |
|
| 209 |
-### Daemon socket option |
|
| 210 |
- |
|
| 211 |
-The Docker daemon can listen for [Docker Remote API](/reference/api/docker_remote_api/) |
|
| 212 |
-requests via three different types of Socket: `unix`, `tcp`, and `fd`. |
|
| 213 |
- |
|
| 214 |
-By default, a `unix` domain socket (or IPC socket) is created at |
|
| 215 |
-`/var/run/docker.sock`, requiring either `root` permission, or `docker` group |
|
| 216 |
-membership. |
|
| 217 |
- |
|
| 218 |
-If you need to access the Docker daemon remotely, you need to enable the `tcp` |
|
| 219 |
-Socket. Beware that the default setup provides un-encrypted and |
|
| 220 |
-un-authenticated direct access to the Docker daemon - and should be secured |
|
| 221 |
-either using the [built in HTTPS encrypted socket](/articles/https/), or by |
|
| 222 |
-putting a secure web proxy in front of it. You can listen on port `2375` on all |
|
| 223 |
-network interfaces with `-H tcp://0.0.0.0:2375`, or on a particular network |
|
| 224 |
-interface using its IP address: `-H tcp://192.168.59.103:2375`. It is |
|
| 225 |
-conventional to use port `2375` for un-encrypted, and port `2376` for encrypted |
|
| 226 |
-communication with the daemon. |
|
| 227 |
- |
|
| 228 |
-> **Note:** |
|
| 229 |
-> If you're using an HTTPS encrypted socket, keep in mind that only |
|
| 230 |
-> TLS1.0 and greater are supported. Protocols SSLv3 and under are not |
|
| 231 |
-> supported anymore for security reasons. |
|
| 232 |
- |
|
| 233 |
-On Systemd based systems, you can communicate with the daemon via |
|
| 234 |
-[Systemd socket activation](http://0pointer.de/blog/projects/socket-activation.html), |
|
| 235 |
-use `docker -d -H fd://`. Using `fd://` will work perfectly for most setups but |
|
| 236 |
-you can also specify individual sockets: `docker -d -H fd://3`. If the |
|
| 237 |
-specified socket activated files aren't found, then Docker will exit. You can |
|
| 238 |
-find examples of using Systemd socket activation with Docker and Systemd in the |
|
| 239 |
-[Docker source tree](https://github.com/docker/docker/tree/master/contrib/init/systemd/). |
|
| 240 |
- |
|
| 241 |
-You can configure the Docker daemon to listen to multiple sockets at the same |
|
| 242 |
-time using multiple `-H` options: |
|
| 243 |
- |
|
| 244 |
- # listen using the default unix socket, and on 2 specific IP addresses on this host. |
|
| 245 |
- docker -d -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2 |
|
| 246 |
- |
|
| 247 |
-The Docker client will honor the `DOCKER_HOST` environment variable to set the |
|
| 248 |
-`-H` flag for the client. |
|
| 249 |
- |
|
| 250 |
- $ docker -H tcp://0.0.0.0:2375 ps |
|
| 251 |
- # or |
|
| 252 |
- $ export DOCKER_HOST="tcp://0.0.0.0:2375" |
|
| 253 |
- $ docker ps |
|
| 254 |
- # both are equal |
|
| 255 |
- |
|
| 256 |
-Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than |
|
| 257 |
-the empty string is equivalent to setting the `--tlsverify` flag. The following |
|
| 258 |
-are equivalent: |
|
| 259 |
- |
|
| 260 |
- $ docker --tlsverify ps |
|
| 261 |
- # or |
|
| 262 |
- $ export DOCKER_TLS_VERIFY=1 |
|
| 263 |
- $ docker ps |
|
| 264 |
- |
|
| 265 |
-The Docker client will honor the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` |
|
| 266 |
-environment variables (or the lowercase versions thereof). `HTTPS_PROXY` takes |
|
| 267 |
-precedence over `HTTP_PROXY`. |
|
| 268 |
- |
|
| 269 |
-### Daemon storage-driver option |
|
| 270 |
- |
|
| 271 |
-The Docker daemon has support for several different image layer storage |
|
| 272 |
-drivers: `aufs`, `devicemapper`, `btrfs`, `zfs` and `overlay`. |
|
| 273 |
- |
|
| 274 |
-The `aufs` driver is the oldest, but is based on a Linux kernel patch-set that |
|
| 275 |
-is unlikely to be merged into the main kernel. These are also known to cause |
|
| 276 |
-some serious kernel crashes. However, `aufs` is also the only storage driver |
|
| 277 |
-that allows containers to share executable and shared library memory, so is a |
|
| 278 |
-useful choice when running thousands of containers with the same program or |
|
| 279 |
-libraries. |
|
| 280 |
- |
|
| 281 |
-The `devicemapper` driver uses thin provisioning and Copy on Write (CoW) |
|
| 282 |
-snapshots. For each devicemapper graph location – typically |
|
| 283 |
-`/var/lib/docker/devicemapper` – a thin pool is created based on two block |
|
| 284 |
-devices, one for data and one for metadata. By default, these block devices |
|
| 285 |
-are created automatically by using loopback mounts of automatically created |
|
| 286 |
-sparse files. Refer to [Storage driver options](#storage-driver-options) below |
|
| 287 |
-for a way how to customize this setup. |
|
| 288 |
-[~jpetazzo/Resizing Docker containers with the Device Mapper plugin](http://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/) |
|
| 289 |
-article explains how to tune your existing setup without the use of options. |
|
| 290 |
- |
|
| 291 |
-The `btrfs` driver is very fast for `docker build` - but like `devicemapper` |
|
| 292 |
-does not share executable memory between devices. Use |
|
| 293 |
-`docker -d -s btrfs -g /mnt/btrfs_partition`. |
|
| 294 |
- |
|
| 295 |
-The `zfs` driver is probably not fast as `btrfs` but has a longer track record |
|
| 296 |
-on stability. Thanks to `Single Copy ARC` shared blocks between clones will be |
|
| 297 |
-cached only once. Use `docker -d -s zfs`. To select a different zfs filesystem |
|
| 298 |
-set `zfs.fsname` option as described in [Storage driver options](#storage-driver-options). |
|
| 299 |
- |
|
| 300 |
-The `overlay` is a very fast union filesystem. It is now merged in the main |
|
| 301 |
-Linux kernel as of [3.18.0](https://lkml.org/lkml/2014/10/26/137). Call |
|
| 302 |
-`docker -d -s overlay` to use it. |
|
| 303 |
- |
|
| 304 |
-> **Note:** |
|
| 305 |
-> As promising as `overlay` is, the feature is still quite young and should not |
|
| 306 |
-> be used in production. Most notably, using `overlay` can cause excessive |
|
| 307 |
-> inode consumption (especially as the number of images grows), as well as |
|
| 308 |
-> being incompatible with the use of RPMs. |
|
| 309 |
- |
|
| 310 |
-> **Note:** |
|
| 311 |
-> It is currently unsupported on `btrfs` or any Copy on Write filesystem |
|
| 312 |
-> and should only be used over `ext4` partitions. |
|
| 313 |
- |
|
| 314 |
-#### Storage driver options |
|
| 315 |
- |
|
| 316 |
-Particular storage-driver can be configured with options specified with |
|
| 317 |
-`--storage-opt` flags. Options for `devicemapper` are prefixed with `dm` and |
|
| 318 |
-options for `zfs` start with `zfs`. |
|
| 319 |
- |
|
| 320 |
-Currently supported options of `devicemapper`: |
|
| 321 |
- |
|
| 322 |
- * `dm.basesize` |
|
| 323 |
- |
|
| 324 |
- Specifies the size to use when creating the base device, which limits the |
|
| 325 |
- size of images and containers. The default value is 10G. Note, thin devices |
|
| 326 |
- are inherently "sparse", so a 10G device which is mostly empty doesn't use |
|
| 327 |
- 10 GB of space on the pool. However, the filesystem will use more space for |
|
| 328 |
- the empty case the larger the device is. |
|
| 329 |
- |
|
| 330 |
- **Warning:** This value affects the system-wide "base" empty filesystem |
|
| 331 |
- that may already be initialized and inherited by pulled images. Typically, |
|
| 332 |
- a change to this value will require additional steps to take effect: |
|
| 333 |
- |
|
| 334 |
- $ sudo service docker stop |
|
| 335 |
- $ sudo rm -rf /var/lib/docker |
|
| 336 |
- $ sudo service docker start |
|
| 337 |
- |
|
| 338 |
- Example use: |
|
| 339 |
- |
|
| 340 |
- $ docker -d --storage-opt dm.basesize=20G |
|
| 341 |
- |
|
| 342 |
- * `dm.loopdatasize` |
|
| 343 |
- |
|
| 344 |
- Specifies the size to use when creating the loopback file for the "data" |
|
| 345 |
- device which is used for the thin pool. The default size is 100G. Note that |
|
| 346 |
- the file is sparse, so it will not initially take up this much space. |
|
| 347 |
- |
|
| 348 |
- Example use: |
|
| 349 |
- |
|
| 350 |
- $ docker -d --storage-opt dm.loopdatasize=200G |
|
| 351 |
- |
|
| 352 |
- * `dm.loopmetadatasize` |
|
| 353 |
- |
|
| 354 |
- Specifies the size to use when creating the loopback file for the |
|
| 355 |
- "metadata" device which is used for the thin pool. The default size is 2G. |
|
| 356 |
- Note that the file is sparse, so it will not initially take up this much |
|
| 357 |
- space. |
|
| 358 |
- |
|
| 359 |
- Example use: |
|
| 360 |
- |
|
| 361 |
- $ docker -d --storage-opt dm.loopmetadatasize=4G |
|
| 362 |
- |
|
| 363 |
- * `dm.fs` |
|
| 364 |
- |
|
| 365 |
- Specifies the filesystem type to use for the base device. The supported |
|
| 366 |
- options are "ext4" and "xfs". The default is "ext4" |
|
| 367 |
- |
|
| 368 |
- Example use: |
|
| 369 |
- |
|
| 370 |
- $ docker -d --storage-opt dm.fs=xfs |
|
| 371 |
- |
|
| 372 |
- * `dm.mkfsarg` |
|
| 373 |
- |
|
| 374 |
- Specifies extra mkfs arguments to be used when creating the base device. |
|
| 375 |
- |
|
| 376 |
- Example use: |
|
| 377 |
- |
|
| 378 |
- $ docker -d --storage-opt "dm.mkfsarg=-O ^has_journal" |
|
| 379 |
- |
|
| 380 |
- * `dm.mountopt` |
|
| 381 |
- |
|
| 382 |
- Specifies extra mount options used when mounting the thin devices. |
|
| 383 |
- |
|
| 384 |
- Example use: |
|
| 385 |
- |
|
| 386 |
- $ docker -d --storage-opt dm.mountopt=nodiscard |
|
| 387 |
- |
|
| 388 |
- * `dm.datadev` |
|
| 389 |
- |
|
| 390 |
- Specifies a custom blockdevice to use for data for the thin pool. |
|
| 391 |
- |
|
| 392 |
- If using a block device for device mapper storage, ideally both datadev and |
|
| 393 |
- metadatadev should be specified to completely avoid using the loopback |
|
| 394 |
- device. |
|
| 395 |
- |
|
| 396 |
- Example use: |
|
| 397 |
- |
|
| 398 |
- $ docker -d \ |
|
| 399 |
- --storage-opt dm.datadev=/dev/sdb1 \ |
|
| 400 |
- --storage-opt dm.metadatadev=/dev/sdc1 |
|
| 401 |
- |
|
| 402 |
- * `dm.metadatadev` |
|
| 403 |
- |
|
| 404 |
- Specifies a custom blockdevice to use for metadata for the thin pool. |
|
| 405 |
- |
|
| 406 |
- For best performance the metadata should be on a different spindle than the |
|
| 407 |
- data, or even better on an SSD. |
|
| 408 |
- |
|
| 409 |
- If setting up a new metadata pool it is required to be valid. This can be |
|
| 410 |
- achieved by zeroing the first 4k to indicate empty metadata, like this: |
|
| 411 |
- |
|
| 412 |
- $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1 |
|
| 413 |
- |
|
| 414 |
- Example use: |
|
| 415 |
- |
|
| 416 |
- $ docker -d \ |
|
| 417 |
- --storage-opt dm.datadev=/dev/sdb1 \ |
|
| 418 |
- --storage-opt dm.metadatadev=/dev/sdc1 |
|
| 419 |
- |
|
| 420 |
- * `dm.blocksize` |
|
| 421 |
- |
|
| 422 |
- Specifies a custom blocksize to use for the thin pool. The default |
|
| 423 |
- blocksize is 64K. |
|
| 424 |
- |
|
| 425 |
- Example use: |
|
| 426 |
- |
|
| 427 |
- $ docker -d --storage-opt dm.blocksize=512K |
|
| 428 |
- |
|
| 429 |
- * `dm.blkdiscard` |
|
| 430 |
- |
|
| 431 |
- Enables or disables the use of blkdiscard when removing devicemapper |
|
| 432 |
- devices. This is enabled by default (only) if using loopback devices and is |
|
| 433 |
- required to resparsify the loopback file on image/container removal. |
|
| 434 |
- |
|
| 435 |
- Disabling this on loopback can lead to *much* faster container removal |
|
| 436 |
- times, but will make the space used in `/var/lib/docker` directory not be |
|
| 437 |
- returned to the system for other use when containers are removed. |
|
| 438 |
- |
|
| 439 |
- Example use: |
|
| 440 |
- |
|
| 441 |
- $ docker -d --storage-opt dm.blkdiscard=false |
|
| 442 |
- |
|
| 443 |
- * `dm.override_udev_sync_check` |
|
| 444 |
- |
|
| 445 |
- Overrides the `udev` synchronization checks between `devicemapper` and `udev`. |
|
| 446 |
- `udev` is the device manager for the Linux kernel. |
|
| 447 |
- |
|
| 448 |
- To view the `udev` sync support of a Docker daemon that is using the |
|
| 449 |
- `devicemapper` driver, run: |
|
| 450 |
- |
|
| 451 |
- $ docker info |
|
| 452 |
- [...] |
|
| 453 |
- Udev Sync Supported: true |
|
| 454 |
- [...] |
|
| 455 |
- |
|
| 456 |
- When `udev` sync support is `true`, then `devicemapper` and udev can |
|
| 457 |
- coordinate the activation and deactivation of devices for containers. |
|
| 458 |
- |
|
| 459 |
- When `udev` sync support is `false`, a race condition occurs between |
|
| 460 |
- the`devicemapper` and `udev` during create and cleanup. The race condition |
|
| 461 |
- results in errors and failures. (For information on these failures, see |
|
| 462 |
- [docker#4036](https://github.com/docker/docker/issues/4036)) |
|
| 463 |
- |
|
| 464 |
- To allow the `docker` daemon to start, regardless of `udev` sync not being |
|
| 465 |
- supported, set `dm.override_udev_sync_check` to true: |
|
| 466 |
- |
|
| 467 |
- $ docker -d --storage-opt dm.override_udev_sync_check=true |
|
| 468 |
- |
|
| 469 |
- When this value is `true`, the `devicemapper` continues and simply warns |
|
| 470 |
- you the errors are happening. |
|
| 471 |
- |
|
| 472 |
- > **Note:** |
|
| 473 |
- > The ideal is to pursue a `docker` daemon and environment that does |
|
| 474 |
- > support synchronizing with `udev`. For further discussion on this |
|
| 475 |
- > topic, see [docker#4036](https://github.com/docker/docker/issues/4036). |
|
| 476 |
- > Otherwise, set this flag for migrating existing Docker daemons to |
|
| 477 |
- > a daemon with a supported environment. |
|
| 478 |
- |
|
| 479 |
-Currently supported options of `zfs`: |
|
| 480 |
- |
|
| 481 |
- * `zfs.fsname` |
|
| 482 |
- |
|
| 483 |
- Set zfs filesystem under which docker will create its own datasets. |
|
| 484 |
- By default docker will pick up the zfs filesystem where docker graph |
|
| 485 |
- (`/var/lib/docker`) is located. |
|
| 486 |
- |
|
| 487 |
- Example use: |
|
| 488 |
- |
|
| 489 |
- $ docker -d -s zfs --storage-opt zfs.fsname=zroot/docker |
|
| 490 |
- |
|
| 491 |
-### Docker execdriver option |
|
| 492 |
- |
|
| 493 |
-The Docker daemon uses a specifically built `libcontainer` execution driver as |
|
| 494 |
-its interface to the Linux kernel `namespaces`, `cgroups`, and `SELinux`. |
|
| 495 |
- |
|
| 496 |
-There is still legacy support for the original [LXC userspace tools]( |
|
| 497 |
-https://linuxcontainers.org/) via the `lxc` execution driver, however, this is |
|
| 498 |
-not where the primary development of new functionality is taking place. |
|
| 499 |
-Add `-e lxc` to the daemon flags to use the `lxc` execution driver. |
|
| 500 |
- |
|
| 501 |
-#### Options for the native execdriver |
|
| 502 |
- |
|
| 503 |
-You can configure the `native` (libcontainer) execdriver using options specified |
|
| 504 |
-with the `--exec-opt` flag. All the flag's options have the `native` prefix. A |
|
| 505 |
-single `native.cgroupdriver` option is available. |
|
| 506 |
- |
|
| 507 |
-The `native.cgroupdriver` option specifies the management of the container's |
|
| 508 |
-cgroups. You can specify `cgroupfs` or `systemd`. If you specify `systemd` and |
|
| 509 |
-it is not available, the system uses `cgroupfs`. By default, if no option is |
|
| 510 |
-specified, the execdriver first tries `systemd` and falls back to `cgroupfs`. |
|
| 511 |
-This example sets the execdriver to `cgroupfs`: |
|
| 512 |
- |
|
| 513 |
- $ sudo docker -d --exec-opt native.cgroupdriver=cgroupfs |
|
| 514 |
- |
|
| 515 |
-Setting this option applies to all containers the daemon launches. |
|
| 516 |
- |
|
| 517 |
-### Daemon DNS options |
|
| 518 |
- |
|
| 519 |
-To set the DNS server for all Docker containers, use |
|
| 520 |
-`docker -d --dns 8.8.8.8`. |
|
| 521 |
- |
|
| 522 |
-To set the DNS search domain for all Docker containers, use |
|
| 523 |
-`docker -d --dns-search example.com`. |
|
| 524 |
- |
|
| 525 |
-### Insecure registries |
|
| 526 |
- |
|
| 527 |
-Docker considers a private registry either secure or insecure. In the rest of |
|
| 528 |
-this section, *registry* is used for *private registry*, and `myregistry:5000` |
|
| 529 |
-is a placeholder example for a private registry. |
|
| 530 |
- |
|
| 531 |
-A secure registry uses TLS and a copy of its CA certificate is placed on the |
|
| 532 |
-Docker host at `/etc/docker/certs.d/myregistry:5000/ca.crt`. An insecure |
|
| 533 |
-registry is either not using TLS (i.e., listening on plain text HTTP), or is |
|
| 534 |
-using TLS with a CA certificate not known by the Docker daemon. The latter can |
|
| 535 |
-happen when the certificate was not found under |
|
| 536 |
-`/etc/docker/certs.d/myregistry:5000/`, or if the certificate verification |
|
| 537 |
-failed (i.e., wrong CA). |
|
| 538 |
- |
|
| 539 |
-By default, Docker assumes all, but local (see local registries below), |
|
| 540 |
-registries are secure. Communicating with an insecure registry is not possible |
|
| 541 |
-if Docker assumes that registry is secure. In order to communicate with an |
|
| 542 |
-insecure registry, the Docker daemon requires `--insecure-registry` in one of |
|
| 543 |
-the following two forms: |
|
| 544 |
- |
|
| 545 |
-* `--insecure-registry myregistry:5000` tells the Docker daemon that |
|
| 546 |
- myregistry:5000 should be considered insecure. |
|
| 547 |
-* `--insecure-registry 10.1.0.0/16` tells the Docker daemon that all registries |
|
| 548 |
- whose domain resolve to an IP address is part of the subnet described by the |
|
| 549 |
- CIDR syntax, should be considered insecure. |
|
| 550 |
- |
|
| 551 |
-The flag can be used multiple times to allow multiple registries to be marked |
|
| 552 |
-as insecure. |
|
| 553 |
- |
|
| 554 |
-If an insecure registry is not marked as insecure, `docker pull`, |
|
| 555 |
-`docker push`, and `docker search` will result in an error message prompting |
|
| 556 |
-the user to either secure or pass the `--insecure-registry` flag to the Docker |
|
| 557 |
-daemon as described above. |
|
| 558 |
- |
|
| 559 |
-Local registries, whose IP address falls in the 127.0.0.0/8 range, are |
|
| 560 |
-automatically marked as insecure as of Docker 1.3.2. It is not recommended to |
|
| 561 |
-rely on this, as it may change in the future. |
|
| 562 |
- |
|
| 563 |
-### Running a Docker daemon behind a HTTPS_PROXY |
|
| 564 |
- |
|
| 565 |
-When running inside a LAN that uses a `HTTPS` proxy, the Docker Hub |
|
| 566 |
-certificates will be replaced by the proxy's certificates. These certificates |
|
| 567 |
-need to be added to your Docker host's configuration: |
|
| 568 |
- |
|
| 569 |
-1. Install the `ca-certificates` package for your distribution |
|
| 570 |
-2. Ask your network admin for the proxy's CA certificate and append them to |
|
| 571 |
- `/etc/pki/tls/certs/ca-bundle.crt` |
|
| 572 |
-3. Then start your Docker daemon with `HTTPS_PROXY=http://username:password@proxy:port/ docker -d`. |
|
| 573 |
- The `username:` and `password@` are optional - and are only needed if your |
|
| 574 |
- proxy is set up to require authentication. |
|
| 575 |
- |
|
| 576 |
-This will only add the proxy and authentication to the Docker daemon's requests - |
|
| 577 |
-your `docker build`s and running containers will need extra configuration to |
|
| 578 |
-use the proxy |
|
| 579 |
- |
|
| 580 |
-### Default Ulimits |
|
| 581 |
- |
|
| 582 |
-`--default-ulimit` allows you to set the default `ulimit` options to use for |
|
| 583 |
-all containers. It takes the same options as `--ulimit` for `docker run`. If |
|
| 584 |
-these defaults are not set, `ulimit` settings will be inherited, if not set on |
|
| 585 |
-`docker run`, from the Docker daemon. Any `--ulimit` options passed to |
|
| 586 |
-`docker run` will overwrite these defaults. |
|
| 587 |
- |
|
| 588 |
-### Miscellaneous options |
|
| 589 |
- |
|
| 590 |
-IP masquerading uses address translation to allow containers without a public |
|
| 591 |
-IP to talk to other machines on the Internet. This may interfere with some |
|
| 592 |
-network topologies and can be disabled with --ip-masq=false. |
|
| 593 |
- |
|
| 594 |
-Docker supports softlinks for the Docker data directory (`/var/lib/docker`) and |
|
| 595 |
-for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be |
|
| 596 |
-set like this: |
|
| 597 |
- |
|
| 598 |
- DOCKER_TMPDIR=/mnt/disk2/tmp /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1 |
|
| 599 |
- # or |
|
| 600 |
- export DOCKER_TMPDIR=/mnt/disk2/tmp |
|
| 601 |
- /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1 |
|
| 602 |
- |
|
| 603 |
-## attach |
|
| 604 |
- |
|
| 605 |
- Usage: docker attach [OPTIONS] CONTAINER |
|
| 606 |
- |
|
| 607 |
- Attach to a running container |
|
| 608 |
- |
|
| 609 |
- --no-stdin=false Do not attach STDIN |
|
| 610 |
- --sig-proxy=true Proxy all received signals to the process |
|
| 611 |
- |
|
| 612 |
-The `docker attach` command allows you to attach to a running container using |
|
| 613 |
-the container's ID or name, either to view its ongoing output or to control it |
|
| 614 |
-interactively. You can attach to the same contained process multiple times |
|
| 615 |
-simultaneously, screen sharing style, or quickly view the progress of your |
|
| 616 |
-daemonized process. |
|
| 617 |
- |
|
| 618 |
-You can detach from the container and leave it running with `CTRL-p CTRL-q` |
|
| 619 |
-(for a quiet exit) or with `CTRL-c` if `--sig-proxy` is false. |
|
| 620 |
- |
|
| 621 |
-If `--sig-proxy` is true (the default),`CTRL-c` sends a `SIGINT` to the |
|
| 622 |
-container. |
|
| 623 |
- |
|
| 624 |
-> **Note:** |
|
| 625 |
-> A process running as PID 1 inside a container is treated specially by |
|
| 626 |
-> Linux: it ignores any signal with the default action. So, the process |
|
| 627 |
-> will not terminate on `SIGINT` or `SIGTERM` unless it is coded to do |
|
| 628 |
-> so. |
|
| 629 |
- |
|
| 630 |
-It is forbidden to redirect the standard input of a `docker attach` command |
|
| 631 |
-while attaching to a tty-enabled container (i.e.: launched with `-t`). |
|
| 632 |
- |
|
| 633 |
-#### Examples |
|
| 634 |
- |
|
| 635 |
- $ docker run -d --name topdemo ubuntu /usr/bin/top -b |
|
| 636 |
- $ docker attach topdemo |
|
| 637 |
- top - 02:05:52 up 3:05, 0 users, load average: 0.01, 0.02, 0.05 |
|
| 638 |
- Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie |
|
| 639 |
- Cpu(s): 0.1%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st |
|
| 640 |
- Mem: 373572k total, 355560k used, 18012k free, 27872k buffers |
|
| 641 |
- Swap: 786428k total, 0k used, 786428k free, 221740k cached |
|
| 642 |
- |
|
| 643 |
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND |
|
| 644 |
- 1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top |
|
| 645 |
- |
|
| 646 |
- top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05 |
|
| 647 |
- Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie |
|
| 648 |
- Cpu(s): 0.0%us, 0.2%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st |
|
| 649 |
- Mem: 373572k total, 355244k used, 18328k free, 27872k buffers |
|
| 650 |
- Swap: 786428k total, 0k used, 786428k free, 221776k cached |
|
| 651 |
- |
|
| 652 |
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND |
|
| 653 |
- 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top |
|
| 654 |
- |
|
| 655 |
- |
|
| 656 |
- top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05 |
|
| 657 |
- Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie |
|
| 658 |
- Cpu(s): 0.2%us, 0.3%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st |
|
| 659 |
- Mem: 373572k total, 355780k used, 17792k free, 27880k buffers |
|
| 660 |
- Swap: 786428k total, 0k used, 786428k free, 221776k cached |
|
| 661 |
- |
|
| 662 |
- PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND |
|
| 663 |
- 1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top |
|
| 664 |
- ^C$ |
|
| 665 |
- $ echo $? |
|
| 666 |
- 0 |
|
| 667 |
- $ docker ps -a | grep topdemo |
|
| 668 |
- 7998ac8581f9 ubuntu:14.04 "/usr/bin/top -b" 38 seconds ago Exited (0) 21 seconds ago topdemo |
|
| 669 |
- |
|
| 670 |
-And in this second example, you can see the exit code returned by the `bash` |
|
| 671 |
-process is returned by the `docker attach` command to its caller too: |
|
| 672 |
- |
|
| 673 |
- $ docker run --name test -d -it debian |
|
| 674 |
- 275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab |
|
| 675 |
- $ docker attach test |
|
| 676 |
- $$ exit 13 |
|
| 677 |
- exit |
|
| 678 |
- $ echo $? |
|
| 679 |
- 13 |
|
| 680 |
- $ docker ps -a | grep test |
|
| 681 |
- 275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test |
|
| 682 |
- |
|
| 683 |
-## build |
|
| 684 |
- |
|
| 685 |
- Usage: docker build [OPTIONS] PATH | URL | - |
|
| 686 |
- |
|
| 687 |
- Build a new image from the source code at PATH |
|
| 688 |
- |
|
| 689 |
- -f, --file="" Name of the Dockerfile (Default is 'PATH/Dockerfile') |
|
| 690 |
- --force-rm=false Always remove intermediate containers |
|
| 691 |
- --no-cache=false Do not use cache when building the image |
|
| 692 |
- --pull=false Always attempt to pull a newer version of the image |
|
| 693 |
- -q, --quiet=false Suppress the verbose output generated by the containers |
|
| 694 |
- --rm=true Remove intermediate containers after a successful build |
|
| 695 |
- -t, --tag="" Repository name (and optionally a tag) for the image |
|
| 696 |
- -m, --memory="" Memory limit for all build containers |
|
| 697 |
- --memory-swap="" Total memory (memory + swap), `-1` to disable swap |
|
| 698 |
- -c, --cpu-shares CPU Shares (relative weight) |
|
| 699 |
- --cpuset-mems="" MEMs in which to allow execution, e.g. `0-3`, `0,1` |
|
| 700 |
- --cpuset-cpus="" CPUs in which to allow execution, e.g. `0-3`, `0,1` |
|
| 701 |
- --cgroup-parent="" Optional parent cgroup for the container |
|
| 702 |
- |
|
| 703 |
-Builds Docker images from a Dockerfile and a "context". A build's context is |
|
| 704 |
-the files located in the specified `PATH` or `URL`. The build process can refer |
|
| 705 |
-to any of the files in the context. For example, your build can use an |
|
| 706 |
-[*ADD*](/reference/builder/#add) instruction to reference a file in the |
|
| 707 |
-context. |
|
| 708 |
- |
|
| 709 |
-The `URL` parameter can refer to three kinds of resources: Git repositories, |
|
| 710 |
-pre-packaged tarball contexts and plain text files. |
|
| 711 |
- |
|
| 712 |
-#### Git repositories |
|
| 713 |
-When the `URL` parameter points to the location of a Git repository, the |
|
| 714 |
-repository acts as the build context. The system recursively clones the |
|
| 715 |
-repository and its submodules using a `git clone --depth 1 --recursive` |
|
| 716 |
-command. This command runs in a temporary directory on your local host. After |
|
| 717 |
-the command succeeds, the directory is sent to the Docker daemon as the |
|
| 718 |
-context. Local clones give you the ability to access private repositories using |
|
| 719 |
-local user credentials, VPN's, and so forth. |
|
| 720 |
- |
|
| 721 |
-Git URLs accept context configuration in their fragment section, separated by a |
|
| 722 |
-colon `:`. The first part represents the reference that Git will check out, |
|
| 723 |
-this can be either a branch, a tag, or a commit SHA. The second part represents |
|
| 724 |
-a subdirectory inside the repository that will be used as a build context. |
|
| 725 |
- |
|
| 726 |
-For example, run this command to use a directory called `docker` in the branch |
|
| 727 |
-`container`: |
|
| 728 |
- |
|
| 729 |
- $ docker build https://github.com/docker/rootfs.git#container:docker |
|
| 730 |
- |
|
| 731 |
-The following table represents all the valid suffixes with their build |
|
| 732 |
-contexts: |
|
| 733 |
- |
|
| 734 |
-Build Syntax Suffix | Commit Used | Build Context Used |
|
| 735 |
-`myrepo.git` | `refs/heads/master` | `/` |
|
| 736 |
-`myrepo.git#mytag` | `refs/tags/mytag` | `/` |
|
| 737 |
-`myrepo.git#mybranch` | `refs/heads/mybranch` | `/` |
|
| 738 |
-`myrepo.git#abcdef` | `sha1 = abcdef` | `/` |
|
| 739 |
-`myrepo.git#:myfolder` | `refs/heads/master` | `/myfolder` |
|
| 740 |
-`myrepo.git#master:myfolder` | `refs/heads/master` | `/myfolder` |
|
| 741 |
-`myrepo.git#mytag:myfolder` | `refs/tags/mytag` | `/myfolder` |
|
| 742 |
-`myrepo.git#mybranch:myfolder` | `refs/heads/mybranch` | `/myfolder` |
|
| 743 |
-`myrepo.git#abcdef:myfolder` | `sha1 = abcdef` | `/myfolder` |
|
| 744 |
- |
|
| 745 |
-#### Tarball contexts |
|
| 746 |
-If you pass an URL to a remote tarball, the URL itself is sent to the daemon: |
|
| 747 |
- |
|
| 748 |
- $ docker build http://server/context.tar.gz |
|
| 749 |
- |
|
| 750 |
-The download operation will be performed on the host the Docker daemon is |
|
| 751 |
-running on, which is not necessarily the same host from which the build command |
|
| 752 |
-is being issued. The Docker daemon will fetch `context.tar.gz` and use it as the |
|
| 753 |
-build context. Tarball contexts must be tar archives conforming to the standard |
|
| 754 |
-`tar` UNIX format and can be compressed with any one of the 'xz', 'bzip2', |
|
| 755 |
-'gzip' or 'identity' (no compression) formats. |
|
| 756 |
- |
|
| 757 |
-#### Text files |
|
| 758 |
-Instead of specifying a context, you can pass a single `Dockerfile` in the |
|
| 759 |
-`URL` or pipe the file in via `STDIN`. To pipe a `Dockerfile` from `STDIN`: |
|
| 760 |
- |
|
| 761 |
- $ docker build - < Dockerfile |
|
| 762 |
- |
|
| 763 |
-If you use `STDIN` or specify a `URL` pointing to a plain text file, the system |
|
| 764 |
-places the contents into a file called `Dockerfile`, and any `-f`, `--file` |
|
| 765 |
-option is ignored. In this scenario, there is no context. |
|
| 766 |
- |
|
| 767 |
-By default the `docker build` command will look for a `Dockerfile` at the root |
|
| 768 |
-of the build context. The `-f`, `--file`, option lets you specify the path to |
|
| 769 |
-an alternative file to use instead. This is useful in cases where the same set |
|
| 770 |
-of files are used for multiple builds. The path must be to a file within the |
|
| 771 |
-build context. If a relative path is specified then it is interpreted as |
|
| 772 |
-relative to the root of the context. |
|
| 773 |
- |
|
| 774 |
-In most cases, it's best to put each Dockerfile in an empty directory. Then, |
|
| 775 |
-add to that directory only the files needed for building the Dockerfile. To |
|
| 776 |
-increase the build's performance, you can exclude files and directories by |
|
| 777 |
-adding a `.dockerignore` file to that directory as well. For information on |
|
| 778 |
-creating one, see the [.dockerignore file](../../reference/builder/#dockerignore-file). |
|
| 779 |
- |
|
| 780 |
-If the Docker client loses connection to the daemon, the build is canceled. |
|
| 781 |
-This happens if you interrupt the Docker client with `ctrl-c` or if the Docker |
|
| 782 |
-client is killed for any reason. |
|
| 783 |
- |
|
| 784 |
-> **Note:** |
|
| 785 |
-> Currently only the "run" phase of the build can be canceled until pull |
|
| 786 |
-> cancellation is implemented). |
|
| 787 |
- |
|
| 788 |
-### Return code |
|
| 789 |
- |
|
| 790 |
-On a successful build, a return code of success `0` will be returned. When the |
|
| 791 |
-build fails, a non-zero failure code will be returned. |
|
| 792 |
- |
|
| 793 |
-There should be informational output of the reason for failure output to |
|
| 794 |
-`STDERR`: |
|
| 795 |
- |
|
| 796 |
- $ docker build -t fail . |
|
| 797 |
- Sending build context to Docker daemon 2.048 kB |
|
| 798 |
- Sending build context to Docker daemon |
|
| 799 |
- Step 0 : FROM busybox |
|
| 800 |
- ---> 4986bf8c1536 |
|
| 801 |
- Step 1 : RUN exit 13 |
|
| 802 |
- ---> Running in e26670ec7a0a |
|
| 803 |
- INFO[0000] The command [/bin/sh -c exit 13] returned a non-zero code: 13 |
|
| 804 |
- $ echo $? |
|
| 805 |
- 1 |
|
| 806 |
- |
|
| 807 |
-See also: |
|
| 808 |
- |
|
| 809 |
-[*Dockerfile Reference*](/reference/builder). |
|
| 810 |
- |
|
| 811 |
-### Examples |
|
| 812 |
- |
|
| 813 |
- $ docker build . |
|
| 814 |
- Uploading context 10240 bytes |
|
| 815 |
- Step 1 : FROM busybox |
|
| 816 |
- Pulling repository busybox |
|
| 817 |
- ---> e9aa60c60128MB/2.284 MB (100%) endpoint: https://cdn-registry-1.docker.io/v1/ |
|
| 818 |
- Step 2 : RUN ls -lh / |
|
| 819 |
- ---> Running in 9c9e81692ae9 |
|
| 820 |
- total 24 |
|
| 821 |
- drwxr-xr-x 2 root root 4.0K Mar 12 2013 bin |
|
| 822 |
- drwxr-xr-x 5 root root 4.0K Oct 19 00:19 dev |
|
| 823 |
- drwxr-xr-x 2 root root 4.0K Oct 19 00:19 etc |
|
| 824 |
- drwxr-xr-x 2 root root 4.0K Nov 15 23:34 lib |
|
| 825 |
- lrwxrwxrwx 1 root root 3 Mar 12 2013 lib64 -> lib |
|
| 826 |
- dr-xr-xr-x 116 root root 0 Nov 15 23:34 proc |
|
| 827 |
- lrwxrwxrwx 1 root root 3 Mar 12 2013 sbin -> bin |
|
| 828 |
- dr-xr-xr-x 13 root root 0 Nov 15 23:34 sys |
|
| 829 |
- drwxr-xr-x 2 root root 4.0K Mar 12 2013 tmp |
|
| 830 |
- drwxr-xr-x 2 root root 4.0K Nov 15 23:34 usr |
|
| 831 |
- ---> b35f4035db3f |
|
| 832 |
- Step 3 : CMD echo Hello world |
|
| 833 |
- ---> Running in 02071fceb21b |
|
| 834 |
- ---> f52f38b7823e |
|
| 835 |
- Successfully built f52f38b7823e |
|
| 836 |
- Removing intermediate container 9c9e81692ae9 |
|
| 837 |
- Removing intermediate container 02071fceb21b |
|
| 838 |
- |
|
| 839 |
-This example specifies that the `PATH` is `.`, and so all the files in the |
|
| 840 |
-local directory get `tar`d and sent to the Docker daemon. The `PATH` specifies |
|
| 841 |
-where to find the files for the "context" of the build on the Docker daemon. |
|
| 842 |
-Remember that the daemon could be running on a remote machine and that no |
|
| 843 |
-parsing of the Dockerfile happens at the client side (where you're running |
|
| 844 |
-`docker build`). That means that *all* the files at `PATH` get sent, not just |
|
| 845 |
-the ones listed to [*ADD*](/reference/builder/#add) in the Dockerfile. |
|
| 846 |
- |
|
| 847 |
-The transfer of context from the local machine to the Docker daemon is what the |
|
| 848 |
-`docker` client means when you see the "Sending build context" message. |
|
| 849 |
- |
|
| 850 |
-If you wish to keep the intermediate containers after the build is complete, |
|
| 851 |
-you must use `--rm=false`. This does not affect the build cache. |
|
| 852 |
- |
|
| 853 |
- $ docker build . |
|
| 854 |
- Uploading context 18.829 MB |
|
| 855 |
- Uploading context |
|
| 856 |
- Step 0 : FROM busybox |
|
| 857 |
- ---> 769b9341d937 |
|
| 858 |
- Step 1 : CMD echo Hello world |
|
| 859 |
- ---> Using cache |
|
| 860 |
- ---> 99cc1ad10469 |
|
| 861 |
- Successfully built 99cc1ad10469 |
|
| 862 |
- $ echo ".git" > .dockerignore |
|
| 863 |
- $ docker build . |
|
| 864 |
- Uploading context 6.76 MB |
|
| 865 |
- Uploading context |
|
| 866 |
- Step 0 : FROM busybox |
|
| 867 |
- ---> 769b9341d937 |
|
| 868 |
- Step 1 : CMD echo Hello world |
|
| 869 |
- ---> Using cache |
|
| 870 |
- ---> 99cc1ad10469 |
|
| 871 |
- Successfully built 99cc1ad10469 |
|
| 872 |
- |
|
| 873 |
-This example shows the use of the `.dockerignore` file to exclude the `.git` |
|
| 874 |
-directory from the context. Its effect can be seen in the changed size of the |
|
| 875 |
-uploaded context. The builder reference contains detailed information on |
|
| 876 |
-[creating a .dockerignore file](../../builder/#dockerignore-file) |
|
| 877 |
- |
|
| 878 |
- $ docker build -t vieux/apache:2.0 . |
|
| 879 |
- |
|
| 880 |
-This will build like the previous example, but it will then tag the resulting |
|
| 881 |
-image. The repository name will be `vieux/apache` and the tag will be `2.0` |
|
| 882 |
- |
|
| 883 |
- $ docker build - < Dockerfile |
|
| 884 |
- |
|
| 885 |
-This will read a Dockerfile from `STDIN` without context. Due to the lack of a |
|
| 886 |
-context, no contents of any local directory will be sent to the Docker daemon. |
|
| 887 |
-Since there is no context, a Dockerfile `ADD` only works if it refers to a |
|
| 888 |
-remote URL. |
|
| 889 |
- |
|
| 890 |
- $ docker build - < context.tar.gz |
|
| 891 |
- |
|
| 892 |
-This will build an image for a compressed context read from `STDIN`. Supported |
|
| 893 |
-formats are: bzip2, gzip and xz. |
|
| 894 |
- |
|
| 895 |
- $ docker build github.com/creack/docker-firefox |
|
| 896 |
- |
|
| 897 |
-This will clone the GitHub repository and use the cloned repository as context. |
|
| 898 |
-The Dockerfile at the root of the repository is used as Dockerfile. Note that |
|
| 899 |
-you can specify an arbitrary Git repository by using the `git://` or `git@` |
|
| 900 |
-schema. |
|
| 901 |
- |
|
| 902 |
- |
|
| 903 |
- $ docker build -f ctx/Dockerfile http://server/ctx.tar.gz |
|
| 904 |
- Downloading context: http://server/ctx.tar.gz [===================>] 240 B/240 B |
|
| 905 |
- Step 0 : FROM busybox |
|
| 906 |
- ---> 8c2e06607696 |
|
| 907 |
- Step 1 : ADD ctx/container.cfg / |
|
| 908 |
- ---> e7829950cee3 |
|
| 909 |
- Removing intermediate container b35224abf821 |
|
| 910 |
- Step 2 : CMD /bin/ls |
|
| 911 |
- ---> Running in fbc63d321d73 |
|
| 912 |
- ---> 3286931702ad |
|
| 913 |
- Removing intermediate container fbc63d321d73 |
|
| 914 |
- Successfully built 377c409b35e4 |
|
| 915 |
- |
|
| 916 |
- |
|
| 917 |
-This will send the URL `http://server/ctx.tar.gz` to the Docker daemon, which |
|
| 918 |
-will download and extract the referenced tarball. The `-f ctx/Dockerfile` |
|
| 919 |
-parameter specifies a path inside `ctx.tar.gz` to the `Dockerfile` that will |
|
| 920 |
-be used to build the image. Any `ADD` commands in that `Dockerfile` that |
|
| 921 |
-refer to local paths must be relative to the root of the contents inside |
|
| 922 |
-`ctx.tar.gz`. In the example above, the tarball contains a directory `ctx/`, |
|
| 923 |
-so the `ADD ctx/container.cfg /` operation works as expected. |
|
| 924 |
- |
|
| 925 |
- $ docker build -f Dockerfile.debug . |
|
| 926 |
- |
|
| 927 |
-This will use a file called `Dockerfile.debug` for the build instructions |
|
| 928 |
-instead of `Dockerfile`. |
|
| 929 |
- |
|
| 930 |
- $ docker build -f dockerfiles/Dockerfile.debug -t myapp_debug . |
|
| 931 |
- $ docker build -f dockerfiles/Dockerfile.prod -t myapp_prod . |
|
| 932 |
- |
|
| 933 |
-The above commands will build the current build context (as specified by the |
|
| 934 |
-`.`) twice, once using a debug version of a `Dockerfile` and once using a |
|
| 935 |
-production version. |
|
| 936 |
- |
|
| 937 |
- $ cd /home/me/myapp/some/dir/really/deep |
|
| 938 |
- $ docker build -f /home/me/myapp/dockerfiles/debug /home/me/myapp |
|
| 939 |
- $ docker build -f ../../../../dockerfiles/debug /home/me/myapp |
|
| 940 |
- |
|
| 941 |
-These two `docker build` commands do the exact same thing. They both use the |
|
| 942 |
-contents of the `debug` file instead of looking for a `Dockerfile` and will use |
|
| 943 |
-`/home/me/myapp` as the root of the build context. Note that `debug` is in the |
|
| 944 |
-directory structure of the build context, regardless of how you refer to it on |
|
| 945 |
-the command line. |
|
| 946 |
- |
|
| 947 |
-> **Note:** |
|
| 948 |
-> `docker build` will return a `no such file or directory` error if the |
|
| 949 |
-> file or directory does not exist in the uploaded context. This may |
|
| 950 |
-> happen if there is no context, or if you specify a file that is |
|
| 951 |
-> elsewhere on the Host system. The context is limited to the current |
|
| 952 |
-> directory (and its children) for security reasons, and to ensure |
|
| 953 |
-> repeatable builds on remote Docker hosts. This is also the reason why |
|
| 954 |
-> `ADD ../file` will not work. |
|
| 955 |
- |
|
| 956 |
-When `docker build` is run with the `--cgroup-parent` option the containers |
|
| 957 |
-used in the build will be run with the [corresponding `docker run` |
|
| 958 |
-flag](/reference/run/#specifying-custom-cgroups). |
|
| 959 |
- |
|
| 960 |
-## commit |
|
| 961 |
- |
|
| 962 |
- Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] |
|
| 963 |
- |
|
| 964 |
- Create a new image from a container's changes |
|
| 965 |
- |
|
| 966 |
- -a, --author="" Author (e.g., "John Hannibal Smith <hannibal@a-team.com>") |
|
| 967 |
- -c, --change=[] Apply specified Dockerfile instructions while committing the image |
|
| 968 |
- -m, --message="" Commit message |
|
| 969 |
- -p, --pause=true Pause container during commit |
|
| 970 |
- |
|
| 971 |
-It can be useful to commit a container's file changes or settings into a new |
|
| 972 |
-image. This allows you debug a container by running an interactive shell, or to |
|
| 973 |
-export a working dataset to another server. Generally, it is better to use |
|
| 974 |
-Dockerfiles to manage your images in a documented and maintainable way. |
|
| 975 |
- |
|
| 976 |
-By default, the container being committed and its processes will be paused |
|
| 977 |
-while the image is committed. This reduces the likelihood of encountering data |
|
| 978 |
-corruption during the process of creating the commit. If this behavior is |
|
| 979 |
-undesired, set the 'p' option to false. |
|
| 980 |
- |
|
| 981 |
-The `--change` option will apply `Dockerfile` instructions to the image that is |
|
| 982 |
-created. Supported `Dockerfile` instructions: |
|
| 983 |
-`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR` |
|
| 984 |
- |
|
| 985 |
-#### Commit a container |
|
| 986 |
- |
|
| 987 |
- $ docker ps |
|
| 988 |
- ID IMAGE COMMAND CREATED STATUS PORTS |
|
| 989 |
- c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours |
|
| 990 |
- 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours |
|
| 991 |
- $ docker commit c3f279d17e0a SvenDowideit/testimage:version3 |
|
| 992 |
- f5283438590d |
|
| 993 |
- $ docker images |
|
| 994 |
- REPOSITORY TAG ID CREATED VIRTUAL SIZE |
|
| 995 |
- SvenDowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB |
|
| 996 |
- |
|
| 997 |
-#### Commit a container with new configurations |
|
| 998 |
- |
|
| 999 |
- $ docker ps |
|
| 1000 |
- ID IMAGE COMMAND CREATED STATUS PORTS |
|
| 1001 |
- c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours |
|
| 1002 |
- 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours |
|
| 1003 |
- $ docker inspect -f "{{ .Config.Env }}" c3f279d17e0a
|
|
| 1004 |
- [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin] |
|
| 1005 |
- $ docker commit --change "ENV DEBUG true" c3f279d17e0a SvenDowideit/testimage:version3 |
|
| 1006 |
- f5283438590d |
|
| 1007 |
- $ docker inspect -f "{{ .Config.Env }}" f5283438590d
|
|
| 1008 |
- [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true] |
|
| 1009 |
- |
|
| 1010 |
-## cp |
|
| 1011 |
- |
|
| 1012 |
-Copy files or folders from a container's filesystem to the directory on the |
|
| 1013 |
-host. Use '-' to write the data as a tar file to `STDOUT`. `CONTAINER:PATH` is |
|
| 1014 |
-relative to the root of the container's filesystem. |
|
| 1015 |
- |
|
| 1016 |
- Usage: docker cp CONTAINER:PATH HOSTDIR|- |
|
| 1017 |
- |
|
| 1018 |
- Copy files/folders from the PATH to the HOSTDIR. |
|
| 1019 |
- |
|
| 1020 |
- |
|
| 1021 |
-## create |
|
| 1022 |
- |
|
| 1023 |
-Creates a new container. |
|
| 1024 |
- |
|
| 1025 |
- Usage: docker create [OPTIONS] IMAGE [COMMAND] [ARG...] |
|
| 1026 |
- |
|
| 1027 |
- Create a new container |
|
| 1028 |
- |
|
| 1029 |
- -a, --attach=[] Attach to STDIN, STDOUT or STDERR |
|
| 1030 |
- --add-host=[] Add a custom host-to-IP mapping (host:ip) |
|
| 1031 |
- --blkio-weight=0 Block IO weight (relative weight) |
|
| 1032 |
- -c, --cpu-shares=0 CPU shares (relative weight) |
|
| 1033 |
- --cap-add=[] Add Linux capabilities |
|
| 1034 |
- --cap-drop=[] Drop Linux capabilities |
|
| 1035 |
- --cgroup-parent="" Optional parent cgroup for the container |
|
| 1036 |
- --cidfile="" Write the container ID to the file |
|
| 1037 |
- --cpuset-cpus="" CPUs in which to allow execution (0-3, 0,1) |
|
| 1038 |
- --cpuset-mems="" Memory nodes (MEMs) in which to allow execution (0-3, 0,1) |
|
| 1039 |
- --cpu-period=0 Limit the CPU CFS (Completely Fair Scheduler) period |
|
| 1040 |
- --cpu-quota=0 Limit the CPU CFS (Completely Fair Scheduler) quota |
|
| 1041 |
- --device=[] Add a host device to the container |
|
| 1042 |
- --dns=[] Set custom DNS servers |
|
| 1043 |
- --dns-search=[] Set custom DNS search domains |
|
| 1044 |
- -e, --env=[] Set environment variables |
|
| 1045 |
- --entrypoint="" Overwrite the default ENTRYPOINT of the image |
|
| 1046 |
- --env-file=[] Read in a file of environment variables |
|
| 1047 |
- --expose=[] Expose a port or a range of ports |
|
| 1048 |
- -h, --hostname="" Container host name |
|
| 1049 |
- -i, --interactive=false Keep STDIN open even if not attached |
|
| 1050 |
- --ipc="" IPC namespace to use |
|
| 1051 |
- -l, --label=[] Set metadata on the container (e.g., --label=com.example.key=value) |
|
| 1052 |
- --label-file=[] Read in a line delimited file of labels |
|
| 1053 |
- --link=[] Add link to another container |
|
| 1054 |
- --log-driver="" Logging driver for container |
|
| 1055 |
- --log-opt=[] Log driver specific options |
|
| 1056 |
- --lxc-conf=[] Add custom lxc options |
|
| 1057 |
- -m, --memory="" Memory limit |
|
| 1058 |
- --mac-address="" Container MAC address (e.g. 92:d0:c6:0a:29:33) |
|
| 1059 |
- --name="" Assign a name to the container |
|
| 1060 |
- --net="bridge" Set the Network mode for the container |
|
| 1061 |
- --oom-kill-disable=false Whether to disable OOM Killer for the container or not |
|
| 1062 |
- -P, --publish-all=false Publish all exposed ports to random ports |
|
| 1063 |
- -p, --publish=[] Publish a container's port(s) to the host |
|
| 1064 |
- --pid="" PID namespace to use |
|
| 1065 |
- --uts="" UTS namespace to use |
|
| 1066 |
- --privileged=false Give extended privileges to this container |
|
| 1067 |
- --read-only=false Mount the container's root filesystem as read only |
|
| 1068 |
- --restart="no" Restart policy (no, on-failure[:max-retry], always) |
|
| 1069 |
- --security-opt=[] Security options |
|
| 1070 |
- -t, --tty=false Allocate a pseudo-TTY |
|
| 1071 |
- -u, --user="" Username or UID |
|
| 1072 |
- -v, --volume=[] Bind mount a volume |
|
| 1073 |
- --volumes-from=[] Mount volumes from the specified container(s) |
|
| 1074 |
- -w, --workdir="" Working directory inside the container |
|
| 1075 |
- |
|
| 1076 |
-The `docker create` command creates a writeable container layer over the |
|
| 1077 |
-specified image and prepares it for running the specified command. The |
|
| 1078 |
-container ID is then printed to `STDOUT`. This is similar to `docker run -d` |
|
| 1079 |
-except the container is never started. You can then use the |
|
| 1080 |
-`docker start <container_id>` command to start the container at any point. |
|
| 1081 |
- |
|
| 1082 |
-This is useful when you want to set up a container configuration ahead of time |
|
| 1083 |
-so that it is ready to start when you need it. The initial status of the |
|
| 1084 |
-new container is `created`. |
|
| 1085 |
- |
|
| 1086 |
-Please see the [run command](#run) section and the [Docker run reference]( |
|
| 1087 |
-/reference/run/) for more details. |
|
| 1088 |
- |
|
| 1089 |
-#### Examples |
|
| 1090 |
- |
|
| 1091 |
- $ docker create -t -i fedora bash |
|
| 1092 |
- 6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752 |
|
| 1093 |
- $ docker start -a -i 6d8af538ec5 |
|
| 1094 |
- bash-4.2# |
|
| 1095 |
- |
|
| 1096 |
-As of v1.4.0 container volumes are initialized during the `docker create` phase |
|
| 1097 |
-(i.e., `docker run` too). For example, this allows you to `create` the `data` |
|
| 1098 |
-volume container, and then use it from another container: |
|
| 1099 |
- |
|
| 1100 |
- $ docker create -v /data --name data ubuntu |
|
| 1101 |
- 240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57 |
|
| 1102 |
- $ docker run --rm --volumes-from data ubuntu ls -la /data |
|
| 1103 |
- total 8 |
|
| 1104 |
- drwxr-xr-x 2 root root 4096 Dec 5 04:10 . |
|
| 1105 |
- drwxr-xr-x 48 root root 4096 Dec 5 04:11 .. |
|
| 1106 |
- |
|
| 1107 |
-Similarly, `create` a host directory bind mounted volume container, which can |
|
| 1108 |
-then be used from the subsequent container: |
|
| 1109 |
- |
|
| 1110 |
- $ docker create -v /home/docker:/docker --name docker ubuntu |
|
| 1111 |
- 9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03 |
|
| 1112 |
- $ docker run --rm --volumes-from docker ubuntu ls -la /docker |
|
| 1113 |
- total 20 |
|
| 1114 |
- drwxr-sr-x 5 1000 staff 180 Dec 5 04:00 . |
|
| 1115 |
- drwxr-xr-x 48 root root 4096 Dec 5 04:13 .. |
|
| 1116 |
- -rw-rw-r-- 1 1000 staff 3833 Dec 5 04:01 .ash_history |
|
| 1117 |
- -rw-r--r-- 1 1000 staff 446 Nov 28 11:51 .ashrc |
|
| 1118 |
- -rw-r--r-- 1 1000 staff 25 Dec 5 04:00 .gitconfig |
|
| 1119 |
- drwxr-sr-x 3 1000 staff 60 Dec 1 03:28 .local |
|
| 1120 |
- -rw-r--r-- 1 1000 staff 920 Nov 28 11:51 .profile |
|
| 1121 |
- drwx--S--- 2 1000 staff 460 Dec 5 00:51 .ssh |
|
| 1122 |
- drwxr-xr-x 32 1000 staff 1140 Dec 5 04:01 docker |
|
| 1123 |
- |
|
| 1124 |
- |
|
| 1125 |
-## diff |
|
| 1126 |
- |
|
| 1127 |
-List the changed files and directories in a container᾿s filesystem |
|
| 1128 |
- |
|
| 1129 |
- Usage: docker diff CONTAINER |
|
| 1130 |
- |
|
| 1131 |
- Inspect changes on a container's filesystem |
|
| 1132 |
- |
|
| 1133 |
-There are 3 events that are listed in the `diff`: |
|
| 1134 |
- |
|
| 1135 |
-1. `A` - Add |
|
| 1136 |
-2. `D` - Delete |
|
| 1137 |
-3. `C` - Change |
|
| 1138 |
- |
|
| 1139 |
-For example: |
|
| 1140 |
- |
|
| 1141 |
- $ docker diff 7bb0e258aefe |
|
| 1142 |
- |
|
| 1143 |
- C /dev |
|
| 1144 |
- A /dev/kmsg |
|
| 1145 |
- C /etc |
|
| 1146 |
- A /etc/mtab |
|
| 1147 |
- A /go |
|
| 1148 |
- A /go/src |
|
| 1149 |
- A /go/src/github.com |
|
| 1150 |
- A /go/src/github.com/docker |
|
| 1151 |
- A /go/src/github.com/docker/docker |
|
| 1152 |
- A /go/src/github.com/docker/docker/.git |
|
| 1153 |
- .... |
|
| 1154 |
- |
|
| 1155 |
-## events |
|
| 1156 |
- |
|
| 1157 |
- Usage: docker events [OPTIONS] |
|
| 1158 |
- |
|
| 1159 |
- Get real time events from the server |
|
| 1160 |
- |
|
| 1161 |
- -f, --filter=[] Filter output based on conditions provided |
|
| 1162 |
- --since="" Show all events created since timestamp |
|
| 1163 |
- --until="" Stream events until this timestamp |
|
| 1164 |
- |
|
| 1165 |
-Docker containers will report the following events: |
|
| 1166 |
- |
|
| 1167 |
- create, destroy, die, export, kill, oom, pause, restart, start, stop, unpause |
|
| 1168 |
- |
|
| 1169 |
-and Docker images will report: |
|
| 1170 |
- |
|
| 1171 |
- untag, delete |
|
| 1172 |
- |
|
| 1173 |
-The `--since` and `--until` parameters can be Unix timestamps, RFC3339 |
|
| 1174 |
-dates or Go duration strings (e.g. `10m`, `1h30m`) computed relative to |
|
| 1175 |
-client machine’s time. If you do not provide the --since option, the command |
|
| 1176 |
-returns only new and/or live events. |
|
| 1177 |
- |
|
| 1178 |
-#### Filtering |
|
| 1179 |
- |
|
| 1180 |
-The filtering flag (`-f` or `--filter`) format is of "key=value". If you would |
|
| 1181 |
-like to use multiple filters, pass multiple flags (e.g., |
|
| 1182 |
-`--filter "foo=bar" --filter "bif=baz"`) |
|
| 1183 |
- |
|
| 1184 |
-Using the same filter multiple times will be handled as a *OR*; for example |
|
| 1185 |
-`--filter container=588a23dac085 --filter container=a8f7720b8c22` will display |
|
| 1186 |
-events for container 588a23dac085 *OR* container a8f7720b8c22 |
|
| 1187 |
- |
|
| 1188 |
-Using multiple filters will be handled as a *AND*; for example |
|
| 1189 |
-`--filter container=588a23dac085 --filter event=start` will display events for |
|
| 1190 |
-container container 588a23dac085 *AND* the event type is *start* |
|
| 1191 |
- |
|
| 1192 |
-The currently supported filters are: |
|
| 1193 |
- |
|
| 1194 |
-* container |
|
| 1195 |
-* event |
|
| 1196 |
-* image |
|
| 1197 |
- |
|
| 1198 |
-#### Examples |
|
| 1199 |
- |
|
| 1200 |
-You'll need two shells for this example. |
|
| 1201 |
- |
|
| 1202 |
-**Shell 1: Listening for events:** |
|
| 1203 |
- |
|
| 1204 |
- $ docker events |
|
| 1205 |
- |
|
| 1206 |
-**Shell 2: Start and Stop containers:** |
|
| 1207 |
- |
|
| 1208 |
- $ docker start 4386fb97867d |
|
| 1209 |
- $ docker stop 4386fb97867d |
|
| 1210 |
- $ docker stop 7805c1d35632 |
|
| 1211 |
- |
|
| 1212 |
-**Shell 1: (Again .. now showing events):** |
|
| 1213 |
- |
|
| 1214 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start |
|
| 1215 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 1216 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 1217 |
- 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 1218 |
- 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 1219 |
- |
|
| 1220 |
-**Show events in the past from a specified time:** |
|
| 1221 |
- |
|
| 1222 |
- $ docker events --since 1378216169 |
|
| 1223 |
- 2014-03-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 1224 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 1225 |
- 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 1226 |
- 2014-03-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 1227 |
- |
|
| 1228 |
- $ docker events --since '2013-09-03' |
|
| 1229 |
- 2014-09-03T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start |
|
| 1230 |
- 2014-09-03T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 1231 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 1232 |
- 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 1233 |
- 2014-09-03T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 1234 |
- |
|
| 1235 |
- $ docker events --since '2013-09-03T15:49:29' |
|
| 1236 |
- 2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 1237 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 1238 |
- 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 1239 |
- 2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 1240 |
- |
|
| 1241 |
-This example outputs all events that were generated in the last 3 minutes, |
|
| 1242 |
-relative to the current time on the client machine: |
|
| 1243 |
- |
|
| 1244 |
- $ docker events --since '3m' |
|
| 1245 |
- 2015-05-12T11:51:30.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 1246 |
- 2015-05-12T15:52:12.999999999Z07:00 4 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 1247 |
- 2015-05-12T15:53:45.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 1248 |
- 2015-05-12T15:54:03.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 1249 |
- |
|
| 1250 |
-**Filter events:** |
|
| 1251 |
- |
|
| 1252 |
- $ docker events --filter 'event=stop' |
|
| 1253 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 1254 |
- 2014-09-03T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 1255 |
- |
|
| 1256 |
- $ docker events --filter 'image=ubuntu-1:14.04' |
|
| 1257 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start |
|
| 1258 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 1259 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 1260 |
- |
|
| 1261 |
- $ docker events --filter 'container=7805c1d35632' |
|
| 1262 |
- 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 1263 |
- 2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 1264 |
- |
|
| 1265 |
- $ docker events --filter 'container=7805c1d35632' --filter 'container=4386fb97867d' |
|
| 1266 |
- 2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 1267 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 1268 |
- 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 1269 |
- 2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 1270 |
- |
|
| 1271 |
- $ docker events --filter 'container=7805c1d35632' --filter 'event=stop' |
|
| 1272 |
- 2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 1273 |
- |
|
| 1274 |
- $ docker events --filter 'container=container_1' --filter 'container=container_2' |
|
| 1275 |
- 2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 1276 |
- 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 1277 |
- 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 1278 |
- 2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 1279 |
- |
|
| 1280 |
-## exec |
|
| 1281 |
- |
|
| 1282 |
- Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...] |
|
| 1283 |
- |
|
| 1284 |
- Run a command in a running container |
|
| 1285 |
- |
|
| 1286 |
- -d, --detach=false Detached mode: run command in the background |
|
| 1287 |
- -i, --interactive=false Keep STDIN open even if not attached |
|
| 1288 |
- -t, --tty=false Allocate a pseudo-TTY |
|
| 1289 |
- -u, --user= Username or UID (format: <name|uid>[:<group|gid>]) |
|
| 1290 |
- |
|
| 1291 |
-The `docker exec` command runs a new command in a running container. |
|
| 1292 |
- |
|
| 1293 |
-The command started using `docker exec` only runs while the container's primary |
|
| 1294 |
-process (`PID 1`) is running, and it is not restarted if the container is |
|
| 1295 |
-restarted. |
|
| 1296 |
- |
|
| 1297 |
-If the container is paused, then the `docker exec` command will fail with an error: |
|
| 1298 |
- |
|
| 1299 |
- $ docker pause test |
|
| 1300 |
- test |
|
| 1301 |
- $ docker ps |
|
| 1302 |
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
|
| 1303 |
- 1ae3b36715d2 ubuntu:latest "bash" 17 seconds ago Up 16 seconds (Paused) test |
|
| 1304 |
- $ docker exec test ls |
|
| 1305 |
- FATA[0000] Error response from daemon: Container test is paused, unpause the container before exec |
|
| 1306 |
- $ echo $? |
|
| 1307 |
- 1 |
|
| 1308 |
- |
|
| 1309 |
-#### Examples |
|
| 1310 |
- |
|
| 1311 |
- $ docker run --name ubuntu_bash --rm -i -t ubuntu bash |
|
| 1312 |
- |
|
| 1313 |
-This will create a container named `ubuntu_bash` and start a Bash session. |
|
| 1314 |
- |
|
| 1315 |
- $ docker exec -d ubuntu_bash touch /tmp/execWorks |
|
| 1316 |
- |
|
| 1317 |
-This will create a new file `/tmp/execWorks` inside the running container |
|
| 1318 |
-`ubuntu_bash`, in the background. |
|
| 1319 |
- |
|
| 1320 |
- $ docker exec -it ubuntu_bash bash |
|
| 1321 |
- |
|
| 1322 |
-This will create a new Bash session in the container `ubuntu_bash`. |
|
| 1323 |
- |
|
| 1324 |
-## export |
|
| 1325 |
- |
|
| 1326 |
- Usage: docker export [OPTIONS] CONTAINER |
|
| 1327 |
- |
|
| 1328 |
- Export the contents of a filesystem to a tar archive (streamed to STDOUT by default) |
|
| 1329 |
- |
|
| 1330 |
- -o, --output="" Write to a file, instead of STDOUT |
|
| 1331 |
- |
|
| 1332 |
- Produces a tarred repository to the standard output stream. |
|
| 1333 |
- |
|
| 1334 |
- For example: |
|
| 1335 |
- |
|
| 1336 |
- $ docker export red_panda > latest.tar |
|
| 1337 |
- |
|
| 1338 |
- Or |
|
| 1339 |
- |
|
| 1340 |
- $ docker export --output="latest.tar" red_panda |
|
| 1341 |
- |
|
| 1342 |
-> **Note:** |
|
| 1343 |
-> `docker export` does not export the contents of volumes associated |
|
| 1344 |
-> with the container. If a volume is mounted on top of an existing |
|
| 1345 |
-> directory in the container, `docker export` will export the contents |
|
| 1346 |
-> of the *underlying* directory, not the contents of the volume. |
|
| 1347 |
-> |
|
| 1348 |
-> Refer to [Backup, restore, or migrate data volumes](/userguide/dockervolumes/#backup-restore-or-migrate-data-volumes) |
|
| 1349 |
-> in the user guide for examples on exporting data in a volume. |
|
| 1350 |
- |
|
| 1351 |
-## history |
|
| 1352 |
- |
|
| 1353 |
- Usage: docker history [OPTIONS] IMAGE |
|
| 1354 |
- |
|
| 1355 |
- Show the history of an image |
|
| 1356 |
- |
|
| 1357 |
- -H, --human=true Print sizes and dates in human readable format |
|
| 1358 |
- --no-trunc=false Don't truncate output |
|
| 1359 |
- -q, --quiet=false Only show numeric IDs |
|
| 1360 |
- |
|
| 1361 |
-To see how the `docker:latest` image was built: |
|
| 1362 |
- |
|
| 1363 |
- $ docker history docker |
|
| 1364 |
- IMAGE CREATED CREATED BY SIZE COMMENT |
|
| 1365 |
- 3e23a5875458 8 days ago /bin/sh -c #(nop) ENV LC_ALL=C.UTF-8 0 B |
|
| 1366 |
- 8578938dd170 8 days ago /bin/sh -c dpkg-reconfigure locales && loc 1.245 MB |
|
| 1367 |
- be51b77efb42 8 days ago /bin/sh -c apt-get update && apt-get install 338.3 MB |
|
| 1368 |
- 4b137612be55 6 weeks ago /bin/sh -c #(nop) ADD jessie.tar.xz in / 121 MB |
|
| 1369 |
- 750d58736b4b 6 weeks ago /bin/sh -c #(nop) MAINTAINER Tianon Gravi <ad 0 B |
|
| 1370 |
- 511136ea3c5a 9 months ago 0 B Imported from - |
|
| 1371 |
- |
|
| 1372 |
-To see how the `docker:apache` image was added to a container's base image: |
|
| 1373 |
- |
|
| 1374 |
- $ docker history docker:scm |
|
| 1375 |
- IMAGE CREATED CREATED BY SIZE COMMENT |
|
| 1376 |
- 2ac9d1098bf1 3 months ago /bin/bash 241.4 MB Added Apache to Fedora base image |
|
| 1377 |
- 88b42ffd1f7c 5 months ago /bin/sh -c #(nop) ADD file:1fd8d7f9f6557cafc7 373.7 MB |
|
| 1378 |
- c69cab00d6ef 5 months ago /bin/sh -c #(nop) MAINTAINER Lokesh Mandvekar 0 B |
|
| 1379 |
- 511136ea3c5a 19 months ago 0 B Imported from - |
|
| 1380 |
- |
|
| 1381 |
- |
|
| 1382 |
-## images |
|
| 1383 |
- |
|
| 1384 |
- Usage: docker images [OPTIONS] [REPOSITORY] |
|
| 1385 |
- |
|
| 1386 |
- List images |
|
| 1387 |
- |
|
| 1388 |
- -a, --all=false Show all images (default hides intermediate images) |
|
| 1389 |
- --digests=false Show digests |
|
| 1390 |
- -f, --filter=[] Filter output based on conditions provided |
|
| 1391 |
- --help=false Print usage |
|
| 1392 |
- --no-trunc=false Don't truncate output |
|
| 1393 |
- -q, --quiet=false Only show numeric IDs |
|
| 1394 |
- |
|
| 1395 |
-The default `docker images` will show all top level |
|
| 1396 |
-images, their repository and tags, and their virtual size. |
|
| 1397 |
- |
|
| 1398 |
-Docker images have intermediate layers that increase reusability, |
|
| 1399 |
-decrease disk usage, and speed up `docker build` by |
|
| 1400 |
-allowing each step to be cached. These intermediate layers are not shown |
|
| 1401 |
-by default. |
|
| 1402 |
- |
|
| 1403 |
-The `VIRTUAL SIZE` is the cumulative space taken up by the image and all |
|
| 1404 |
-its parent images. This is also the disk space used by the contents of the |
|
| 1405 |
-Tar file created when you `docker save` an image. |
|
| 1406 |
- |
|
| 1407 |
-An image will be listed more than once if it has multiple repository names |
|
| 1408 |
-or tags. This single image (identifiable by its matching `IMAGE ID`) |
|
| 1409 |
-uses up the `VIRTUAL SIZE` listed only once. |
|
| 1410 |
- |
|
| 1411 |
-#### Listing the most recently created images |
|
| 1412 |
- |
|
| 1413 |
- $ docker images |
|
| 1414 |
- REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 1415 |
- <none> <none> 77af4d6b9913 19 hours ago 1.089 GB |
|
| 1416 |
- committ latest b6fa739cedf5 19 hours ago 1.089 GB |
|
| 1417 |
- <none> <none> 78a85c484f71 19 hours ago 1.089 GB |
|
| 1418 |
- docker latest 30557a29d5ab 20 hours ago 1.089 GB |
|
| 1419 |
- <none> <none> 5ed6274db6ce 24 hours ago 1.089 GB |
|
| 1420 |
- postgres 9 746b819f315e 4 days ago 213.4 MB |
|
| 1421 |
- postgres 9.3 746b819f315e 4 days ago 213.4 MB |
|
| 1422 |
- postgres 9.3.5 746b819f315e 4 days ago 213.4 MB |
|
| 1423 |
- postgres latest 746b819f315e 4 days ago 213.4 MB |
|
| 1424 |
- |
|
| 1425 |
- |
|
| 1426 |
-#### Listing the full length image IDs |
|
| 1427 |
- |
|
| 1428 |
- $ docker images --no-trunc |
|
| 1429 |
- REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 1430 |
- <none> <none> 77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB |
|
| 1431 |
- committest latest b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB |
|
| 1432 |
- <none> <none> 78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB |
|
| 1433 |
- docker latest 30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB |
|
| 1434 |
- <none> <none> 0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 1.089 GB |
|
| 1435 |
- <none> <none> 18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 1.082 GB |
|
| 1436 |
- <none> <none> f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 1.089 GB |
|
| 1437 |
- tryout latest 2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 131.5 MB |
|
| 1438 |
- <none> <none> 5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 1.089 GB |
|
| 1439 |
- |
|
| 1440 |
-#### Listing image digests |
|
| 1441 |
- |
|
| 1442 |
-Images that use the v2 or later format have a content-addressable identifier |
|
| 1443 |
-called a `digest`. As long as the input used to generate the image is |
|
| 1444 |
-unchanged, the digest value is predictable. To list image digest values, use |
|
| 1445 |
-the `--digests` flag: |
|
| 1446 |
- |
|
| 1447 |
- $ docker images --digests |
|
| 1448 |
- REPOSITORY TAG DIGEST IMAGE ID CREATED VIRTUAL SIZE |
|
| 1449 |
- localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB |
|
| 1450 |
- |
|
| 1451 |
-When pushing or pulling to a 2.0 registry, the `push` or `pull` command |
|
| 1452 |
-output includes the image digest. You can `pull` using a digest value. You can |
|
| 1453 |
-also reference by digest in `create`, `run`, and `rmi` commands, as well as the |
|
| 1454 |
-`FROM` image reference in a Dockerfile. |
|
| 1455 |
- |
|
| 1456 |
-#### Filtering |
|
| 1457 |
- |
|
| 1458 |
-The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more |
|
| 1459 |
-than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`) |
|
| 1460 |
- |
|
| 1461 |
-The currently supported filters are: |
|
| 1462 |
- |
|
| 1463 |
-* dangling (boolean - true or false) |
|
| 1464 |
-* label (`label=<key>` or `label=<key>=<value>`) |
|
| 1465 |
- |
|
| 1466 |
-##### Untagged images |
|
| 1467 |
- |
|
| 1468 |
- $ docker images --filter "dangling=true" |
|
| 1469 |
- |
|
| 1470 |
- REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 1471 |
- <none> <none> 8abc22fbb042 4 weeks ago 0 B |
|
| 1472 |
- <none> <none> 48e5f45168b9 4 weeks ago 2.489 MB |
|
| 1473 |
- <none> <none> bf747efa0e2f 4 weeks ago 0 B |
|
| 1474 |
- <none> <none> 980fe10e5736 12 weeks ago 101.4 MB |
|
| 1475 |
- <none> <none> dea752e4e117 12 weeks ago 101.4 MB |
|
| 1476 |
- <none> <none> 511136ea3c5a 8 months ago 0 B |
|
| 1477 |
- |
|
| 1478 |
-This will display untagged images, that are the leaves of the images tree (not |
|
| 1479 |
-intermediary layers). These images occur when a new build of an image takes the |
|
| 1480 |
-`repo:tag` away from the image ID, leaving it untagged. A warning will be issued |
|
| 1481 |
-if trying to remove an image when a container is presently using it. |
|
| 1482 |
-By having this flag it allows for batch cleanup. |
|
| 1483 |
- |
|
| 1484 |
-Ready for use by `docker rmi ...`, like: |
|
| 1485 |
- |
|
| 1486 |
- $ docker rmi $(docker images -f "dangling=true" -q) |
|
| 1487 |
- |
|
| 1488 |
- 8abc22fbb042 |
|
| 1489 |
- 48e5f45168b9 |
|
| 1490 |
- bf747efa0e2f |
|
| 1491 |
- 980fe10e5736 |
|
| 1492 |
- dea752e4e117 |
|
| 1493 |
- 511136ea3c5a |
|
| 1494 |
- |
|
| 1495 |
-NOTE: Docker will warn you if any containers exist that are using these untagged images. |
|
| 1496 |
- |
|
| 1497 |
-## import |
|
| 1498 |
- |
|
| 1499 |
- Usage: docker import file|URL|- [REPOSITORY[:TAG]] |
|
| 1500 |
- |
|
| 1501 |
- Create an empty filesystem image and import the contents of the |
|
| 1502 |
- tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then |
|
| 1503 |
- optionally tag it. |
|
| 1504 |
- |
|
| 1505 |
- -c, --change=[] Apply specified Dockerfile instructions while importing the image |
|
| 1506 |
- |
|
| 1507 |
-You can specify a `URL` or `-` (dash) to take data directly from `STDIN`. The |
|
| 1508 |
-`URL` can point to an archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, or .txz) |
|
| 1509 |
-containing a fileystem or to an individual file on the Docker host. If you |
|
| 1510 |
-specify an archive, Docker untars it in the container relative to the `/` |
|
| 1511 |
-(root). If you specify an individual file, you must specify the full path within |
|
| 1512 |
-the host. To import from a remote location, specify a `URI` that begins with the |
|
| 1513 |
-`http://` or `https://` protocol. |
|
| 1514 |
- |
|
| 1515 |
- |
|
| 1516 |
-The `--change` option will apply `Dockerfile` instructions to the image |
|
| 1517 |
-that is created. |
|
| 1518 |
-Supported `Dockerfile` instructions: |
|
| 1519 |
-`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR` |
|
| 1520 |
- |
|
| 1521 |
-#### Examples |
|
| 1522 |
- |
|
| 1523 |
-**Import from a local file archive:** |
|
| 1524 |
- |
|
| 1525 |
- $ sudo docker import /local/path/to/exampleimage.tgz exampleimagedir |
|
| 1526 |
- |
|
| 1527 |
-**Import from a remote location:** |
|
| 1528 |
- |
|
| 1529 |
-This will create a new untagged image. |
|
| 1530 |
- |
|
| 1531 |
- $ docker import http://example.com/exampleimage.tgz |
|
| 1532 |
- |
|
| 1533 |
-**Import from a local file:** |
|
| 1534 |
- |
|
| 1535 |
-Import to docker via pipe and `STDIN`. |
|
| 1536 |
- |
|
| 1537 |
- $ cat exampleimage.tgz | docker import - exampleimagelocal:new |
|
| 1538 |
- |
|
| 1539 |
-**Import from a local directory:** |
|
| 1540 |
- |
|
| 1541 |
- $ sudo tar -c . | docker import - exampleimagedir |
|
| 1542 |
- |
|
| 1543 |
-**Import from a local directory with new configurations:** |
|
| 1544 |
- |
|
| 1545 |
- $ sudo tar -c . | docker import --change "ENV DEBUG true" - exampleimagedir |
|
| 1546 |
- |
|
| 1547 |
-Note the `sudo` in this example – you must preserve |
|
| 1548 |
-the ownership of the files (especially root ownership) during the |
|
| 1549 |
-archiving with tar. If you are not root (or the sudo command) when you |
|
| 1550 |
-tar, then the ownerships might not get preserved. |
|
| 1551 |
- |
|
| 1552 |
-## info |
|
| 1553 |
- |
|
| 1554 |
- |
|
| 1555 |
- Usage: docker info |
|
| 1556 |
- |
|
| 1557 |
- Display system-wide information |
|
| 1558 |
- |
|
| 1559 |
-For example: |
|
| 1560 |
- |
|
| 1561 |
- $ docker -D info |
|
| 1562 |
- Containers: 14 |
|
| 1563 |
- Images: 52 |
|
| 1564 |
- Storage Driver: aufs |
|
| 1565 |
- Root Dir: /var/lib/docker/aufs |
|
| 1566 |
- Backing Filesystem: extfs |
|
| 1567 |
- Dirs: 545 |
|
| 1568 |
- Execution Driver: native-0.2 |
|
| 1569 |
- Logging Driver: json-file |
|
| 1570 |
- Kernel Version: 3.13.0-24-generic |
|
| 1571 |
- Operating System: Ubuntu 14.04 LTS |
|
| 1572 |
- CPUs: 1 |
|
| 1573 |
- Name: prod-server-42 |
|
| 1574 |
- ID: 7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS |
|
| 1575 |
- Total Memory: 2 GiB |
|
| 1576 |
- Debug mode (server): false |
|
| 1577 |
- Debug mode (client): true |
|
| 1578 |
- File Descriptors: 10 |
|
| 1579 |
- Goroutines: 9 |
|
| 1580 |
- System Time: Tue Mar 10 18:38:57 UTC 2015 |
|
| 1581 |
- EventsListeners: 0 |
|
| 1582 |
- Init Path: /usr/bin/docker |
|
| 1583 |
- Docker Root Dir: /var/lib/docker |
|
| 1584 |
- Http Proxy: http://test:test@localhost:8080 |
|
| 1585 |
- Https Proxy: https://test:test@localhost:8080 |
|
| 1586 |
- No Proxy: 9.81.1.160 |
|
| 1587 |
- Username: svendowideit |
|
| 1588 |
- Registry: [https://index.docker.io/v1/] |
|
| 1589 |
- Labels: |
|
| 1590 |
- storage=ssd |
|
| 1591 |
- |
|
| 1592 |
-The global `-D` option tells all `docker` commands to output debug information. |
|
| 1593 |
- |
|
| 1594 |
-When sending issue reports, please use `docker version` and `docker -D info` to |
|
| 1595 |
-ensure we know how your setup is configured. |
|
| 1596 |
- |
|
| 1597 |
-## inspect |
|
| 1598 |
- |
|
| 1599 |
- Usage: docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...] |
|
| 1600 |
- |
|
| 1601 |
- Return low-level information on a container or image |
|
| 1602 |
- |
|
| 1603 |
- -f, --format="" Format the output using the given go template |
|
| 1604 |
- |
|
| 1605 |
-By default, this will render all results in a JSON array. If a format is |
|
| 1606 |
-specified, the given template will be executed for each result. |
|
| 1607 |
- |
|
| 1608 |
-Go's [text/template](http://golang.org/pkg/text/template/) package |
|
| 1609 |
-describes all the details of the format. |
|
| 1610 |
- |
|
| 1611 |
-#### Examples |
|
| 1612 |
- |
|
| 1613 |
-**Get an instance's IP address:** |
|
| 1614 |
- |
|
| 1615 |
-For the most part, you can pick out any field from the JSON in a fairly |
|
| 1616 |
-straightforward manner. |
|
| 1617 |
- |
|
| 1618 |
- $ docker inspect --format='{{.NetworkSettings.IPAddress}}' $INSTANCE_ID
|
|
| 1619 |
- |
|
| 1620 |
-**Get an instance's MAC Address:** |
|
| 1621 |
- |
|
| 1622 |
-For the most part, you can pick out any field from the JSON in a fairly |
|
| 1623 |
-straightforward manner. |
|
| 1624 |
- |
|
| 1625 |
- $ docker inspect --format='{{.NetworkSettings.MacAddress}}' $INSTANCE_ID
|
|
| 1626 |
- |
|
| 1627 |
-**Get an instance's log path:** |
|
| 1628 |
- |
|
| 1629 |
- $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
|
|
| 1630 |
- |
|
| 1631 |
-**List All Port Bindings:** |
|
| 1632 |
- |
|
| 1633 |
-One can loop over arrays and maps in the results to produce simple text |
|
| 1634 |
-output: |
|
| 1635 |
- |
|
| 1636 |
- $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
|
|
| 1637 |
- |
|
| 1638 |
-**Find a Specific Port Mapping:** |
|
| 1639 |
- |
|
| 1640 |
-The `.Field` syntax doesn't work when the field name begins with a |
|
| 1641 |
-number, but the template language's `index` function does. The |
|
| 1642 |
-`.NetworkSettings.Ports` section contains a map of the internal port |
|
| 1643 |
-mappings to a list of external address/port objects, so to grab just the |
|
| 1644 |
-numeric public port, you use `index` to find the specific port map, and |
|
| 1645 |
-then `index` 0 contains the first object inside of that. Then we ask for |
|
| 1646 |
-the `HostPort` field to get the public address. |
|
| 1647 |
- |
|
| 1648 |
- $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
|
|
| 1649 |
- |
|
| 1650 |
-**Get config:** |
|
| 1651 |
- |
|
| 1652 |
-The `.Field` syntax doesn't work when the field contains JSON data, but |
|
| 1653 |
-the template language's custom `json` function does. The `.config` |
|
| 1654 |
-section contains complex JSON object, so to grab it as JSON, you use |
|
| 1655 |
-`json` to convert the configuration object into JSON. |
|
| 1656 |
- |
|
| 1657 |
- $ docker inspect --format='{{json .config}}' $INSTANCE_ID
|
|
| 1658 |
- |
|
| 1659 |
-## kill |
|
| 1660 |
- |
|
| 1661 |
- Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...] |
|
| 1662 |
- |
|
| 1663 |
- Kill a running container using SIGKILL or a specified signal |
|
| 1664 |
- |
|
| 1665 |
- -s, --signal="KILL" Signal to send to the container |
|
| 1666 |
- |
|
| 1667 |
-The main process inside the container will be sent `SIGKILL`, or any |
|
| 1668 |
-signal specified with option `--signal`. |
|
| 1669 |
- |
|
| 1670 |
-## load |
|
| 1671 |
- |
|
| 1672 |
- Usage: docker load [OPTIONS] |
|
| 1673 |
- |
|
| 1674 |
- Load an image from a tar archive on STDIN |
|
| 1675 |
- |
|
| 1676 |
- -i, --input="" Read from a tar archive file, instead of STDIN |
|
| 1677 |
- |
|
| 1678 |
-Loads a tarred repository from a file or the standard input stream. |
|
| 1679 |
-Restores both images and tags. |
|
| 1680 |
- |
|
| 1681 |
- $ docker images |
|
| 1682 |
- REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 1683 |
- $ docker load < busybox.tar |
|
| 1684 |
- $ docker images |
|
| 1685 |
- REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 1686 |
- busybox latest 769b9341d937 7 weeks ago 2.489 MB |
|
| 1687 |
- $ docker load --input fedora.tar |
|
| 1688 |
- $ docker images |
|
| 1689 |
- REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 1690 |
- busybox latest 769b9341d937 7 weeks ago 2.489 MB |
|
| 1691 |
- fedora rawhide 0d20aec6529d 7 weeks ago 387 MB |
|
| 1692 |
- fedora 20 58394af37342 7 weeks ago 385.5 MB |
|
| 1693 |
- fedora heisenbug 58394af37342 7 weeks ago 385.5 MB |
|
| 1694 |
- fedora latest 58394af37342 7 weeks ago 385.5 MB |
|
| 1695 |
- |
|
| 1696 |
-## login |
|
| 1697 |
- |
|
| 1698 |
- Usage: docker login [OPTIONS] [SERVER] |
|
| 1699 |
- |
|
| 1700 |
- Register or log in to a Docker registry server, if no server is |
|
| 1701 |
- specified "https://index.docker.io/v1/" is the default. |
|
| 1702 |
- |
|
| 1703 |
- -e, --email="" Email |
|
| 1704 |
- -p, --password="" Password |
|
| 1705 |
- -u, --username="" Username |
|
| 1706 |
- |
|
| 1707 |
-If you want to login to a self-hosted registry you can specify this by |
|
| 1708 |
-adding the server name. |
|
| 1709 |
- |
|
| 1710 |
- example: |
|
| 1711 |
- $ docker login localhost:8080 |
|
| 1712 |
- |
|
| 1713 |
-## logout |
|
| 1714 |
- |
|
| 1715 |
- Usage: docker logout [SERVER] |
|
| 1716 |
- |
|
| 1717 |
- Log out from a Docker registry, if no server is |
|
| 1718 |
- specified "https://index.docker.io/v1/" is the default. |
|
| 1719 |
- |
|
| 1720 |
-For example: |
|
| 1721 |
- |
|
| 1722 |
- $ docker logout localhost:8080 |
|
| 1723 |
- |
|
| 1724 |
-## logs |
|
| 1725 |
- |
|
| 1726 |
- Usage: docker logs [OPTIONS] CONTAINER |
|
| 1727 |
- |
|
| 1728 |
- Fetch the logs of a container |
|
| 1729 |
- |
|
| 1730 |
- -f, --follow=false Follow log output |
|
| 1731 |
- --since="" Show logs since timestamp |
|
| 1732 |
- -t, --timestamps=false Show timestamps |
|
| 1733 |
- --tail="all" Number of lines to show from the end of the logs |
|
| 1734 |
- |
|
| 1735 |
-NOTE: this command is available only for containers with `json-file` logging |
|
| 1736 |
-driver. |
|
| 1737 |
- |
|
| 1738 |
-The `docker logs` command batch-retrieves logs present at the time of execution. |
|
| 1739 |
- |
|
| 1740 |
-The `docker logs --follow` command will continue streaming the new output from |
|
| 1741 |
-the container's `STDOUT` and `STDERR`. |
|
| 1742 |
- |
|
| 1743 |
-Passing a negative number or a non-integer to `--tail` is invalid and the |
|
| 1744 |
-value is set to `all` in that case. This behavior may change in the future. |
|
| 1745 |
- |
|
| 1746 |
-The `docker logs --timestamp` commands will add an RFC3339Nano |
|
| 1747 |
-timestamp, for example `2014-09-16T06:17:46.000000000Z`, to each |
|
| 1748 |
-log entry. To ensure that the timestamps for are aligned the |
|
| 1749 |
-nano-second part of the timestamp will be padded with zero when necessary. |
|
| 1750 |
- |
|
| 1751 |
-The `--since` option shows only the container logs generated after |
|
| 1752 |
-a given date. You can specify the date as an RFC 3339 date, a UNIX |
|
| 1753 |
-timestamp, or a Go duration string (e.g. `1m30s`, `3h`). Docker computes |
|
| 1754 |
-the date relative to the client machine’s time. You can combine |
|
| 1755 |
-the `--since` option with either or both of the `--follow` or `--tail` options. |
|
| 1756 |
- |
|
| 1757 |
-## pause |
|
| 1758 |
- |
|
| 1759 |
- Usage: docker pause CONTAINER [CONTAINER...] |
|
| 1760 |
- |
|
| 1761 |
- Pause all processes within a container |
|
| 1762 |
- |
|
| 1763 |
-The `docker pause` command uses the cgroups freezer to suspend all processes in |
|
| 1764 |
-a container. Traditionally, when suspending a process the `SIGSTOP` signal is |
|
| 1765 |
-used, which is observable by the process being suspended. With the cgroups freezer |
|
| 1766 |
-the process is unaware, and unable to capture, that it is being suspended, |
|
| 1767 |
-and subsequently resumed. |
|
| 1768 |
- |
|
| 1769 |
-See the |
|
| 1770 |
-[cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt) |
|
| 1771 |
-for further details. |
|
| 1772 |
- |
|
| 1773 |
-## port |
|
| 1774 |
- |
|
| 1775 |
- Usage: docker port CONTAINER [PRIVATE_PORT[/PROTO]] |
|
| 1776 |
- |
|
| 1777 |
- List port mappings for the CONTAINER, or lookup the public-facing port that is |
|
| 1778 |
- NAT-ed to the PRIVATE_PORT |
|
| 1779 |
- |
|
| 1780 |
-You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or |
|
| 1781 |
-just a specific mapping: |
|
| 1782 |
- |
|
| 1783 |
- $ docker ps test |
|
| 1784 |
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
|
| 1785 |
- b650456536c7 busybox:latest top 54 minutes ago Up 54 minutes 0.0.0.0:1234->9876/tcp, 0.0.0.0:4321->7890/tcp test |
|
| 1786 |
- $ docker port test |
|
| 1787 |
- 7890/tcp -> 0.0.0.0:4321 |
|
| 1788 |
- 9876/tcp -> 0.0.0.0:1234 |
|
| 1789 |
- $ docker port test 7890/tcp |
|
| 1790 |
- 0.0.0.0:4321 |
|
| 1791 |
- $ docker port test 7890/udp |
|
| 1792 |
- 2014/06/24 11:53:36 Error: No public port '7890/udp' published for test |
|
| 1793 |
- $ docker port test 7890 |
|
| 1794 |
- 0.0.0.0:4321 |
|
| 1795 |
- |
|
| 1796 |
-## ps |
|
| 1797 |
- |
|
| 1798 |
- Usage: docker ps [OPTIONS] |
|
| 1799 |
- |
|
| 1800 |
- List containers |
|
| 1801 |
- |
|
| 1802 |
- -a, --all=false Show all containers (default shows just running) |
|
| 1803 |
- --before="" Show only container created before Id or Name |
|
| 1804 |
- -f, --filter=[] Filter output based on conditions provided |
|
| 1805 |
- -l, --latest=false Show the latest created container, include non-running |
|
| 1806 |
- -n=-1 Show n last created containers, include non-running |
|
| 1807 |
- --no-trunc=false Don't truncate output |
|
| 1808 |
- -q, --quiet=false Only display numeric IDs |
|
| 1809 |
- -s, --size=false Display total file sizes |
|
| 1810 |
- --since="" Show created since Id or Name, include non-running |
|
| 1811 |
- |
|
| 1812 |
-Running `docker ps --no-trunc` showing 2 linked containers. |
|
| 1813 |
- |
|
| 1814 |
- $ docker ps |
|
| 1815 |
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
|
| 1816 |
- 4c01db0b339c ubuntu:12.04 bash 17 seconds ago Up 16 seconds 3300-3310/tcp webapp |
|
| 1817 |
- d7886598dbe2 crosbymichael/redis:latest /redis-server --dir 33 minutes ago Up 33 minutes 6379/tcp redis,webapp/db |
|
| 1818 |
- |
|
| 1819 |
-`docker ps` will show only running containers by default. To see all containers: |
|
| 1820 |
-`docker ps -a` |
|
| 1821 |
- |
|
| 1822 |
-`docker ps` will group exposed ports into a single range if possible. E.g., a container that exposes TCP ports `100, 101, 102` will display `100-102/tcp` in the `PORTS` column. |
|
| 1823 |
- |
|
| 1824 |
-#### Filtering |
|
| 1825 |
- |
|
| 1826 |
-The filtering flag (`-f` or `--filter)` format is a `key=value` pair. If there is more |
|
| 1827 |
-than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`) |
|
| 1828 |
- |
|
| 1829 |
-The currently supported filters are: |
|
| 1830 |
- |
|
| 1831 |
-* id (container's id) |
|
| 1832 |
-* label (`label=<key>` or `label=<key>=<value>`) |
|
| 1833 |
-* name (container's name) |
|
| 1834 |
-* exited (int - the code of exited containers. Only useful with `--all`) |
|
| 1835 |
-* status (created|restarting|running|paused|exited) |
|
| 1836 |
- |
|
| 1837 |
-##### Successfully exited containers |
|
| 1838 |
- |
|
| 1839 |
- $ docker ps -a --filter 'exited=0' |
|
| 1840 |
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
|
| 1841 |
- ea09c3c82f6e registry:latest /srv/run.sh 2 weeks ago Exited (0) 2 weeks ago 127.0.0.1:5000->5000/tcp desperate_leakey |
|
| 1842 |
- 106ea823fe4e fedora:latest /bin/sh -c 'bash -l' 2 weeks ago Exited (0) 2 weeks ago determined_albattani |
|
| 1843 |
- 48ee228c9464 fedora:20 bash 2 weeks ago Exited (0) 2 weeks ago tender_torvalds |
|
| 1844 |
- |
|
| 1845 |
-This shows all the containers that have exited with status of '0' |
|
| 1846 |
- |
|
| 1847 |
-##### Killed containers |
|
| 1848 |
- |
|
| 1849 |
-You can use a filter to locate containers that exited with status of `137` meaning a `SIGKILL(9)` killed them. |
|
| 1850 |
- |
|
| 1851 |
- $ docker ps -a --filter 'exited=137' |
|
| 1852 |
- CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
|
| 1853 |
- b3e1c0ed5bfe ubuntu:latest "sleep 1000" 12 seconds ago Exited (137) 5 seconds ago grave_kowalevski |
|
| 1854 |
- a2eb5558d669 redis:latest "/entrypoint.sh redi 2 hours ago Exited (137) 2 hours ago sharp_lalande |
|
| 1855 |
- |
|
| 1856 |
-Any of these events a result in `137` status: |
|
| 1857 |
- |
|
| 1858 |
-* the `init` process of the container is killed manually |
|
| 1859 |
-* `docker kill` kills the container |
|
| 1860 |
-* Docker daemon restarts which kills all old running containers |
|
| 1861 |
- |
|
| 1862 |
-## pull |
|
| 1863 |
- |
|
| 1864 |
- Usage: docker pull [OPTIONS] NAME[:TAG] | [REGISTRY_HOST[:REGISTRY_PORT]/]NAME[:TAG] |
|
| 1865 |
- |
|
| 1866 |
- Pull an image or a repository from the registry |
|
| 1867 |
- |
|
| 1868 |
- -a, --all-tags=false Download all tagged images in the repository |
|
| 1869 |
- |
|
| 1870 |
-Most of your images will be created on top of a base image from the |
|
| 1871 |
-[Docker Hub](https://hub.docker.com) registry. |
|
| 1872 |
- |
|
| 1873 |
-[Docker Hub](https://hub.docker.com) contains many pre-built images that you |
|
| 1874 |
-can `pull` and try without needing to define and configure your own. |
|
| 1875 |
- |
|
| 1876 |
-It is also possible to manually specify the path of a registry to pull from. |
|
| 1877 |
-For example, if you have set up a local registry, you can specify its path to |
|
| 1878 |
-pull from it. A repository path is similar to a URL, but does not contain |
|
| 1879 |
-a protocol specifier (`https://`, for example). |
|
| 1880 |
- |
|
| 1881 |
-To download a particular image, or set of images (i.e., a repository), |
|
| 1882 |
-use `docker pull`: |
|
| 1883 |
- |
|
| 1884 |
- $ docker pull debian |
|
| 1885 |
- # will pull the debian:latest image and its intermediate layers |
|
| 1886 |
- $ docker pull debian:testing |
|
| 1887 |
- # will pull the image named debian:testing and any intermediate |
|
| 1888 |
- # layers it is based on. |
|
| 1889 |
- $ docker pull debian@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf |
|
| 1890 |
- # will pull the image from the debian repository with the digest |
|
| 1891 |
- # sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf |
|
| 1892 |
- # and any intermediate layers it is based on. |
|
| 1893 |
- # (Typically the empty `scratch` image, a MAINTAINER layer, |
|
| 1894 |
- # and the un-tarred base). |
|
| 1895 |
- $ docker pull --all-tags centos |
|
| 1896 |
- # will pull all the images from the centos repository |
|
| 1897 |
- $ docker pull registry.hub.docker.com/debian |
|
| 1898 |
- # manually specifies the path to the default Docker registry. This could |
|
| 1899 |
- # be replaced with the path to a local registry to pull from another source. |
|
| 1900 |
- # sudo docker pull myhub.com:8080/test-image |
|
| 1901 |
- |
|
| 1902 |
-## push |
|
| 1903 |
- |
|
| 1904 |
- Usage: docker push NAME[:TAG] |
|
| 1905 |
- |
|
| 1906 |
- Push an image or a repository to the registry |
|
| 1907 |
- |
|
| 1908 |
-Use `docker push` to share your images to the [Docker Hub](https://hub.docker.com) |
|
| 1909 |
-registry or to a self-hosted one. |
|
| 1910 |
- |
|
| 1911 |
-## rename |
|
| 1912 |
- |
|
| 1913 |
- Usage: docker rename OLD_NAME NEW_NAME |
|
| 1914 |
- |
|
| 1915 |
- rename a existing container to a NEW_NAME |
|
| 1916 |
- |
|
| 1917 |
-The `docker rename` command allows the container to be renamed to a different name. |
|
| 1918 |
- |
|
| 1919 |
-## restart |
|
| 1920 |
- |
|
| 1921 |
- Usage: docker restart [OPTIONS] CONTAINER [CONTAINER...] |
|
| 1922 |
- |
|
| 1923 |
- Restart a running container |
|
| 1924 |
- |
|
| 1925 |
- -t, --time=10 Seconds to wait for stop before killing the container |
|
| 1926 |
- |
|
| 1927 |
-## rm |
|
| 1928 |
- |
|
| 1929 |
- Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...] |
|
| 1930 |
- |
|
| 1931 |
- Remove one or more containers |
|
| 1932 |
- |
|
| 1933 |
- -f, --force=false Force the removal of a running container (uses SIGKILL) |
|
| 1934 |
- -l, --link=false Remove the specified link |
|
| 1935 |
- -v, --volumes=false Remove the volumes associated with the container |
|
| 1936 |
- |
|
| 1937 |
-#### Examples |
|
| 1938 |
- |
|
| 1939 |
- $ docker rm /redis |
|
| 1940 |
- /redis |
|
| 1941 |
- |
|
| 1942 |
-This will remove the container referenced under the link |
|
| 1943 |
-`/redis`. |
|
| 1944 |
- |
|
| 1945 |
- $ docker rm --link /webapp/redis |
|
| 1946 |
- /webapp/redis |
|
| 1947 |
- |
|
| 1948 |
-This will remove the underlying link between `/webapp` and the `/redis` |
|
| 1949 |
-containers removing all network communication. |
|
| 1950 |
- |
|
| 1951 |
- $ docker rm --force redis |
|
| 1952 |
- redis |
|
| 1953 |
- |
|
| 1954 |
-The main process inside the container referenced under the link `/redis` will receive |
|
| 1955 |
-`SIGKILL`, then the container will be removed. |
|
| 1956 |
- |
|
| 1957 |
- $ docker rm $(docker ps -a -q) |
|
| 1958 |
- |
|
| 1959 |
-This command will delete all stopped containers. The command |
|
| 1960 |
-`docker ps -a -q` will return all existing container IDs and pass them to |
|
| 1961 |
-the `rm` command which will delete them. Any running containers will not be |
|
| 1962 |
-deleted. |
|
| 1963 |
- |
|
| 1964 |
-## rmi |
|
| 1965 |
- |
|
| 1966 |
- Usage: docker rmi [OPTIONS] IMAGE [IMAGE...] |
|
| 1967 |
- |
|
| 1968 |
- Remove one or more images |
|
| 1969 |
- |
|
| 1970 |
- -f, --force=false Force removal of the image |
|
| 1971 |
- --no-prune=false Do not delete untagged parents |
|
| 1972 |
- |
|
| 1973 |
-#### Removing tagged images |
|
| 1974 |
- |
|
| 1975 |
-You can remove an image using its short or long ID, its tag, or its digest. If |
|
| 1976 |
-an image has one or more tag or digest reference, you must remove all of them |
|
| 1977 |
-before the image is removed. |
|
| 1978 |
- |
|
| 1979 |
- $ docker images |
|
| 1980 |
- REPOSITORY TAG IMAGE ID CREATED SIZE |
|
| 1981 |
- test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 1982 |
- test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 1983 |
- test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 1984 |
- |
|
| 1985 |
- $ docker rmi fd484f19954f |
|
| 1986 |
- Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force |
|
| 1987 |
- 2013/12/11 05:47:16 Error: failed to remove one or more images |
|
| 1988 |
- |
|
| 1989 |
- $ docker rmi test1 |
|
| 1990 |
- Untagged: test1:latest |
|
| 1991 |
- $ docker rmi test2 |
|
| 1992 |
- Untagged: test2:latest |
|
| 1993 |
- |
|
| 1994 |
- $ docker images |
|
| 1995 |
- REPOSITORY TAG IMAGE ID CREATED SIZE |
|
| 1996 |
- test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 1997 |
- $ docker rmi test |
|
| 1998 |
- Untagged: test:latest |
|
| 1999 |
- Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8 |
|
| 2000 |
- |
|
| 2001 |
-If you use the `-f` flag and specify the image's short or long ID, then this |
|
| 2002 |
-command untags and removes all images that match the specified ID. |
|
| 2003 |
- |
|
| 2004 |
- $ docker images |
|
| 2005 |
- REPOSITORY TAG IMAGE ID CREATED SIZE |
|
| 2006 |
- test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 2007 |
- test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 2008 |
- test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 2009 |
- |
|
| 2010 |
- $ docker rmi -f fd484f19954f |
|
| 2011 |
- Untagged: test1:latest |
|
| 2012 |
- Untagged: test:latest |
|
| 2013 |
- Untagged: test2:latest |
|
| 2014 |
- Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8 |
|
| 2015 |
- |
|
| 2016 |
-An image pulled by digest has no tag associated with it: |
|
| 2017 |
- |
|
| 2018 |
- $ docker images --digests |
|
| 2019 |
- REPOSITORY TAG DIGEST IMAGE ID CREATED VIRTUAL SIZE |
|
| 2020 |
- localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB |
|
| 2021 |
- |
|
| 2022 |
-To remove an image using its digest: |
|
| 2023 |
- |
|
| 2024 |
- $ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf |
|
| 2025 |
- Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf |
|
| 2026 |
- Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125 |
|
| 2027 |
- Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2 |
|
| 2028 |
- Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b |
|
| 2029 |
- |
|
| 2030 |
-## run |
|
| 2031 |
- |
|
| 2032 |
- Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] |
|
| 2033 |
- |
|
| 2034 |
- Run a command in a new container |
|
| 2035 |
- |
|
| 2036 |
- -a, --attach=[] Attach to STDIN, STDOUT or STDERR |
|
| 2037 |
- --add-host=[] Add a custom host-to-IP mapping (host:ip) |
|
| 2038 |
- --blkio-weight=0 Block IO weight (relative weight) |
|
| 2039 |
- -c, --cpu-shares=0 CPU shares (relative weight) |
|
| 2040 |
- --cap-add=[] Add Linux capabilities |
|
| 2041 |
- --cap-drop=[] Drop Linux capabilities |
|
| 2042 |
- --cidfile="" Write the container ID to the file |
|
| 2043 |
- --cpuset-cpus="" CPUs in which to allow execution (0-3, 0,1) |
|
| 2044 |
- --cpuset-mems="" Memory nodes (MEMs) in which to allow execution (0-3, 0,1) |
|
| 2045 |
- --cpu-period=0 Limit the CPU CFS (Completely Fair Scheduler) period |
|
| 2046 |
- --cpu-quota=0 Limit the CPU CFS (Completely Fair Scheduler) quota |
|
| 2047 |
- -d, --detach=false Run container in background and print container ID |
|
| 2048 |
- --device=[] Add a host device to the container |
|
| 2049 |
- --dns=[] Set custom DNS servers |
|
| 2050 |
- --dns-search=[] Set custom DNS search domains |
|
| 2051 |
- -e, --env=[] Set environment variables |
|
| 2052 |
- --entrypoint="" Overwrite the default ENTRYPOINT of the image |
|
| 2053 |
- --env-file=[] Read in a file of environment variables |
|
| 2054 |
- --expose=[] Expose a port or a range of ports |
|
| 2055 |
- -h, --hostname="" Container host name |
|
| 2056 |
- --help=false Print usage |
|
| 2057 |
- -i, --interactive=false Keep STDIN open even if not attached |
|
| 2058 |
- --ipc="" IPC namespace to use |
|
| 2059 |
- --link=[] Add link to another container |
|
| 2060 |
- --log-driver="" Logging driver for container |
|
| 2061 |
- --log-opt=[] Log driver specific options |
|
| 2062 |
- --lxc-conf=[] Add custom lxc options |
|
| 2063 |
- -m, --memory="" Memory limit |
|
| 2064 |
- -l, --label=[] Set metadata on the container (e.g., --label=com.example.key=value) |
|
| 2065 |
- --label-file=[] Read in a file of labels (EOL delimited) |
|
| 2066 |
- --mac-address="" Container MAC address (e.g. 92:d0:c6:0a:29:33) |
|
| 2067 |
- --memory-swap="" Total memory (memory + swap), '-1' to disable swap |
|
| 2068 |
- --name="" Assign a name to the container |
|
| 2069 |
- --net="bridge" Set the Network mode for the container |
|
| 2070 |
- --oom-kill-disable=false Whether to disable OOM Killer for the container or not |
|
| 2071 |
- -P, --publish-all=false Publish all exposed ports to random ports |
|
| 2072 |
- -p, --publish=[] Publish a container's port(s) to the host |
|
| 2073 |
- --pid="" PID namespace to use |
|
| 2074 |
- --uts="" UTS namespace to use |
|
| 2075 |
- --privileged=false Give extended privileges to this container |
|
| 2076 |
- --read-only=false Mount the container's root filesystem as read only |
|
| 2077 |
- --restart="no" Restart policy (no, on-failure[:max-retry], always) |
|
| 2078 |
- --rm=false Automatically remove the container when it exits |
|
| 2079 |
- --security-opt=[] Security Options |
|
| 2080 |
- --sig-proxy=true Proxy received signals to the process |
|
| 2081 |
- -t, --tty=false Allocate a pseudo-TTY |
|
| 2082 |
- -u, --user="" Username or UID (format: <name|uid>[:<group|gid>]) |
|
| 2083 |
- -v, --volume=[] Bind mount a volume |
|
| 2084 |
- --volumes-from=[] Mount volumes from the specified container(s) |
|
| 2085 |
- -w, --workdir="" Working directory inside the container |
|
| 2086 |
- |
|
| 2087 |
-The `docker run` command first `creates` a writeable container layer over the |
|
| 2088 |
-specified image, and then `starts` it using the specified command. That is, |
|
| 2089 |
-`docker run` is equivalent to the API `/containers/create` then |
|
| 2090 |
-`/containers/(id)/start`. A stopped container can be restarted with all its |
|
| 2091 |
-previous changes intact using `docker start`. See `docker ps -a` to view a list |
|
| 2092 |
-of all containers. |
|
| 2093 |
- |
|
| 2094 |
-There is detailed information about `docker run` in the [Docker run reference]( |
|
| 2095 |
-/reference/run/). |
|
| 2096 |
- |
|
| 2097 |
-The `docker run` command can be used in combination with `docker commit` to |
|
| 2098 |
-[*change the command that a container runs*](#commit-an-existing-container). |
|
| 2099 |
- |
|
| 2100 |
-See the [Docker User Guide](/userguide/dockerlinks/) for more detailed |
|
| 2101 |
-information about the `--expose`, `-p`, `-P` and `--link` parameters, |
|
| 2102 |
-and linking containers. |
|
| 2103 |
- |
|
| 2104 |
-#### Examples |
|
| 2105 |
- |
|
| 2106 |
- $ docker run --name test -it debian |
|
| 2107 |
- $$ exit 13 |
|
| 2108 |
- exit |
|
| 2109 |
- $ echo $? |
|
| 2110 |
- 13 |
|
| 2111 |
- $ docker ps -a | grep test |
|
| 2112 |
- 275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test |
|
| 2113 |
- |
|
| 2114 |
-In this example, we are running `bash` interactively in the `debian:latest` image, and giving |
|
| 2115 |
-the container the name `test`. We then quit `bash` by running `exit 13`, which means `bash` |
|
| 2116 |
-will have an exit code of `13`. This is then passed on to the caller of `docker run`, and |
|
| 2117 |
-is recorded in the `test` container metadata. |
|
| 2118 |
- |
|
| 2119 |
- $ docker run --cidfile /tmp/docker_test.cid ubuntu echo "test" |
|
| 2120 |
- |
|
| 2121 |
-This will create a container and print `test` to the console. The `cidfile` |
|
| 2122 |
-flag makes Docker attempt to create a new file and write the container ID to it. |
|
| 2123 |
-If the file exists already, Docker will return an error. Docker will close this |
|
| 2124 |
-file when `docker run` exits. |
|
| 2125 |
- |
|
| 2126 |
- $ docker run -t -i --rm ubuntu bash |
|
| 2127 |
- root@bc338942ef20:/# mount -t tmpfs none /mnt |
|
| 2128 |
- mount: permission denied |
|
| 2129 |
- |
|
| 2130 |
-This will *not* work, because by default, most potentially dangerous kernel |
|
| 2131 |
-capabilities are dropped; including `cap_sys_admin` (which is required to mount |
|
| 2132 |
-filesystems). However, the `--privileged` flag will allow it to run: |
|
| 2133 |
- |
|
| 2134 |
- $ docker run --privileged ubuntu bash |
|
| 2135 |
- root@50e3f57e16e6:/# mount -t tmpfs none /mnt |
|
| 2136 |
- root@50e3f57e16e6:/# df -h |
|
| 2137 |
- Filesystem Size Used Avail Use% Mounted on |
|
| 2138 |
- none 1.9G 0 1.9G 0% /mnt |
|
| 2139 |
- |
|
| 2140 |
-The `--privileged` flag gives *all* capabilities to the container, and it also |
|
| 2141 |
-lifts all the limitations enforced by the `device` cgroup controller. In other |
|
| 2142 |
-words, the container can then do almost everything that the host can do. This |
|
| 2143 |
-flag exists to allow special use-cases, like running Docker within Docker. |
|
| 2144 |
- |
|
| 2145 |
- $ docker run -w /path/to/dir/ -i -t ubuntu pwd |
|
| 2146 |
- |
|
| 2147 |
-The `-w` lets the command being executed inside directory given, here |
|
| 2148 |
-`/path/to/dir/`. If the path does not exists it is created inside the container. |
|
| 2149 |
- |
|
| 2150 |
- $ docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd |
|
| 2151 |
- |
|
| 2152 |
-The `-v` flag mounts the current working directory into the container. The `-w` |
|
| 2153 |
-lets the command being executed inside the current working directory, by |
|
| 2154 |
-changing into the directory to the value returned by `pwd`. So this |
|
| 2155 |
-combination executes the command using the container, but inside the |
|
| 2156 |
-current working directory. |
|
| 2157 |
- |
|
| 2158 |
- $ docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash |
|
| 2159 |
- |
|
| 2160 |
-When the host directory of a bind-mounted volume doesn't exist, Docker |
|
| 2161 |
-will automatically create this directory on the host for you. In the |
|
| 2162 |
-example above, Docker will create the `/doesnt/exist` |
|
| 2163 |
-folder before starting your container. |
|
| 2164 |
- |
|
| 2165 |
- $ docker run --read-only -v /icanwrite busybox touch /icanwrite here |
|
| 2166 |
- |
|
| 2167 |
-Volumes can be used in combination with `--read-only` to control where |
|
| 2168 |
-a container writes files. The `--read-only` flag mounts the container's root |
|
| 2169 |
-filesystem as read only prohibiting writes to locations other than the |
|
| 2170 |
-specified volumes for the container. |
|
| 2171 |
- |
|
| 2172 |
- $ docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v ./static-docker:/usr/bin/docker busybox sh |
|
| 2173 |
- |
|
| 2174 |
-By bind-mounting the docker unix socket and statically linked docker |
|
| 2175 |
-binary (such as that provided by [https://get.docker.com]( |
|
| 2176 |
-https://get.docker.com)), you give the container the full access to create and |
|
| 2177 |
-manipulate the host's Docker daemon. |
|
| 2178 |
- |
|
| 2179 |
- $ docker run -p 127.0.0.1:80:8080 ubuntu bash |
|
| 2180 |
- |
|
| 2181 |
-This binds port `8080` of the container to port `80` on `127.0.0.1` of |
|
| 2182 |
-the host machine. The [Docker User Guide](/userguide/dockerlinks/) |
|
| 2183 |
-explains in detail how to manipulate ports in Docker. |
|
| 2184 |
- |
|
| 2185 |
- $ docker run --expose 80 ubuntu bash |
|
| 2186 |
- |
|
| 2187 |
-This exposes port `80` of the container for use within a link without |
|
| 2188 |
-publishing the port to the host system's interfaces. The [Docker User |
|
| 2189 |
-Guide](/userguide/dockerlinks) explains in detail how to manipulate |
|
| 2190 |
-ports in Docker. |
|
| 2191 |
- |
|
| 2192 |
- $ docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash |
|
| 2193 |
- |
|
| 2194 |
-This sets environmental variables in the container. For illustration all three |
|
| 2195 |
-flags are shown here. Where `-e`, `--env` take an environment variable and |
|
| 2196 |
-value, or if no `=` is provided, then that variable's current value is passed |
|
| 2197 |
-through (i.e. `$MYVAR1` from the host is set to `$MYVAR1` in the container). |
|
| 2198 |
-When no `=` is provided and that variable is not defined in the client's |
|
| 2199 |
-environment then that variable will be removed from the container's list of |
|
| 2200 |
-environment variables. |
|
| 2201 |
-All three flags, `-e`, `--env` and `--env-file` can be repeated. |
|
| 2202 |
- |
|
| 2203 |
-Regardless of the order of these three flags, the `--env-file` are processed |
|
| 2204 |
-first, and then `-e`, `--env` flags. This way, the `-e` or `--env` will |
|
| 2205 |
-override variables as needed. |
|
| 2206 |
- |
|
| 2207 |
- $ cat ./env.list |
|
| 2208 |
- TEST_FOO=BAR |
|
| 2209 |
- $ docker run --env TEST_FOO="This is a test" --env-file ./env.list busybox env | grep TEST_FOO |
|
| 2210 |
- TEST_FOO=This is a test |
|
| 2211 |
- |
|
| 2212 |
-The `--env-file` flag takes a filename as an argument and expects each line |
|
| 2213 |
-to be in the `VAR=VAL` format, mimicking the argument passed to `--env`. Comment |
|
| 2214 |
-lines need only be prefixed with `#` |
|
| 2215 |
- |
|
| 2216 |
-An example of a file passed with `--env-file` |
|
| 2217 |
- |
|
| 2218 |
- $ cat ./env.list |
|
| 2219 |
- TEST_FOO=BAR |
|
| 2220 |
- |
|
| 2221 |
- # this is a comment |
|
| 2222 |
- TEST_APP_DEST_HOST=10.10.0.127 |
|
| 2223 |
- TEST_APP_DEST_PORT=8888 |
|
| 2224 |
- |
|
| 2225 |
- # pass through this variable from the caller |
|
| 2226 |
- TEST_PASSTHROUGH |
|
| 2227 |
- $ sudo TEST_PASSTHROUGH=howdy docker run --env-file ./env.list busybox env |
|
| 2228 |
- HOME=/ |
|
| 2229 |
- PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
|
| 2230 |
- HOSTNAME=5198e0745561 |
|
| 2231 |
- TEST_FOO=BAR |
|
| 2232 |
- TEST_APP_DEST_HOST=10.10.0.127 |
|
| 2233 |
- TEST_APP_DEST_PORT=8888 |
|
| 2234 |
- TEST_PASSTHROUGH=howdy |
|
| 2235 |
- |
|
| 2236 |
- $ docker run --name console -t -i ubuntu bash |
|
| 2237 |
- |
|
| 2238 |
-A label is a a `key=value` pair that applies metadata to a container. To label a container with two labels: |
|
| 2239 |
- |
|
| 2240 |
- $ docker run -l my-label --label com.example.foo=bar ubuntu bash |
|
| 2241 |
- |
|
| 2242 |
-The `my-label` key doesn't specify a value so the label defaults to an empty |
|
| 2243 |
-string(`""`). To add multiple labels, repeat the label flag (`-l` or `--label`). |
|
| 2244 |
- |
|
| 2245 |
-The `key=value` must be unique to avoid overwriting the label value. If you |
|
| 2246 |
-specify labels with identical keys but different values, each subsequent value |
|
| 2247 |
-overwrites the previous. Docker uses the last `key=value` you supply. |
|
| 2248 |
- |
|
| 2249 |
-Use the `--label-file` flag to load multiple labels from a file. Delimit each |
|
| 2250 |
-label in the file with an EOL mark. The example below loads labels from a |
|
| 2251 |
-labels file in the current directory: |
|
| 2252 |
- |
|
| 2253 |
- $ docker run --label-file ./labels ubuntu bash |
|
| 2254 |
- |
|
| 2255 |
-The label-file format is similar to the format for loading environment |
|
| 2256 |
-variables. (Unlike environment variables, labels are not visible to processes |
|
| 2257 |
-running inside a container.) The following example illustrates a label-file |
|
| 2258 |
-format: |
|
| 2259 |
- |
|
| 2260 |
- com.example.label1="a label" |
|
| 2261 |
- |
|
| 2262 |
- # this is a comment |
|
| 2263 |
- com.example.label2=another\ label |
|
| 2264 |
- com.example.label3 |
|
| 2265 |
- |
|
| 2266 |
-You can load multiple label-files by supplying multiple `--label-file` flags. |
|
| 2267 |
- |
|
| 2268 |
-For additional information on working with labels, see [*Labels - custom |
|
| 2269 |
-metadata in Docker*](/userguide/labels-custom-metadata/) in the Docker User |
|
| 2270 |
-Guide. |
|
| 2271 |
- |
|
| 2272 |
- $ docker run --link /redis:redis --name console ubuntu bash |
|
| 2273 |
- |
|
| 2274 |
-The `--link` flag will link the container named `/redis` into the newly |
|
| 2275 |
-created container with the alias `redis`. The new container can access the |
|
| 2276 |
-network and environment of the `redis` container via environment variables. |
|
| 2277 |
-The `--link` flag will also just accept the form `<name or id>` in which case |
|
| 2278 |
-the alias will match the name. For instance, you could have written the previous |
|
| 2279 |
-example as: |
|
| 2280 |
- |
|
| 2281 |
- $ docker run --link redis --name console ubuntu bash |
|
| 2282 |
- |
|
| 2283 |
-The `--name` flag will assign the name `console` to the newly created |
|
| 2284 |
-container. |
|
| 2285 |
- |
|
| 2286 |
- $ docker run --volumes-from 777f7dc92da7 --volumes-from ba8c0c54f0f2:ro -i -t ubuntu pwd |
|
| 2287 |
- |
|
| 2288 |
-The `--volumes-from` flag mounts all the defined volumes from the referenced |
|
| 2289 |
-containers. Containers can be specified by repetitions of the `--volumes-from` |
|
| 2290 |
-argument. The container ID may be optionally suffixed with `:ro` or `:rw` to |
|
| 2291 |
-mount the volumes in read-only or read-write mode, respectively. By default, |
|
| 2292 |
-the volumes are mounted in the same mode (read write or read only) as |
|
| 2293 |
-the reference container. |
|
| 2294 |
- |
|
| 2295 |
-Labeling systems like SELinux require that proper labels are placed on volume |
|
| 2296 |
-content mounted into a container. Without a label, the security system might |
|
| 2297 |
-prevent the processes running inside the container from using the content. By |
|
| 2298 |
-default, Docker does not change the labels set by the OS. |
|
| 2299 |
- |
|
| 2300 |
-To change the label in the container context, you can add either of two suffixes |
|
| 2301 |
-`:z` or `:Z` to the volume mount. These suffixes tell Docker to relabel file |
|
| 2302 |
-objects on the shared volumes. The `z` option tells Docker that two containers |
|
| 2303 |
-share the volume content. As a result, Docker labels the content with a shared |
|
| 2304 |
-content label. Shared volume labels allow all containers to read/write content. |
|
| 2305 |
-The `Z` option tells Docker to label the content with a private unshared label. |
|
| 2306 |
-Only the current container can use a private volume. |
|
| 2307 |
- |
|
| 2308 |
-The `-a` flag tells `docker run` to bind to the container's `STDIN`, `STDOUT` |
|
| 2309 |
-or `STDERR`. This makes it possible to manipulate the output and input as |
|
| 2310 |
-needed. |
|
| 2311 |
- |
|
| 2312 |
- $ echo "test" | docker run -i -a stdin ubuntu cat - |
|
| 2313 |
- |
|
| 2314 |
-This pipes data into a container and prints the container's ID by attaching |
|
| 2315 |
-only to the container's `STDIN`. |
|
| 2316 |
- |
|
| 2317 |
- $ docker run -a stderr ubuntu echo test |
|
| 2318 |
- |
|
| 2319 |
-This isn't going to print anything unless there's an error because we've |
|
| 2320 |
-only attached to the `STDERR` of the container. The container's logs |
|
| 2321 |
-still store what's been written to `STDERR` and `STDOUT`. |
|
| 2322 |
- |
|
| 2323 |
- $ cat somefile | docker run -i -a stdin mybuilder dobuild |
|
| 2324 |
- |
|
| 2325 |
-This is how piping a file into a container could be done for a build. |
|
| 2326 |
-The container's ID will be printed after the build is done and the build |
|
| 2327 |
-logs could be retrieved using `docker logs`. This is |
|
| 2328 |
-useful if you need to pipe a file or something else into a container and |
|
| 2329 |
-retrieve the container's ID once the container has finished running. |
|
| 2330 |
- |
|
| 2331 |
- $ docker run --device=/dev/sdc:/dev/xvdc --device=/dev/sdd --device=/dev/zero:/dev/nulo -i -t ubuntu ls -l /dev/{xvdc,sdd,nulo}
|
|
| 2332 |
- brw-rw---- 1 root disk 8, 2 Feb 9 16:05 /dev/xvdc |
|
| 2333 |
- brw-rw---- 1 root disk 8, 3 Feb 9 16:05 /dev/sdd |
|
| 2334 |
- crw-rw-rw- 1 root root 1, 5 Feb 9 16:05 /dev/nulo |
|
| 2335 |
- |
|
| 2336 |
-It is often necessary to directly expose devices to a container. The `--device` |
|
| 2337 |
-option enables that. For example, a specific block storage device or loop |
|
| 2338 |
-device or audio device can be added to an otherwise unprivileged container |
|
| 2339 |
-(without the `--privileged` flag) and have the application directly access it. |
|
| 2340 |
- |
|
| 2341 |
-By default, the container will be able to `read`, `write` and `mknod` these devices. |
|
| 2342 |
-This can be overridden using a third `:rwm` set of options to each `--device` |
|
| 2343 |
-flag: |
|
| 2344 |
- |
|
| 2345 |
- |
|
| 2346 |
- $ docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc |
|
| 2347 |
- |
|
| 2348 |
- Command (m for help): q |
|
| 2349 |
- $ docker run --device=/dev/sda:/dev/xvdc:ro --rm -it ubuntu fdisk /dev/xvdc |
|
| 2350 |
- You will not be able to write the partition table. |
|
| 2351 |
- |
|
| 2352 |
- Command (m for help): q |
|
| 2353 |
- |
|
| 2354 |
- $ docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc |
|
| 2355 |
- |
|
| 2356 |
- Command (m for help): q |
|
| 2357 |
- |
|
| 2358 |
- $ docker run --device=/dev/sda:/dev/xvdc:m --rm -it ubuntu fdisk /dev/xvdc |
|
| 2359 |
- fdisk: unable to open /dev/xvdc: Operation not permitted |
|
| 2360 |
- |
|
| 2361 |
-> **Note:** |
|
| 2362 |
-> `--device` cannot be safely used with ephemeral devices. Block devices |
|
| 2363 |
-> that may be removed should not be added to untrusted containers with |
|
| 2364 |
-> `--device`. |
|
| 2365 |
- |
|
| 2366 |
-**A complete example:** |
|
| 2367 |
- |
|
| 2368 |
- $ docker run -d --name static static-web-files sh |
|
| 2369 |
- $ docker run -d --expose=8098 --name riak riakserver |
|
| 2370 |
- $ docker run -d -m 100m -e DEVELOPMENT=1 -e BRANCH=example-code -v $(pwd):/app/bin:ro --name app appserver |
|
| 2371 |
- $ docker run -d -p 1443:443 --dns=10.0.0.1 --dns-search=dev.org -v /var/log/httpd --volumes-from static --link riak --link app -h www.sven.dev.org --name web webserver |
|
| 2372 |
- $ docker run -t -i --rm --volumes-from web -w /var/log/httpd busybox tail -f access.log |
|
| 2373 |
- |
|
| 2374 |
-This example shows five containers that might be set up to test a web |
|
| 2375 |
-application change: |
|
| 2376 |
- |
|
| 2377 |
-1. Start a pre-prepared volume image `static-web-files` (in the background) |
|
| 2378 |
- that has CSS, image and static HTML in it, (with a `VOLUME` instruction in |
|
| 2379 |
- the Dockerfile to allow the web server to use those files); |
|
| 2380 |
-2. Start a pre-prepared `riakserver` image, give the container name `riak` and |
|
| 2381 |
- expose port `8098` to any containers that link to it; |
|
| 2382 |
-3. Start the `appserver` image, restricting its memory usage to 100MB, setting |
|
| 2383 |
- two environment variables `DEVELOPMENT` and `BRANCH` and bind-mounting the |
|
| 2384 |
- current directory (`$(pwd)`) in the container in read-only mode as `/app/bin`; |
|
| 2385 |
-4. Start the `webserver`, mapping port `443` in the container to port `1443` on |
|
| 2386 |
- the Docker server, setting the DNS server to `10.0.0.1` and DNS search |
|
| 2387 |
- domain to `dev.org`, creating a volume to put the log files into (so we can |
|
| 2388 |
- access it from another container), then importing the files from the volume |
|
| 2389 |
- exposed by the `static` container, and linking to all exposed ports from |
|
| 2390 |
- `riak` and `app`. Lastly, we set the hostname to `web.sven.dev.org` so its |
|
| 2391 |
- consistent with the pre-generated SSL certificate; |
|
| 2392 |
-5. Finally, we create a container that runs `tail -f access.log` using the logs |
|
| 2393 |
- volume from the `web` container, setting the workdir to `/var/log/httpd`. The |
|
| 2394 |
- `--rm` option means that when the container exits, the container's layer is |
|
| 2395 |
- removed. |
|
| 2396 |
- |
|
| 2397 |
-#### Restart policies |
|
| 2398 |
- |
|
| 2399 |
-Use Docker's `--restart` to specify a container's *restart policy*. A restart |
|
| 2400 |
-policy controls whether the Docker daemon restarts a container after exit. |
|
| 2401 |
-Docker supports the following restart policies: |
|
| 2402 |
- |
|
| 2403 |
-<table> |
|
| 2404 |
- <thead> |
|
| 2405 |
- <tr> |
|
| 2406 |
- <th>Policy</th> |
|
| 2407 |
- <th>Result</th> |
|
| 2408 |
- </tr> |
|
| 2409 |
- </thead> |
|
| 2410 |
- <tbody> |
|
| 2411 |
- <tr> |
|
| 2412 |
- <td><strong>no</strong></td> |
|
| 2413 |
- <td> |
|
| 2414 |
- Do not automatically restart the container when it exits. This is the |
|
| 2415 |
- default. |
|
| 2416 |
- </td> |
|
| 2417 |
- </tr> |
|
| 2418 |
- <tr> |
|
| 2419 |
- <td> |
|
| 2420 |
- <span style="white-space: nowrap"> |
|
| 2421 |
- <strong>on-failure</strong>[:max-retries] |
|
| 2422 |
- </span> |
|
| 2423 |
- </td> |
|
| 2424 |
- <td> |
|
| 2425 |
- Restart only if the container exits with a non-zero exit status. |
|
| 2426 |
- Optionally, limit the number of restart retries the Docker |
|
| 2427 |
- daemon attempts. |
|
| 2428 |
- </td> |
|
| 2429 |
- </tr> |
|
| 2430 |
- <tr> |
|
| 2431 |
- <td><strong>always</strong></td> |
|
| 2432 |
- <td> |
|
| 2433 |
- Always restart the container regardless of the exit status. |
|
| 2434 |
- When you specify always, the Docker daemon will try to restart |
|
| 2435 |
- the container indefinitely. |
|
| 2436 |
- </td> |
|
| 2437 |
- </tr> |
|
| 2438 |
- </tbody> |
|
| 2439 |
-</table> |
|
| 2440 |
- |
|
| 2441 |
- $ docker run --restart=always redis |
|
| 2442 |
- |
|
| 2443 |
-This will run the `redis` container with a restart policy of **always** |
|
| 2444 |
-so that if the container exits, Docker will restart it. |
|
| 2445 |
- |
|
| 2446 |
-More detailed information on restart policies can be found in the |
|
| 2447 |
-[Restart Policies (--restart)](/reference/run/#restart-policies-restart) |
|
| 2448 |
-section of the Docker run reference page. |
|
| 2449 |
- |
|
| 2450 |
-### Adding entries to a container hosts file |
|
| 2451 |
- |
|
| 2452 |
-You can add other hosts into a container's `/etc/hosts` file by using one or |
|
| 2453 |
-more `--add-host` flags. This example adds a static address for a host named |
|
| 2454 |
-`docker`: |
|
| 2455 |
- |
|
| 2456 |
- $ docker run --add-host=docker:10.180.0.1 --rm -it debian |
|
| 2457 |
- $$ ping docker |
|
| 2458 |
- PING docker (10.180.0.1): 48 data bytes |
|
| 2459 |
- 56 bytes from 10.180.0.1: icmp_seq=0 ttl=254 time=7.600 ms |
|
| 2460 |
- 56 bytes from 10.180.0.1: icmp_seq=1 ttl=254 time=30.705 ms |
|
| 2461 |
- ^C--- docker ping statistics --- |
|
| 2462 |
- 2 packets transmitted, 2 packets received, 0% packet loss |
|
| 2463 |
- round-trip min/avg/max/stddev = 7.600/19.152/30.705/11.553 ms |
|
| 2464 |
- |
|
| 2465 |
-Sometimes you need to connect to the Docker host from within your |
|
| 2466 |
-container. To enable this, pass the Docker host's IP address to |
|
| 2467 |
-the container using the `--add-host` flag. To find the host's address, |
|
| 2468 |
-use the `ip addr show` command. |
|
| 2469 |
- |
|
| 2470 |
-The flags you pass to `ip addr show` depend on whether you are |
|
| 2471 |
-using IPv4 or IPv6 networking in your containers. Use the following |
|
| 2472 |
-flags for IPv4 address retrieval for a network device named `eth0`: |
|
| 2473 |
- |
|
| 2474 |
- $ HOSTIP=`ip -4 addr show scope global dev eth0 | grep inet | awk '{print \$2}' | cut -d / -f 1`
|
|
| 2475 |
- $ docker run --add-host=docker:${HOSTIP} --rm -it debian
|
|
| 2476 |
- |
|
| 2477 |
-For IPv6 use the `-6` flag instead of the `-4` flag. For other network |
|
| 2478 |
-devices, replace `eth0` with the correct device name (for example `docker0` |
|
| 2479 |
-for the bridge device). |
|
| 2480 |
- |
|
| 2481 |
-### Setting ulimits in a container |
|
| 2482 |
- |
|
| 2483 |
-Since setting `ulimit` settings in a container requires extra privileges not |
|
| 2484 |
-available in the default container, you can set these using the `--ulimit` flag. |
|
| 2485 |
-`--ulimit` is specified with a soft and hard limit as such: |
|
| 2486 |
-`<type>=<soft limit>[:<hard limit>]`, for example: |
|
| 2487 |
- |
|
| 2488 |
- $ docker run --ulimit nofile=1024:1024 --rm debian ulimit -n |
|
| 2489 |
- 1024 |
|
| 2490 |
- |
|
| 2491 |
-> **Note:** |
|
| 2492 |
-> If you do not provide a `hard limit`, the `soft limit` will be used |
|
| 2493 |
-> for both values. If no `ulimits` are set, they will be inherited from |
|
| 2494 |
-> the default `ulimits` set on the daemon. `as` option is disabled now. |
|
| 2495 |
-> In other words, the following script is not supported: |
|
| 2496 |
-> `$ docker run -it --ulimit as=1024 fedora /bin/bash` |
|
| 2497 |
- |
|
| 2498 |
-The values are sent to the appropriate `syscall` as they are set. |
|
| 2499 |
-Docker doesn't perform any byte conversion. Take this into account when setting the values. |
|
| 2500 |
- |
|
| 2501 |
-## save |
|
| 2502 |
- |
|
| 2503 |
- Usage: docker save [OPTIONS] IMAGE [IMAGE...] |
|
| 2504 |
- |
|
| 2505 |
- Save an image(s) to a tar archive (streamed to STDOUT by default) |
|
| 2506 |
- |
|
| 2507 |
- -o, --output="" Write to a file, instead of STDOUT |
|
| 2508 |
- |
|
| 2509 |
-Produces a tarred repository to the standard output stream. |
|
| 2510 |
-Contains all parent layers, and all tags + versions, or specified `repo:tag`, for |
|
| 2511 |
-each argument provided. |
|
| 2512 |
- |
|
| 2513 |
-It is used to create a backup that can then be used with `docker load` |
|
| 2514 |
- |
|
| 2515 |
- $ docker save busybox > busybox.tar |
|
| 2516 |
- $ ls -sh busybox.tar |
|
| 2517 |
- 2.7M busybox.tar |
|
| 2518 |
- $ docker save --output busybox.tar busybox |
|
| 2519 |
- $ ls -sh busybox.tar |
|
| 2520 |
- 2.7M busybox.tar |
|
| 2521 |
- $ docker save -o fedora-all.tar fedora |
|
| 2522 |
- $ docker save -o fedora-latest.tar fedora:latest |
|
| 2523 |
- |
|
| 2524 |
-It is even useful to cherry-pick particular tags of an image repository |
|
| 2525 |
- |
|
| 2526 |
- $ docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy |
|
| 2527 |
- |
|
| 2528 |
-## search |
|
| 2529 |
- |
|
| 2530 |
-Search [Docker Hub](https://hub.docker.com) for images |
|
| 2531 |
- |
|
| 2532 |
- Usage: docker search [OPTIONS] TERM |
|
| 2533 |
- |
|
| 2534 |
- Search the Docker Hub for images |
|
| 2535 |
- |
|
| 2536 |
- --automated=false Only show automated builds |
|
| 2537 |
- --no-trunc=false Don't truncate output |
|
| 2538 |
- -s, --stars=0 Only displays with at least x stars |
|
| 2539 |
- |
|
| 2540 |
-See [*Find Public Images on Docker Hub*]( |
|
| 2541 |
-/userguide/dockerrepos/#searching-for-images) for |
|
| 2542 |
-more details on finding shared images from the command line. |
|
| 2543 |
- |
|
| 2544 |
-> **Note:** |
|
| 2545 |
-> Search queries will only return up to 25 results |
|
| 2546 |
- |
|
| 2547 |
-## start |
|
| 2548 |
- |
|
| 2549 |
- Usage: docker start [OPTIONS] CONTAINER [CONTAINER...] |
|
| 2550 |
- |
|
| 2551 |
- Start one or more stopped containers |
|
| 2552 |
- |
|
| 2553 |
- -a, --attach=false Attach STDOUT/STDERR and forward signals |
|
| 2554 |
- -i, --interactive=false Attach container's STDIN |
|
| 2555 |
- |
|
| 2556 |
-## stats |
|
| 2557 |
- |
|
| 2558 |
- Usage: docker stats CONTAINER [CONTAINER...] |
|
| 2559 |
- |
|
| 2560 |
- Display a live stream of one or more containers' resource usage statistics |
|
| 2561 |
- |
|
| 2562 |
- --help=false Print usage |
|
| 2563 |
- --no-stream=false Disable streaming stats and only pull the first result |
|
| 2564 |
- |
|
| 2565 |
-Running `docker stats` on multiple containers |
|
| 2566 |
- |
|
| 2567 |
- $ docker stats redis1 redis2 |
|
| 2568 |
- CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O |
|
| 2569 |
- redis1 0.07% 796 KB/64 MB 1.21% 788 B/648 B |
|
| 2570 |
- redis2 0.07% 2.746 MB/64 MB 4.29% 1.266 KB/648 B |
|
| 2571 |
- |
|
| 2572 |
- |
|
| 2573 |
-The `docker stats` command will only return a live stream of data for running |
|
| 2574 |
-containers. Stopped containers will not return any data. |
|
| 2575 |
- |
|
| 2576 |
-> **Note:** |
|
| 2577 |
-> If you want more detailed information about a container's resource |
|
| 2578 |
-> usage, use the API endpoint. |
|
| 2579 |
- |
|
| 2580 |
-## stop |
|
| 2581 |
- |
|
| 2582 |
- Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...] |
|
| 2583 |
- |
|
| 2584 |
- Stop a running container by sending SIGTERM and then SIGKILL after a |
|
| 2585 |
- grace period |
|
| 2586 |
- |
|
| 2587 |
- -t, --time=10 Seconds to wait for stop before killing it |
|
| 2588 |
- |
|
| 2589 |
-The main process inside the container will receive `SIGTERM`, and after a grace |
|
| 2590 |
-period, `SIGKILL`. |
|
| 2591 |
- |
|
| 2592 |
-## tag |
|
| 2593 |
- |
|
| 2594 |
- Usage: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG] |
|
| 2595 |
- |
|
| 2596 |
- Tag an image into a repository |
|
| 2597 |
- |
|
| 2598 |
- -f, --force=false Force |
|
| 2599 |
- |
|
| 2600 |
-You can group your images together using names and tags, and then upload them |
|
| 2601 |
-to [*Share Images via Repositories*](/userguide/dockerrepos/#contributing-to-docker-hub). |
|
| 2602 |
- |
|
| 2603 |
-## top |
|
| 2604 |
- |
|
| 2605 |
- Usage: docker top CONTAINER [ps OPTIONS] |
|
| 2606 |
- |
|
| 2607 |
- Display the running processes of a container |
|
| 2608 |
- |
|
| 2609 |
-## unpause |
|
| 2610 |
- |
|
| 2611 |
- Usage: docker unpause CONTAINER [CONTAINER...] |
|
| 2612 |
- |
|
| 2613 |
- Unpause all processes within a container |
|
| 2614 |
- |
|
| 2615 |
-The `docker unpause` command uses the cgroups freezer to un-suspend all |
|
| 2616 |
-processes in a container. |
|
| 2617 |
- |
|
| 2618 |
-See the |
|
| 2619 |
-[cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt) |
|
| 2620 |
-for further details. |
|
| 2621 |
- |
|
| 2622 |
-## version |
|
| 2623 |
- |
|
| 2624 |
- Usage: docker version |
|
| 2625 |
- |
|
| 2626 |
- Show the Docker version information. |
|
| 2627 |
- |
|
| 2628 |
-Show the Docker version, API version, Git commit, Go version and |
|
| 2629 |
-OS/architecture of both Docker client and daemon. Example use: |
|
| 2630 |
- |
|
| 2631 |
- $ docker version |
|
| 2632 |
- Client version: 1.5.0 |
|
| 2633 |
- Client API version: 1.17 |
|
| 2634 |
- Go version (client): go1.4.1 |
|
| 2635 |
- Git commit (client): a8a31ef |
|
| 2636 |
- OS/Arch (client): darwin/amd64 |
|
| 2637 |
- Server version: 1.5.0 |
|
| 2638 |
- Server API version: 1.17 |
|
| 2639 |
- Go version (server): go1.4.1 |
|
| 2640 |
- Git commit (server): a8a31ef |
|
| 2641 |
- OS/Arch (server): linux/amd64 |
|
| 2642 |
- |
|
| 2643 |
- |
|
| 2644 |
-## wait |
|
| 2645 |
- |
|
| 2646 |
- Usage: docker wait CONTAINER [CONTAINER...] |
|
| 2647 |
- |
|
| 2648 |
- Block until a container stops, then print its exit code. |
| 2649 | 149 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,61 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "commit" |
|
| 2 |
+description = "The commit command description and usage" |
|
| 3 |
+keywords = ["commit, file, changes"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# commit |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]] |
|
| 12 |
+ |
|
| 13 |
+ Create a new image from a container's changes |
|
| 14 |
+ |
|
| 15 |
+ -a, --author="" Author (e.g., "John Hannibal Smith <hannibal@a-team.com>") |
|
| 16 |
+ -c, --change=[] Apply specified Dockerfile instructions while committing the image |
|
| 17 |
+ -m, --message="" Commit message |
|
| 18 |
+ -p, --pause=true Pause container during commit |
|
| 19 |
+ |
|
| 20 |
+It can be useful to commit a container's file changes or settings into a new |
|
| 21 |
+image. This allows you debug a container by running an interactive shell, or to |
|
| 22 |
+export a working dataset to another server. Generally, it is better to use |
|
| 23 |
+Dockerfiles to manage your images in a documented and maintainable way. |
|
| 24 |
+ |
|
| 25 |
+By default, the container being committed and its processes will be paused |
|
| 26 |
+while the image is committed. This reduces the likelihood of encountering data |
|
| 27 |
+corruption during the process of creating the commit. If this behavior is |
|
| 28 |
+undesired, set the 'p' option to false. |
|
| 29 |
+ |
|
| 30 |
+The `--change` option will apply `Dockerfile` instructions to the image that is |
|
| 31 |
+created. Supported `Dockerfile` instructions: |
|
| 32 |
+`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR` |
|
| 33 |
+ |
|
| 34 |
+## Commit a container |
|
| 35 |
+ |
|
| 36 |
+ $ docker ps |
|
| 37 |
+ ID IMAGE COMMAND CREATED STATUS PORTS |
|
| 38 |
+ c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours |
|
| 39 |
+ 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours |
|
| 40 |
+ $ docker commit c3f279d17e0a SvenDowideit/testimage:version3 |
|
| 41 |
+ f5283438590d |
|
| 42 |
+ $ docker images |
|
| 43 |
+ REPOSITORY TAG ID CREATED VIRTUAL SIZE |
|
| 44 |
+ SvenDowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB |
|
| 45 |
+ |
|
| 46 |
+## Commit a container with new configurations |
|
| 47 |
+ |
|
| 48 |
+ $ docker ps |
|
| 49 |
+ ID IMAGE COMMAND CREATED STATUS PORTS |
|
| 50 |
+ c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours |
|
| 51 |
+ 197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours |
|
| 52 |
+ $ docker inspect -f "{{ .Config.Env }}" c3f279d17e0a
|
|
| 53 |
+ [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin] |
|
| 54 |
+ $ docker commit --change "ENV DEBUG true" c3f279d17e0a SvenDowideit/testimage:version3 |
|
| 55 |
+ f5283438590d |
|
| 56 |
+ $ docker inspect -f "{{ .Config.Env }}" f5283438590d
|
|
| 57 |
+ [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true] |
|
| 58 |
+ |
| 0 | 59 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,22 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "cp" |
|
| 2 |
+description = "The cp command description and usage" |
|
| 3 |
+keywords = ["copy, container, files, folders"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# cp |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker cp CONTAINER:PATH HOSTDIR|- |
|
| 12 |
+ |
|
| 13 |
+ Copy files/folders from the PATH to the HOSTDIR. |
|
| 14 |
+ |
|
| 15 |
+Copy files or folders from a container's filesystem to the directory on the |
|
| 16 |
+host. Use '-' to write the data as a tar file to `STDOUT`. `CONTAINER:PATH` is |
|
| 17 |
+relative to the root of the container's filesystem. |
|
| 18 |
+ |
|
| 19 |
+ |
| 0 | 20 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,115 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "create" |
|
| 2 |
+description = "The create command description and usage" |
|
| 3 |
+keywords = ["docker, create, container"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# create |
|
| 10 |
+ |
|
| 11 |
+Creates a new container. |
|
| 12 |
+ |
|
| 13 |
+ Usage: docker create [OPTIONS] IMAGE [COMMAND] [ARG...] |
|
| 14 |
+ |
|
| 15 |
+ Create a new container |
|
| 16 |
+ |
|
| 17 |
+ -a, --attach=[] Attach to STDIN, STDOUT or STDERR |
|
| 18 |
+ --add-host=[] Add a custom host-to-IP mapping (host:ip) |
|
| 19 |
+ --blkio-weight=0 Block IO weight (relative weight) |
|
| 20 |
+ -c, --cpu-shares=0 CPU shares (relative weight) |
|
| 21 |
+ --cap-add=[] Add Linux capabilities |
|
| 22 |
+ --cap-drop=[] Drop Linux capabilities |
|
| 23 |
+ --cgroup-parent="" Optional parent cgroup for the container |
|
| 24 |
+ --cidfile="" Write the container ID to the file |
|
| 25 |
+ --cpuset-cpus="" CPUs in which to allow execution (0-3, 0,1) |
|
| 26 |
+ --cpuset-mems="" Memory nodes (MEMs) in which to allow execution (0-3, 0,1) |
|
| 27 |
+ --cpu-period=0 Limit the CPU CFS (Completely Fair Scheduler) period |
|
| 28 |
+ --cpu-quota=0 Limit the CPU CFS (Completely Fair Scheduler) quota |
|
| 29 |
+ --device=[] Add a host device to the container |
|
| 30 |
+ --dns=[] Set custom DNS servers |
|
| 31 |
+ --dns-search=[] Set custom DNS search domains |
|
| 32 |
+ -e, --env=[] Set environment variables |
|
| 33 |
+ --entrypoint="" Overwrite the default ENTRYPOINT of the image |
|
| 34 |
+ --env-file=[] Read in a file of environment variables |
|
| 35 |
+ --expose=[] Expose a port or a range of ports |
|
| 36 |
+ -h, --hostname="" Container host name |
|
| 37 |
+ -i, --interactive=false Keep STDIN open even if not attached |
|
| 38 |
+ --ipc="" IPC namespace to use |
|
| 39 |
+ -l, --label=[] Set metadata on the container (e.g., --label=com.example.key=value) |
|
| 40 |
+ --label-file=[] Read in a line delimited file of labels |
|
| 41 |
+ --link=[] Add link to another container |
|
| 42 |
+ --log-driver="" Logging driver for container |
|
| 43 |
+ --log-opt=[] Log driver specific options |
|
| 44 |
+ --lxc-conf=[] Add custom lxc options |
|
| 45 |
+ -m, --memory="" Memory limit |
|
| 46 |
+ --mac-address="" Container MAC address (e.g. 92:d0:c6:0a:29:33) |
|
| 47 |
+ --name="" Assign a name to the container |
|
| 48 |
+ --net="bridge" Set the Network mode for the container |
|
| 49 |
+ --oom-kill-disable=false Whether to disable OOM Killer for the container or not |
|
| 50 |
+ -P, --publish-all=false Publish all exposed ports to random ports |
|
| 51 |
+ -p, --publish=[] Publish a container's port(s) to the host |
|
| 52 |
+ --pid="" PID namespace to use |
|
| 53 |
+ --uts="" UTS namespace to use |
|
| 54 |
+ --privileged=false Give extended privileges to this container |
|
| 55 |
+ --read-only=false Mount the container's root filesystem as read only |
|
| 56 |
+ --restart="no" Restart policy (no, on-failure[:max-retry], always) |
|
| 57 |
+ --security-opt=[] Security options |
|
| 58 |
+ -t, --tty=false Allocate a pseudo-TTY |
|
| 59 |
+ -u, --user="" Username or UID |
|
| 60 |
+ -v, --volume=[] Bind mount a volume |
|
| 61 |
+ --volumes-from=[] Mount volumes from the specified container(s) |
|
| 62 |
+ -w, --workdir="" Working directory inside the container |
|
| 63 |
+ |
|
| 64 |
+The `docker create` command creates a writeable container layer over the |
|
| 65 |
+specified image and prepares it for running the specified command. The |
|
| 66 |
+container ID is then printed to `STDOUT`. This is similar to `docker run -d` |
|
| 67 |
+except the container is never started. You can then use the |
|
| 68 |
+`docker start <container_id>` command to start the container at any point. |
|
| 69 |
+ |
|
| 70 |
+This is useful when you want to set up a container configuration ahead of time |
|
| 71 |
+so that it is ready to start when you need it. The initial status of the |
|
| 72 |
+new container is `created`. |
|
| 73 |
+ |
|
| 74 |
+Please see the [run command](/reference/commandline/run) section and the [Docker run reference]( |
|
| 75 |
+/reference/run/) for more details. |
|
| 76 |
+ |
|
| 77 |
+## Examples |
|
| 78 |
+ |
|
| 79 |
+ $ docker create -t -i fedora bash |
|
| 80 |
+ 6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752 |
|
| 81 |
+ $ docker start -a -i 6d8af538ec5 |
|
| 82 |
+ bash-4.2# |
|
| 83 |
+ |
|
| 84 |
+As of v1.4.0 container volumes are initialized during the `docker create` phase |
|
| 85 |
+(i.e., `docker run` too). For example, this allows you to `create` the `data` |
|
| 86 |
+volume container, and then use it from another container: |
|
| 87 |
+ |
|
| 88 |
+ $ docker create -v /data --name data ubuntu |
|
| 89 |
+ 240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57 |
|
| 90 |
+ $ docker run --rm --volumes-from data ubuntu ls -la /data |
|
| 91 |
+ total 8 |
|
| 92 |
+ drwxr-xr-x 2 root root 4096 Dec 5 04:10 . |
|
| 93 |
+ drwxr-xr-x 48 root root 4096 Dec 5 04:11 .. |
|
| 94 |
+ |
|
| 95 |
+Similarly, `create` a host directory bind mounted volume container, which can |
|
| 96 |
+then be used from the subsequent container: |
|
| 97 |
+ |
|
| 98 |
+ $ docker create -v /home/docker:/docker --name docker ubuntu |
|
| 99 |
+ 9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03 |
|
| 100 |
+ $ docker run --rm --volumes-from docker ubuntu ls -la /docker |
|
| 101 |
+ total 20 |
|
| 102 |
+ drwxr-sr-x 5 1000 staff 180 Dec 5 04:00 . |
|
| 103 |
+ drwxr-xr-x 48 root root 4096 Dec 5 04:13 .. |
|
| 104 |
+ -rw-rw-r-- 1 1000 staff 3833 Dec 5 04:01 .ash_history |
|
| 105 |
+ -rw-r--r-- 1 1000 staff 446 Nov 28 11:51 .ashrc |
|
| 106 |
+ -rw-r--r-- 1 1000 staff 25 Dec 5 04:00 .gitconfig |
|
| 107 |
+ drwxr-sr-x 3 1000 staff 60 Dec 1 03:28 .local |
|
| 108 |
+ -rw-r--r-- 1 1000 staff 920 Nov 28 11:51 .profile |
|
| 109 |
+ drwx--S--- 2 1000 staff 460 Dec 5 00:51 .ssh |
|
| 110 |
+ drwxr-xr-x 32 1000 staff 1140 Dec 5 04:01 docker |
|
| 111 |
+ |
|
| 112 |
+ |
| 0 | 113 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,464 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "daemon" |
|
| 2 |
+description = "The daemon command description and usage" |
|
| 3 |
+keywords = ["container, daemon, runtime"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+<![end-metadata]--> |
|
| 7 |
+ |
|
| 8 |
+# daemon |
|
| 9 |
+ |
|
| 10 |
+ Usage: docker [OPTIONS] COMMAND [arg...] |
|
| 11 |
+ |
|
| 12 |
+ A self-sufficient runtime for linux containers. |
|
| 13 |
+ |
|
| 14 |
+ Options: |
|
| 15 |
+ --api-cors-header="" Set CORS headers in the remote API |
|
| 16 |
+ -b, --bridge="" Attach containers to a network bridge |
|
| 17 |
+ --bip="" Specify network bridge IP |
|
| 18 |
+ -D, --debug=false Enable debug mode |
|
| 19 |
+ -d, --daemon=false Enable daemon mode |
|
| 20 |
+ --default-gateway="" Container default gateway IPv4 address |
|
| 21 |
+ --default-gateway-v6="" Container default gateway IPv6 address |
|
| 22 |
+ --dns=[] DNS server to use |
|
| 23 |
+ --dns-search=[] DNS search domains to use |
|
| 24 |
+ --default-ulimit=[] Set default ulimit settings for containers |
|
| 25 |
+ -e, --exec-driver="native" Exec driver to use |
|
| 26 |
+ --exec-opt=[] Set exec driver options |
|
| 27 |
+ --exec-root="/var/run/docker" Root of the Docker execdriver |
|
| 28 |
+ --fixed-cidr="" IPv4 subnet for fixed IPs |
|
| 29 |
+ --fixed-cidr-v6="" IPv6 subnet for fixed IPs |
|
| 30 |
+ -G, --group="docker" Group for the unix socket |
|
| 31 |
+ -g, --graph="/var/lib/docker" Root of the Docker runtime |
|
| 32 |
+ -H, --host=[] Daemon socket(s) to connect to |
|
| 33 |
+ -h, --help=false Print usage |
|
| 34 |
+ --icc=true Enable inter-container communication |
|
| 35 |
+ --insecure-registry=[] Enable insecure registry communication |
|
| 36 |
+ --ip=0.0.0.0 Default IP when binding container ports |
|
| 37 |
+ --ip-forward=true Enable net.ipv4.ip_forward |
|
| 38 |
+ --ip-masq=true Enable IP masquerading |
|
| 39 |
+ --iptables=true Enable addition of iptables rules |
|
| 40 |
+ --ipv6=false Enable IPv6 networking |
|
| 41 |
+ -l, --log-level="info" Set the logging level |
|
| 42 |
+ --label=[] Set key=value labels to the daemon |
|
| 43 |
+ --log-driver="json-file" Default driver for container logs |
|
| 44 |
+ --log-opt=[] Log driver specific options |
|
| 45 |
+ --mtu=0 Set the containers network MTU |
|
| 46 |
+ -p, --pidfile="/var/run/docker.pid" Path to use for daemon PID file |
|
| 47 |
+ --registry-mirror=[] Preferred Docker registry mirror |
|
| 48 |
+ -s, --storage-driver="" Storage driver to use |
|
| 49 |
+ --selinux-enabled=false Enable selinux support |
|
| 50 |
+ --storage-opt=[] Set storage driver options |
|
| 51 |
+ --tls=false Use TLS; implied by --tlsverify |
|
| 52 |
+ --tlscacert="~/.docker/ca.pem" Trust certs signed only by this CA |
|
| 53 |
+ --tlscert="~/.docker/cert.pem" Path to TLS certificate file |
|
| 54 |
+ --tlskey="~/.docker/key.pem" Path to TLS key file |
|
| 55 |
+ --tlsverify=false Use TLS and verify the remote |
|
| 56 |
+ --userland-proxy=true Use userland proxy for loopback traffic |
|
| 57 |
+ -v, --version=false Print version information and quit |
|
| 58 |
+ |
|
| 59 |
+Options with [] may be specified multiple times. |
|
| 60 |
+ |
|
| 61 |
+The Docker daemon is the persistent process that manages containers. Docker |
|
| 62 |
+uses the same binary for both the daemon and client. To run the daemon you |
|
| 63 |
+provide the `-d` flag. |
|
| 64 |
+ |
|
| 65 |
+To run the daemon with debug output, use `docker -d -D`. |
|
| 66 |
+ |
|
| 67 |
+## Daemon socket option |
|
| 68 |
+ |
|
| 69 |
+The Docker daemon can listen for [Docker Remote API](/reference/api/docker_remote_api/) |
|
| 70 |
+requests via three different types of Socket: `unix`, `tcp`, and `fd`. |
|
| 71 |
+ |
|
| 72 |
+By default, a `unix` domain socket (or IPC socket) is created at |
|
| 73 |
+`/var/run/docker.sock`, requiring either `root` permission, or `docker` group |
|
| 74 |
+membership. |
|
| 75 |
+ |
|
| 76 |
+If you need to access the Docker daemon remotely, you need to enable the `tcp` |
|
| 77 |
+Socket. Beware that the default setup provides un-encrypted and |
|
| 78 |
+un-authenticated direct access to the Docker daemon - and should be secured |
|
| 79 |
+either using the [built in HTTPS encrypted socket](/articles/https/), or by |
|
| 80 |
+putting a secure web proxy in front of it. You can listen on port `2375` on all |
|
| 81 |
+network interfaces with `-H tcp://0.0.0.0:2375`, or on a particular network |
|
| 82 |
+interface using its IP address: `-H tcp://192.168.59.103:2375`. It is |
|
| 83 |
+conventional to use port `2375` for un-encrypted, and port `2376` for encrypted |
|
| 84 |
+communication with the daemon. |
|
| 85 |
+ |
|
| 86 |
+> **Note:** |
|
| 87 |
+> If you're using an HTTPS encrypted socket, keep in mind that only |
|
| 88 |
+> TLS1.0 and greater are supported. Protocols SSLv3 and under are not |
|
| 89 |
+> supported anymore for security reasons. |
|
| 90 |
+ |
|
| 91 |
+On Systemd based systems, you can communicate with the daemon via |
|
| 92 |
+[Systemd socket activation](http://0pointer.de/blog/projects/socket-activation.html), |
|
| 93 |
+use `docker -d -H fd://`. Using `fd://` will work perfectly for most setups but |
|
| 94 |
+you can also specify individual sockets: `docker -d -H fd://3`. If the |
|
| 95 |
+specified socket activated files aren't found, then Docker will exit. You can |
|
| 96 |
+find examples of using Systemd socket activation with Docker and Systemd in the |
|
| 97 |
+[Docker source tree](https://github.com/docker/docker/tree/master/contrib/init/systemd/). |
|
| 98 |
+ |
|
| 99 |
+You can configure the Docker daemon to listen to multiple sockets at the same |
|
| 100 |
+time using multiple `-H` options: |
|
| 101 |
+ |
|
| 102 |
+ # listen using the default unix socket, and on 2 specific IP addresses on this host. |
|
| 103 |
+ docker -d -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2 |
|
| 104 |
+ |
|
| 105 |
+The Docker client will honor the `DOCKER_HOST` environment variable to set the |
|
| 106 |
+`-H` flag for the client. |
|
| 107 |
+ |
|
| 108 |
+ $ docker -H tcp://0.0.0.0:2375 ps |
|
| 109 |
+ # or |
|
| 110 |
+ $ export DOCKER_HOST="tcp://0.0.0.0:2375" |
|
| 111 |
+ $ docker ps |
|
| 112 |
+ # both are equal |
|
| 113 |
+ |
|
| 114 |
+Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than |
|
| 115 |
+the empty string is equivalent to setting the `--tlsverify` flag. The following |
|
| 116 |
+are equivalent: |
|
| 117 |
+ |
|
| 118 |
+ $ docker --tlsverify ps |
|
| 119 |
+ # or |
|
| 120 |
+ $ export DOCKER_TLS_VERIFY=1 |
|
| 121 |
+ $ docker ps |
|
| 122 |
+ |
|
| 123 |
+The Docker client will honor the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` |
|
| 124 |
+environment variables (or the lowercase versions thereof). `HTTPS_PROXY` takes |
|
| 125 |
+precedence over `HTTP_PROXY`. |
|
| 126 |
+ |
|
| 127 |
+### Daemon storage-driver option |
|
| 128 |
+ |
|
| 129 |
+The Docker daemon has support for several different image layer storage |
|
| 130 |
+drivers: `aufs`, `devicemapper`, `btrfs`, `zfs` and `overlay`. |
|
| 131 |
+ |
|
| 132 |
+The `aufs` driver is the oldest, but is based on a Linux kernel patch-set that |
|
| 133 |
+is unlikely to be merged into the main kernel. These are also known to cause |
|
| 134 |
+some serious kernel crashes. However, `aufs` is also the only storage driver |
|
| 135 |
+that allows containers to share executable and shared library memory, so is a |
|
| 136 |
+useful choice when running thousands of containers with the same program or |
|
| 137 |
+libraries. |
|
| 138 |
+ |
|
| 139 |
+The `devicemapper` driver uses thin provisioning and Copy on Write (CoW) |
|
| 140 |
+snapshots. For each devicemapper graph location – typically |
|
| 141 |
+`/var/lib/docker/devicemapper` – a thin pool is created based on two block |
|
| 142 |
+devices, one for data and one for metadata. By default, these block devices |
|
| 143 |
+are created automatically by using loopback mounts of automatically created |
|
| 144 |
+sparse files. Refer to [Storage driver options](#storage-driver-options) below |
|
| 145 |
+for a way how to customize this setup. |
|
| 146 |
+[~jpetazzo/Resizing Docker containers with the Device Mapper plugin](http://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/) |
|
| 147 |
+article explains how to tune your existing setup without the use of options. |
|
| 148 |
+ |
|
| 149 |
+The `btrfs` driver is very fast for `docker build` - but like `devicemapper` |
|
| 150 |
+does not share executable memory between devices. Use |
|
| 151 |
+`docker -d -s btrfs -g /mnt/btrfs_partition`. |
|
| 152 |
+ |
|
| 153 |
+The `zfs` driver is probably not fast as `btrfs` but has a longer track record |
|
| 154 |
+on stability. Thanks to `Single Copy ARC` shared blocks between clones will be |
|
| 155 |
+cached only once. Use `docker -d -s zfs`. To select a different zfs filesystem |
|
| 156 |
+set `zfs.fsname` option as described in [Storage driver options](#storage-driver-options). |
|
| 157 |
+ |
|
| 158 |
+The `overlay` is a very fast union filesystem. It is now merged in the main |
|
| 159 |
+Linux kernel as of [3.18.0](https://lkml.org/lkml/2014/10/26/137). Call |
|
| 160 |
+`docker -d -s overlay` to use it. |
|
| 161 |
+ |
|
| 162 |
+> **Note:** |
|
| 163 |
+> As promising as `overlay` is, the feature is still quite young and should not |
|
| 164 |
+> be used in production. Most notably, using `overlay` can cause excessive |
|
| 165 |
+> inode consumption (especially as the number of images grows), as well as |
|
| 166 |
+> being incompatible with the use of RPMs. |
|
| 167 |
+ |
|
| 168 |
+> **Note:** |
|
| 169 |
+> It is currently unsupported on `btrfs` or any Copy on Write filesystem |
|
| 170 |
+> and should only be used over `ext4` partitions. |
|
| 171 |
+ |
|
| 172 |
+### Storage driver options |
|
| 173 |
+ |
|
| 174 |
+Particular storage-driver can be configured with options specified with |
|
| 175 |
+`--storage-opt` flags. Options for `devicemapper` are prefixed with `dm` and |
|
| 176 |
+options for `zfs` start with `zfs`. |
|
| 177 |
+ |
|
| 178 |
+Currently supported options of `devicemapper`: |
|
| 179 |
+ |
|
| 180 |
+ * `dm.basesize` |
|
| 181 |
+ |
|
| 182 |
+ Specifies the size to use when creating the base device, which limits the |
|
| 183 |
+ size of images and containers. The default value is 10G. Note, thin devices |
|
| 184 |
+ are inherently "sparse", so a 10G device which is mostly empty doesn't use |
|
| 185 |
+ 10 GB of space on the pool. However, the filesystem will use more space for |
|
| 186 |
+ the empty case the larger the device is. |
|
| 187 |
+ |
|
| 188 |
+ **Warning:** This value affects the system-wide "base" empty filesystem |
|
| 189 |
+ that may already be initialized and inherited by pulled images. Typically, |
|
| 190 |
+ a change to this value will require additional steps to take effect: |
|
| 191 |
+ |
|
| 192 |
+ $ sudo service docker stop |
|
| 193 |
+ $ sudo rm -rf /var/lib/docker |
|
| 194 |
+ $ sudo service docker start |
|
| 195 |
+ |
|
| 196 |
+ Example use: |
|
| 197 |
+ |
|
| 198 |
+ $ docker -d --storage-opt dm.basesize=20G |
|
| 199 |
+ |
|
| 200 |
+ * `dm.loopdatasize` |
|
| 201 |
+ |
|
| 202 |
+ Specifies the size to use when creating the loopback file for the "data" |
|
| 203 |
+ device which is used for the thin pool. The default size is 100G. Note that |
|
| 204 |
+ the file is sparse, so it will not initially take up this much space. |
|
| 205 |
+ |
|
| 206 |
+ Example use: |
|
| 207 |
+ |
|
| 208 |
+ $ docker -d --storage-opt dm.loopdatasize=200G |
|
| 209 |
+ |
|
| 210 |
+ * `dm.loopmetadatasize` |
|
| 211 |
+ |
|
| 212 |
+ Specifies the size to use when creating the loopback file for the |
|
| 213 |
+ "metadata" device which is used for the thin pool. The default size is 2G. |
|
| 214 |
+ Note that the file is sparse, so it will not initially take up this much |
|
| 215 |
+ space. |
|
| 216 |
+ |
|
| 217 |
+ Example use: |
|
| 218 |
+ |
|
| 219 |
+ $ docker -d --storage-opt dm.loopmetadatasize=4G |
|
| 220 |
+ |
|
| 221 |
+ * `dm.fs` |
|
| 222 |
+ |
|
| 223 |
+ Specifies the filesystem type to use for the base device. The supported |
|
| 224 |
+ options are "ext4" and "xfs". The default is "ext4" |
|
| 225 |
+ |
|
| 226 |
+ Example use: |
|
| 227 |
+ |
|
| 228 |
+ $ docker -d --storage-opt dm.fs=xfs |
|
| 229 |
+ |
|
| 230 |
+ * `dm.mkfsarg` |
|
| 231 |
+ |
|
| 232 |
+ Specifies extra mkfs arguments to be used when creating the base device. |
|
| 233 |
+ |
|
| 234 |
+ Example use: |
|
| 235 |
+ |
|
| 236 |
+ $ docker -d --storage-opt "dm.mkfsarg=-O ^has_journal" |
|
| 237 |
+ |
|
| 238 |
+ * `dm.mountopt` |
|
| 239 |
+ |
|
| 240 |
+ Specifies extra mount options used when mounting the thin devices. |
|
| 241 |
+ |
|
| 242 |
+ Example use: |
|
| 243 |
+ |
|
| 244 |
+ $ docker -d --storage-opt dm.mountopt=nodiscard |
|
| 245 |
+ |
|
| 246 |
+ * `dm.datadev` |
|
| 247 |
+ |
|
| 248 |
+ Specifies a custom blockdevice to use for data for the thin pool. |
|
| 249 |
+ |
|
| 250 |
+ If using a block device for device mapper storage, ideally both datadev and |
|
| 251 |
+ metadatadev should be specified to completely avoid using the loopback |
|
| 252 |
+ device. |
|
| 253 |
+ |
|
| 254 |
+ Example use: |
|
| 255 |
+ |
|
| 256 |
+ $ docker -d \ |
|
| 257 |
+ --storage-opt dm.datadev=/dev/sdb1 \ |
|
| 258 |
+ --storage-opt dm.metadatadev=/dev/sdc1 |
|
| 259 |
+ |
|
| 260 |
+ * `dm.metadatadev` |
|
| 261 |
+ |
|
| 262 |
+ Specifies a custom blockdevice to use for metadata for the thin pool. |
|
| 263 |
+ |
|
| 264 |
+ For best performance the metadata should be on a different spindle than the |
|
| 265 |
+ data, or even better on an SSD. |
|
| 266 |
+ |
|
| 267 |
+ If setting up a new metadata pool it is required to be valid. This can be |
|
| 268 |
+ achieved by zeroing the first 4k to indicate empty metadata, like this: |
|
| 269 |
+ |
|
| 270 |
+ $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1 |
|
| 271 |
+ |
|
| 272 |
+ Example use: |
|
| 273 |
+ |
|
| 274 |
+ $ docker -d \ |
|
| 275 |
+ --storage-opt dm.datadev=/dev/sdb1 \ |
|
| 276 |
+ --storage-opt dm.metadatadev=/dev/sdc1 |
|
| 277 |
+ |
|
| 278 |
+ * `dm.blocksize` |
|
| 279 |
+ |
|
| 280 |
+ Specifies a custom blocksize to use for the thin pool. The default |
|
| 281 |
+ blocksize is 64K. |
|
| 282 |
+ |
|
| 283 |
+ Example use: |
|
| 284 |
+ |
|
| 285 |
+ $ docker -d --storage-opt dm.blocksize=512K |
|
| 286 |
+ |
|
| 287 |
+ * `dm.blkdiscard` |
|
| 288 |
+ |
|
| 289 |
+ Enables or disables the use of blkdiscard when removing devicemapper |
|
| 290 |
+ devices. This is enabled by default (only) if using loopback devices and is |
|
| 291 |
+ required to resparsify the loopback file on image/container removal. |
|
| 292 |
+ |
|
| 293 |
+ Disabling this on loopback can lead to *much* faster container removal |
|
| 294 |
+ times, but will make the space used in `/var/lib/docker` directory not be |
|
| 295 |
+ returned to the system for other use when containers are removed. |
|
| 296 |
+ |
|
| 297 |
+ Example use: |
|
| 298 |
+ |
|
| 299 |
+ $ docker -d --storage-opt dm.blkdiscard=false |
|
| 300 |
+ |
|
| 301 |
+ * `dm.override_udev_sync_check` |
|
| 302 |
+ |
|
| 303 |
+ Overrides the `udev` synchronization checks between `devicemapper` and `udev`. |
|
| 304 |
+ `udev` is the device manager for the Linux kernel. |
|
| 305 |
+ |
|
| 306 |
+ To view the `udev` sync support of a Docker daemon that is using the |
|
| 307 |
+ `devicemapper` driver, run: |
|
| 308 |
+ |
|
| 309 |
+ $ docker info |
|
| 310 |
+ [...] |
|
| 311 |
+ Udev Sync Supported: true |
|
| 312 |
+ [...] |
|
| 313 |
+ |
|
| 314 |
+ When `udev` sync support is `true`, then `devicemapper` and udev can |
|
| 315 |
+ coordinate the activation and deactivation of devices for containers. |
|
| 316 |
+ |
|
| 317 |
+ When `udev` sync support is `false`, a race condition occurs between |
|
| 318 |
+ the`devicemapper` and `udev` during create and cleanup. The race condition |
|
| 319 |
+ results in errors and failures. (For information on these failures, see |
|
| 320 |
+ [docker#4036](https://github.com/docker/docker/issues/4036)) |
|
| 321 |
+ |
|
| 322 |
+ To allow the `docker` daemon to start, regardless of `udev` sync not being |
|
| 323 |
+ supported, set `dm.override_udev_sync_check` to true: |
|
| 324 |
+ |
|
| 325 |
+ $ docker -d --storage-opt dm.override_udev_sync_check=true |
|
| 326 |
+ |
|
| 327 |
+ When this value is `true`, the `devicemapper` continues and simply warns |
|
| 328 |
+ you the errors are happening. |
|
| 329 |
+ |
|
| 330 |
+ > **Note:** |
|
| 331 |
+ > The ideal is to pursue a `docker` daemon and environment that does |
|
| 332 |
+ > support synchronizing with `udev`. For further discussion on this |
|
| 333 |
+ > topic, see [docker#4036](https://github.com/docker/docker/issues/4036). |
|
| 334 |
+ > Otherwise, set this flag for migrating existing Docker daemons to |
|
| 335 |
+ > a daemon with a supported environment. |
|
| 336 |
+ |
|
| 337 |
+## Docker execdriver option |
|
| 338 |
+ |
|
| 339 |
+Currently supported options of `zfs`: |
|
| 340 |
+ |
|
| 341 |
+ * `zfs.fsname` |
|
| 342 |
+ |
|
| 343 |
+ Set zfs filesystem under which docker will create its own datasets. |
|
| 344 |
+ By default docker will pick up the zfs filesystem where docker graph |
|
| 345 |
+ (`/var/lib/docker`) is located. |
|
| 346 |
+ |
|
| 347 |
+ Example use: |
|
| 348 |
+ |
|
| 349 |
+ $ docker -d -s zfs --storage-opt zfs.fsname=zroot/docker |
|
| 350 |
+ |
|
| 351 |
+The Docker daemon uses a specifically built `libcontainer` execution driver as |
|
| 352 |
+its interface to the Linux kernel `namespaces`, `cgroups`, and `SELinux`. |
|
| 353 |
+ |
|
| 354 |
+There is still legacy support for the original [LXC userspace tools]( |
|
| 355 |
+https://linuxcontainers.org/) via the `lxc` execution driver, however, this is |
|
| 356 |
+not where the primary development of new functionality is taking place. |
|
| 357 |
+Add `-e lxc` to the daemon flags to use the `lxc` execution driver. |
|
| 358 |
+ |
|
| 359 |
+## Options for the native execdriver |
|
| 360 |
+ |
|
| 361 |
+You can configure the `native` (libcontainer) execdriver using options specified |
|
| 362 |
+with the `--exec-opt` flag. All the flag's options have the `native` prefix. A |
|
| 363 |
+single `native.cgroupdriver` option is available. |
|
| 364 |
+ |
|
| 365 |
+The `native.cgroupdriver` option specifies the management of the container's |
|
| 366 |
+cgroups. You can specify `cgroupfs` or `systemd`. If you specify `systemd` and |
|
| 367 |
+it is not available, the system uses `cgroupfs`. By default, if no option is |
|
| 368 |
+specified, the execdriver first tries `systemd` and falls back to `cgroupfs`. |
|
| 369 |
+This example sets the execdriver to `cgroupfs`: |
|
| 370 |
+ |
|
| 371 |
+ $ sudo docker -d --exec-opt native.cgroupdriver=cgroupfs |
|
| 372 |
+ |
|
| 373 |
+Setting this option applies to all containers the daemon launches. |
|
| 374 |
+ |
|
| 375 |
+## Daemon DNS options |
|
| 376 |
+ |
|
| 377 |
+To set the DNS server for all Docker containers, use |
|
| 378 |
+`docker -d --dns 8.8.8.8`. |
|
| 379 |
+ |
|
| 380 |
+To set the DNS search domain for all Docker containers, use |
|
| 381 |
+`docker -d --dns-search example.com`. |
|
| 382 |
+ |
|
| 383 |
+## Insecure registries |
|
| 384 |
+ |
|
| 385 |
+Docker considers a private registry either secure or insecure. In the rest of |
|
| 386 |
+this section, *registry* is used for *private registry*, and `myregistry:5000` |
|
| 387 |
+is a placeholder example for a private registry. |
|
| 388 |
+ |
|
| 389 |
+A secure registry uses TLS and a copy of its CA certificate is placed on the |
|
| 390 |
+Docker host at `/etc/docker/certs.d/myregistry:5000/ca.crt`. An insecure |
|
| 391 |
+registry is either not using TLS (i.e., listening on plain text HTTP), or is |
|
| 392 |
+using TLS with a CA certificate not known by the Docker daemon. The latter can |
|
| 393 |
+happen when the certificate was not found under |
|
| 394 |
+`/etc/docker/certs.d/myregistry:5000/`, or if the certificate verification |
|
| 395 |
+failed (i.e., wrong CA). |
|
| 396 |
+ |
|
| 397 |
+By default, Docker assumes all, but local (see local registries below), |
|
| 398 |
+registries are secure. Communicating with an insecure registry is not possible |
|
| 399 |
+if Docker assumes that registry is secure. In order to communicate with an |
|
| 400 |
+insecure registry, the Docker daemon requires `--insecure-registry` in one of |
|
| 401 |
+the following two forms: |
|
| 402 |
+ |
|
| 403 |
+* `--insecure-registry myregistry:5000` tells the Docker daemon that |
|
| 404 |
+ myregistry:5000 should be considered insecure. |
|
| 405 |
+* `--insecure-registry 10.1.0.0/16` tells the Docker daemon that all registries |
|
| 406 |
+ whose domain resolve to an IP address is part of the subnet described by the |
|
| 407 |
+ CIDR syntax, should be considered insecure. |
|
| 408 |
+ |
|
| 409 |
+The flag can be used multiple times to allow multiple registries to be marked |
|
| 410 |
+as insecure. |
|
| 411 |
+ |
|
| 412 |
+If an insecure registry is not marked as insecure, `docker pull`, |
|
| 413 |
+`docker push`, and `docker search` will result in an error message prompting |
|
| 414 |
+the user to either secure or pass the `--insecure-registry` flag to the Docker |
|
| 415 |
+daemon as described above. |
|
| 416 |
+ |
|
| 417 |
+Local registries, whose IP address falls in the 127.0.0.0/8 range, are |
|
| 418 |
+automatically marked as insecure as of Docker 1.3.2. It is not recommended to |
|
| 419 |
+rely on this, as it may change in the future. |
|
| 420 |
+ |
|
| 421 |
+## Running a Docker daemon behind a HTTPS_PROXY |
|
| 422 |
+ |
|
| 423 |
+When running inside a LAN that uses a `HTTPS` proxy, the Docker Hub |
|
| 424 |
+certificates will be replaced by the proxy's certificates. These certificates |
|
| 425 |
+need to be added to your Docker host's configuration: |
|
| 426 |
+ |
|
| 427 |
+1. Install the `ca-certificates` package for your distribution |
|
| 428 |
+2. Ask your network admin for the proxy's CA certificate and append them to |
|
| 429 |
+ `/etc/pki/tls/certs/ca-bundle.crt` |
|
| 430 |
+3. Then start your Docker daemon with `HTTPS_PROXY=http://username:password@proxy:port/ docker -d`. |
|
| 431 |
+ The `username:` and `password@` are optional - and are only needed if your |
|
| 432 |
+ proxy is set up to require authentication. |
|
| 433 |
+ |
|
| 434 |
+This will only add the proxy and authentication to the Docker daemon's requests - |
|
| 435 |
+your `docker build`s and running containers will need extra configuration to |
|
| 436 |
+use the proxy |
|
| 437 |
+ |
|
| 438 |
+## Default Ulimits |
|
| 439 |
+ |
|
| 440 |
+`--default-ulimit` allows you to set the default `ulimit` options to use for |
|
| 441 |
+all containers. It takes the same options as `--ulimit` for `docker run`. If |
|
| 442 |
+these defaults are not set, `ulimit` settings will be inherited, if not set on |
|
| 443 |
+`docker run`, from the Docker daemon. Any `--ulimit` options passed to |
|
| 444 |
+`docker run` will overwrite these defaults. |
|
| 445 |
+ |
|
| 446 |
+## Miscellaneous options |
|
| 447 |
+ |
|
| 448 |
+IP masquerading uses address translation to allow containers without a public |
|
| 449 |
+IP to talk to other machines on the Internet. This may interfere with some |
|
| 450 |
+network topologies and can be disabled with --ip-masq=false. |
|
| 451 |
+ |
|
| 452 |
+Docker supports softlinks for the Docker data directory (`/var/lib/docker`) and |
|
| 453 |
+for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be |
|
| 454 |
+set like this: |
|
| 455 |
+ |
|
| 456 |
+ DOCKER_TMPDIR=/mnt/disk2/tmp /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1 |
|
| 457 |
+ # or |
|
| 458 |
+ export DOCKER_TMPDIR=/mnt/disk2/tmp |
|
| 459 |
+ /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1 |
|
| 460 |
+ |
|
| 461 |
+ |
| 0 | 462 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,39 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "diff" |
|
| 2 |
+description = "The diff command description and usage" |
|
| 3 |
+keywords = ["list, changed, files, container"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# diff |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker diff CONTAINER |
|
| 12 |
+ |
|
| 13 |
+ Inspect changes on a container's filesystem |
|
| 14 |
+ |
|
| 15 |
+List the changed files and directories in a container᾿s filesystem |
|
| 16 |
+ There are 3 events that are listed in the `diff`: |
|
| 17 |
+ |
|
| 18 |
+1. `A` - Add |
|
| 19 |
+2. `D` - Delete |
|
| 20 |
+3. `C` - Change |
|
| 21 |
+ |
|
| 22 |
+For example: |
|
| 23 |
+ |
|
| 24 |
+ $ docker diff 7bb0e258aefe |
|
| 25 |
+ |
|
| 26 |
+ C /dev |
|
| 27 |
+ A /dev/kmsg |
|
| 28 |
+ C /etc |
|
| 29 |
+ A /etc/mtab |
|
| 30 |
+ A /go |
|
| 31 |
+ A /go/src |
|
| 32 |
+ A /go/src/github.com |
|
| 33 |
+ A /go/src/github.com/docker |
|
| 34 |
+ A /go/src/github.com/docker/docker |
|
| 35 |
+ A /go/src/github.com/docker/docker/.git |
|
| 36 |
+ .... |
| 0 | 37 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,136 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "events" |
|
| 2 |
+description = "The events command description and usage" |
|
| 3 |
+keywords = ["events, container, report"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# events |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker events [OPTIONS] |
|
| 12 |
+ |
|
| 13 |
+ Get real time events from the server |
|
| 14 |
+ |
|
| 15 |
+ -f, --filter=[] Filter output based on conditions provided |
|
| 16 |
+ --since="" Show all events created since timestamp |
|
| 17 |
+ --until="" Stream events until this timestamp |
|
| 18 |
+ |
|
| 19 |
+Docker containers will report the following events: |
|
| 20 |
+ |
|
| 21 |
+ create, destroy, die, export, kill, oom, pause, restart, start, stop, unpause |
|
| 22 |
+ |
|
| 23 |
+and Docker images will report: |
|
| 24 |
+ |
|
| 25 |
+ untag, delete |
|
| 26 |
+ |
|
| 27 |
+The `--since` and `--until` parameters can be Unix timestamps, RFC3339 |
|
| 28 |
+dates or Go duration strings (e.g. `10m`, `1h30m`) computed relative to |
|
| 29 |
+client machine’s time. If you do not provide the --since option, the command |
|
| 30 |
+returns only new and/or live events. |
|
| 31 |
+ |
|
| 32 |
+## Filtering |
|
| 33 |
+ |
|
| 34 |
+The filtering flag (`-f` or `--filter`) format is of "key=value". If you would |
|
| 35 |
+like to use multiple filters, pass multiple flags (e.g., |
|
| 36 |
+`--filter "foo=bar" --filter "bif=baz"`) |
|
| 37 |
+ |
|
| 38 |
+Using the same filter multiple times will be handled as a *OR*; for example |
|
| 39 |
+`--filter container=588a23dac085 --filter container=a8f7720b8c22` will display |
|
| 40 |
+events for container 588a23dac085 *OR* container a8f7720b8c22 |
|
| 41 |
+ |
|
| 42 |
+Using multiple filters will be handled as a *AND*; for example |
|
| 43 |
+`--filter container=588a23dac085 --filter event=start` will display events for |
|
| 44 |
+container container 588a23dac085 *AND* the event type is *start* |
|
| 45 |
+ |
|
| 46 |
+The currently supported filters are: |
|
| 47 |
+ |
|
| 48 |
+* container |
|
| 49 |
+* event |
|
| 50 |
+* image |
|
| 51 |
+ |
|
| 52 |
+## Examples |
|
| 53 |
+ |
|
| 54 |
+You'll need two shells for this example. |
|
| 55 |
+ |
|
| 56 |
+**Shell 1: Listening for events:** |
|
| 57 |
+ |
|
| 58 |
+ $ docker events |
|
| 59 |
+ |
|
| 60 |
+**Shell 2: Start and Stop containers:** |
|
| 61 |
+ |
|
| 62 |
+ $ docker start 4386fb97867d |
|
| 63 |
+ $ docker stop 4386fb97867d |
|
| 64 |
+ $ docker stop 7805c1d35632 |
|
| 65 |
+ |
|
| 66 |
+**Shell 1: (Again .. now showing events):** |
|
| 67 |
+ |
|
| 68 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start |
|
| 69 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 70 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 71 |
+ 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 72 |
+ 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 73 |
+ |
|
| 74 |
+**Show events in the past from a specified time:** |
|
| 75 |
+ |
|
| 76 |
+ $ docker events --since 1378216169 |
|
| 77 |
+ 2014-03-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 78 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 79 |
+ 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 80 |
+ 2014-03-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 81 |
+ |
|
| 82 |
+ $ docker events --since '2013-09-03' |
|
| 83 |
+ 2014-09-03T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start |
|
| 84 |
+ 2014-09-03T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 85 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 86 |
+ 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 87 |
+ 2014-09-03T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 88 |
+ |
|
| 89 |
+ $ docker events --since '2013-09-03T15:49:29' |
|
| 90 |
+ 2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 91 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 92 |
+ 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 93 |
+ 2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 94 |
+ |
|
| 95 |
+This example outputs all events that were generated in the last 3 minutes, |
|
| 96 |
+relative to the current time on the client machine: |
|
| 97 |
+ |
|
| 98 |
+ $ docker events --since '3m' |
|
| 99 |
+ 2015-05-12T11:51:30.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 100 |
+ 2015-05-12T15:52:12.999999999Z07:00 4 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 101 |
+ 2015-05-12T15:53:45.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 102 |
+ 2015-05-12T15:54:03.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 103 |
+ |
|
| 104 |
+**Filter events:** |
|
| 105 |
+ |
|
| 106 |
+ $ docker events --filter 'event=stop' |
|
| 107 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 108 |
+ 2014-09-03T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 109 |
+ |
|
| 110 |
+ $ docker events --filter 'image=ubuntu-1:14.04' |
|
| 111 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start |
|
| 112 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 113 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 114 |
+ |
|
| 115 |
+ $ docker events --filter 'container=7805c1d35632' |
|
| 116 |
+ 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 117 |
+ 2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 118 |
+ |
|
| 119 |
+ $ docker events --filter 'container=7805c1d35632' --filter 'container=4386fb97867d' |
|
| 120 |
+ 2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 121 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 122 |
+ 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 123 |
+ 2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 124 |
+ |
|
| 125 |
+ $ docker events --filter 'container=7805c1d35632' --filter 'event=stop' |
|
| 126 |
+ 2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 127 |
+ |
|
| 128 |
+ $ docker events --filter 'container=container_1' --filter 'container=container_2' |
|
| 129 |
+ 2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die |
|
| 130 |
+ 2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop |
|
| 131 |
+ 2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die |
|
| 132 |
+ 2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop |
|
| 133 |
+ |
| 0 | 134 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,55 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "exec" |
|
| 2 |
+description = "The exec command description and usage" |
|
| 3 |
+keywords = ["command, container, run, execute"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# exec |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...] |
|
| 12 |
+ |
|
| 13 |
+ Run a command in a running container |
|
| 14 |
+ |
|
| 15 |
+ -d, --detach=false Detached mode: run command in the background |
|
| 16 |
+ -i, --interactive=false Keep STDIN open even if not attached |
|
| 17 |
+ -t, --tty=false Allocate a pseudo-TTY |
|
| 18 |
+ -u, --user= Username or UID (format: <name|uid>[:<group|gid>]) |
|
| 19 |
+ |
|
| 20 |
+The `docker exec` command runs a new command in a running container. |
|
| 21 |
+ |
|
| 22 |
+The command started using `docker exec` only runs while the container's primary |
|
| 23 |
+process (`PID 1`) is running, and it is not restarted if the container is |
|
| 24 |
+restarted. |
|
| 25 |
+ |
|
| 26 |
+If the container is paused, then the `docker exec` command will fail with an error: |
|
| 27 |
+ |
|
| 28 |
+ $ docker pause test |
|
| 29 |
+ test |
|
| 30 |
+ $ docker ps |
|
| 31 |
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
|
| 32 |
+ 1ae3b36715d2 ubuntu:latest "bash" 17 seconds ago Up 16 seconds (Paused) test |
|
| 33 |
+ $ docker exec test ls |
|
| 34 |
+ FATA[0000] Error response from daemon: Container test is paused, unpause the container before exec |
|
| 35 |
+ $ echo $? |
|
| 36 |
+ 1 |
|
| 37 |
+ |
|
| 38 |
+## Examples |
|
| 39 |
+ |
|
| 40 |
+ $ docker run --name ubuntu_bash --rm -i -t ubuntu bash |
|
| 41 |
+ |
|
| 42 |
+This will create a container named `ubuntu_bash` and start a Bash session. |
|
| 43 |
+ |
|
| 44 |
+ $ docker exec -d ubuntu_bash touch /tmp/execWorks |
|
| 45 |
+ |
|
| 46 |
+This will create a new file `/tmp/execWorks` inside the running container |
|
| 47 |
+`ubuntu_bash`, in the background. |
|
| 48 |
+ |
|
| 49 |
+ $ docker exec -it ubuntu_bash bash |
|
| 50 |
+ |
|
| 51 |
+This will create a new Bash session in the container `ubuntu_bash`. |
|
| 52 |
+ |
| 0 | 53 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,38 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "export" |
|
| 2 |
+description = "The export command description and usage" |
|
| 3 |
+keywords = ["export, file, system, container"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# export |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker export [OPTIONS] CONTAINER |
|
| 12 |
+ |
|
| 13 |
+ Export the contents of a filesystem to a tar archive (streamed to STDOUT by default). |
|
| 14 |
+ |
|
| 15 |
+ -o, --output="" Write to a file, instead of STDOUT |
|
| 16 |
+ |
|
| 17 |
+ Produces a tarred repository to the standard output stream. |
|
| 18 |
+ |
|
| 19 |
+ |
|
| 20 |
+ For example: |
|
| 21 |
+ |
|
| 22 |
+ $ docker export red_panda > latest.tar |
|
| 23 |
+ |
|
| 24 |
+ Or |
|
| 25 |
+ |
|
| 26 |
+ $ docker export --output="latest.tar" red_panda |
|
| 27 |
+ |
|
| 28 |
+The `docker export` command does not export the contents of volumes associated |
|
| 29 |
+with the container. If a volume is mounted on top of an existing directory in |
|
| 30 |
+the container, `docker export` will export the contents of the *underlying* |
|
| 31 |
+directory, not the contents of the volume. |
|
| 32 |
+ |
|
| 33 |
+Refer to [Backup, restore, or migrate data |
|
| 34 |
+volumes](/userguide/dockervolumes/#backup-restore-or-migrate-data-volumes) in |
|
| 35 |
+the user guide for examples on exporting data in a volume. |
| 0 | 36 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,42 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "history" |
|
| 2 |
+description = "The history command description and usage" |
|
| 3 |
+keywords = ["docker, image, history"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# history |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker history [OPTIONS] IMAGE |
|
| 12 |
+ |
|
| 13 |
+ Show the history of an image |
|
| 14 |
+ |
|
| 15 |
+ -H, --human=true Print sizes and dates in human readable format |
|
| 16 |
+ --no-trunc=false Don't truncate output |
|
| 17 |
+ -q, --quiet=false Only show numeric IDs |
|
| 18 |
+ |
|
| 19 |
+To see how the `docker:latest` image was built: |
|
| 20 |
+ |
|
| 21 |
+ $ docker history docker |
|
| 22 |
+ IMAGE CREATED CREATED BY SIZE COMMENT |
|
| 23 |
+ 3e23a5875458 8 days ago /bin/sh -c #(nop) ENV LC_ALL=C.UTF-8 0 B |
|
| 24 |
+ 8578938dd170 8 days ago /bin/sh -c dpkg-reconfigure locales && loc 1.245 MB |
|
| 25 |
+ be51b77efb42 8 days ago /bin/sh -c apt-get update && apt-get install 338.3 MB |
|
| 26 |
+ 4b137612be55 6 weeks ago /bin/sh -c #(nop) ADD jessie.tar.xz in / 121 MB |
|
| 27 |
+ 750d58736b4b 6 weeks ago /bin/sh -c #(nop) MAINTAINER Tianon Gravi <ad 0 B |
|
| 28 |
+ 511136ea3c5a 9 months ago 0 B Imported from - |
|
| 29 |
+ |
|
| 30 |
+To see how the `docker:apache` image was added to a container's base image: |
|
| 31 |
+ |
|
| 32 |
+ $ docker history docker:scm |
|
| 33 |
+ IMAGE CREATED CREATED BY SIZE COMMENT |
|
| 34 |
+ 2ac9d1098bf1 3 months ago /bin/bash 241.4 MB Added Apache to Fedora base image |
|
| 35 |
+ 88b42ffd1f7c 5 months ago /bin/sh -c #(nop) ADD file:1fd8d7f9f6557cafc7 373.7 MB |
|
| 36 |
+ c69cab00d6ef 5 months ago /bin/sh -c #(nop) MAINTAINER Lokesh Mandvekar 0 B |
|
| 37 |
+ 511136ea3c5a 19 months ago 0 B Imported from - |
|
| 38 |
+ |
|
| 39 |
+ |
| 0 | 40 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,127 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "images" |
|
| 2 |
+description = "The images command description and usage" |
|
| 3 |
+keywords = ["list, docker, images"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# images |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker images [OPTIONS] [REPOSITORY] |
|
| 12 |
+ |
|
| 13 |
+ List images |
|
| 14 |
+ |
|
| 15 |
+ -a, --all=false Show all images (default hides intermediate images) |
|
| 16 |
+ --digests=false Show digests |
|
| 17 |
+ -f, --filter=[] Filter output based on conditions provided |
|
| 18 |
+ --help=false Print usage |
|
| 19 |
+ --no-trunc=false Don't truncate output |
|
| 20 |
+ -q, --quiet=false Only show numeric IDs |
|
| 21 |
+ |
|
| 22 |
+The default `docker images` will show all top level |
|
| 23 |
+images, their repository and tags, and their virtual size. |
|
| 24 |
+ |
|
| 25 |
+Docker images have intermediate layers that increase reusability, |
|
| 26 |
+decrease disk usage, and speed up `docker build` by |
|
| 27 |
+allowing each step to be cached. These intermediate layers are not shown |
|
| 28 |
+by default. |
|
| 29 |
+ |
|
| 30 |
+The `VIRTUAL SIZE` is the cumulative space taken up by the image and all |
|
| 31 |
+its parent images. This is also the disk space used by the contents of the |
|
| 32 |
+Tar file created when you `docker save` an image. |
|
| 33 |
+ |
|
| 34 |
+An image will be listed more than once if it has multiple repository names |
|
| 35 |
+or tags. This single image (identifiable by its matching `IMAGE ID`) |
|
| 36 |
+uses up the `VIRTUAL SIZE` listed only once. |
|
| 37 |
+ |
|
| 38 |
+### Listing the most recently created images |
|
| 39 |
+ |
|
| 40 |
+ $ docker images |
|
| 41 |
+ REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 42 |
+ <none> <none> 77af4d6b9913 19 hours ago 1.089 GB |
|
| 43 |
+ committ latest b6fa739cedf5 19 hours ago 1.089 GB |
|
| 44 |
+ <none> <none> 78a85c484f71 19 hours ago 1.089 GB |
|
| 45 |
+ docker latest 30557a29d5ab 20 hours ago 1.089 GB |
|
| 46 |
+ <none> <none> 5ed6274db6ce 24 hours ago 1.089 GB |
|
| 47 |
+ postgres 9 746b819f315e 4 days ago 213.4 MB |
|
| 48 |
+ postgres 9.3 746b819f315e 4 days ago 213.4 MB |
|
| 49 |
+ postgres 9.3.5 746b819f315e 4 days ago 213.4 MB |
|
| 50 |
+ postgres latest 746b819f315e 4 days ago 213.4 MB |
|
| 51 |
+ |
|
| 52 |
+ |
|
| 53 |
+## Listing the full length image IDs |
|
| 54 |
+ |
|
| 55 |
+ $ docker images --no-trunc |
|
| 56 |
+ REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 57 |
+ <none> <none> 77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB |
|
| 58 |
+ committest latest b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB |
|
| 59 |
+ <none> <none> 78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB |
|
| 60 |
+ docker latest 30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB |
|
| 61 |
+ <none> <none> 0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 1.089 GB |
|
| 62 |
+ <none> <none> 18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 1.082 GB |
|
| 63 |
+ <none> <none> f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 1.089 GB |
|
| 64 |
+ tryout latest 2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 131.5 MB |
|
| 65 |
+ <none> <none> 5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 1.089 GB |
|
| 66 |
+ |
|
| 67 |
+## Listing image digests |
|
| 68 |
+ |
|
| 69 |
+Images that use the v2 or later format have a content-addressable identifier |
|
| 70 |
+called a `digest`. As long as the input used to generate the image is |
|
| 71 |
+unchanged, the digest value is predictable. To list image digest values, use |
|
| 72 |
+the `--digests` flag: |
|
| 73 |
+ |
|
| 74 |
+ $ docker images --digests |
|
| 75 |
+ REPOSITORY TAG DIGEST IMAGE ID CREATED VIRTUAL SIZE |
|
| 76 |
+ localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB |
|
| 77 |
+ |
|
| 78 |
+When pushing or pulling to a 2.0 registry, the `push` or `pull` command |
|
| 79 |
+output includes the image digest. You can `pull` using a digest value. You can |
|
| 80 |
+also reference by digest in `create`, `run`, and `rmi` commands, as well as the |
|
| 81 |
+`FROM` image reference in a Dockerfile. |
|
| 82 |
+ |
|
| 83 |
+## Filtering |
|
| 84 |
+ |
|
| 85 |
+The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more |
|
| 86 |
+than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`) |
|
| 87 |
+ |
|
| 88 |
+The currently supported filters are: |
|
| 89 |
+ |
|
| 90 |
+* dangling (boolean - true or false) |
|
| 91 |
+* label (`label=<key>` or `label=<key>=<value>`) |
|
| 92 |
+ |
|
| 93 |
+##### Untagged images |
|
| 94 |
+ |
|
| 95 |
+ $ docker images --filter "dangling=true" |
|
| 96 |
+ |
|
| 97 |
+ REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 98 |
+ <none> <none> 8abc22fbb042 4 weeks ago 0 B |
|
| 99 |
+ <none> <none> 48e5f45168b9 4 weeks ago 2.489 MB |
|
| 100 |
+ <none> <none> bf747efa0e2f 4 weeks ago 0 B |
|
| 101 |
+ <none> <none> 980fe10e5736 12 weeks ago 101.4 MB |
|
| 102 |
+ <none> <none> dea752e4e117 12 weeks ago 101.4 MB |
|
| 103 |
+ <none> <none> 511136ea3c5a 8 months ago 0 B |
|
| 104 |
+ |
|
| 105 |
+This will display untagged images, that are the leaves of the images tree (not |
|
| 106 |
+intermediary layers). These images occur when a new build of an image takes the |
|
| 107 |
+`repo:tag` away from the image ID, leaving it untagged. A warning will be issued |
|
| 108 |
+if trying to remove an image when a container is presently using it. |
|
| 109 |
+By having this flag it allows for batch cleanup. |
|
| 110 |
+ |
|
| 111 |
+Ready for use by `docker rmi ...`, like: |
|
| 112 |
+ |
|
| 113 |
+ $ docker rmi $(docker images -f "dangling=true" -q) |
|
| 114 |
+ |
|
| 115 |
+ 8abc22fbb042 |
|
| 116 |
+ 48e5f45168b9 |
|
| 117 |
+ bf747efa0e2f |
|
| 118 |
+ 980fe10e5736 |
|
| 119 |
+ dea752e4e117 |
|
| 120 |
+ 511136ea3c5a |
|
| 121 |
+ |
|
| 122 |
+NOTE: Docker will warn you if any containers exist that are using these untagged images. |
|
| 123 |
+ |
|
| 124 |
+ |
| 0 | 125 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,58 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "import" |
|
| 2 |
+description = "The import command description and usage" |
|
| 3 |
+keywords = ["import, file, system, container"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# import |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker import URL|- [REPOSITORY[:TAG]] |
|
| 12 |
+ |
|
| 13 |
+ Create an empty filesystem image and import the contents of the |
|
| 14 |
+ tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then |
|
| 15 |
+ optionally tag it. |
|
| 16 |
+ |
|
| 17 |
+ -c, --change=[] Apply specified Dockerfile instructions while importing the image |
|
| 18 |
+ |
|
| 19 |
+URLs must start with `http` and point to a single file archive (.tar, |
|
| 20 |
+.tar.gz, .tgz, .bzip, .tar.xz, or .txz) containing a root filesystem. If |
|
| 21 |
+you would like to import from a local directory or archive, you can use |
|
| 22 |
+the `-` parameter to take the data from `STDIN`. |
|
| 23 |
+ |
|
| 24 |
+The `--change` option will apply `Dockerfile` instructions to the image |
|
| 25 |
+that is created. |
|
| 26 |
+Supported `Dockerfile` instructions: |
|
| 27 |
+`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR` |
|
| 28 |
+ |
|
| 29 |
+## Examples |
|
| 30 |
+ |
|
| 31 |
+**Import from a remote location:** |
|
| 32 |
+ |
|
| 33 |
+This will create a new untagged image. |
|
| 34 |
+ |
|
| 35 |
+ $ docker import http://example.com/exampleimage.tgz |
|
| 36 |
+ |
|
| 37 |
+**Import from a local file:** |
|
| 38 |
+ |
|
| 39 |
+Import to docker via pipe and `STDIN`. |
|
| 40 |
+ |
|
| 41 |
+ $ cat exampleimage.tgz | docker import - exampleimagelocal:new |
|
| 42 |
+ |
|
| 43 |
+**Import from a local directory:** |
|
| 44 |
+ |
|
| 45 |
+ $ sudo tar -c . | docker import - exampleimagedir |
|
| 46 |
+ |
|
| 47 |
+**Import from a local directory with new configurations:** |
|
| 48 |
+ |
|
| 49 |
+ $ sudo tar -c . | docker import --change "ENV DEBUG true" - exampleimagedir |
|
| 50 |
+ |
|
| 51 |
+Note the `sudo` in this example – you must preserve |
|
| 52 |
+the ownership of the files (especially root ownership) during the |
|
| 53 |
+archiving with tar. If you are not root (or the sudo command) when you |
|
| 54 |
+tar, then the ownerships might not get preserved. |
|
| 55 |
+ |
| 0 | 56 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,57 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "info" |
|
| 2 |
+description = "The info command description and usage" |
|
| 3 |
+keywords = ["display, docker, information"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# info |
|
| 10 |
+ |
|
| 11 |
+ |
|
| 12 |
+ Usage: docker info |
|
| 13 |
+ |
|
| 14 |
+ Display system-wide information |
|
| 15 |
+ |
|
| 16 |
+For example: |
|
| 17 |
+ |
|
| 18 |
+ $ docker -D info |
|
| 19 |
+ Containers: 14 |
|
| 20 |
+ Images: 52 |
|
| 21 |
+ Storage Driver: aufs |
|
| 22 |
+ Root Dir: /var/lib/docker/aufs |
|
| 23 |
+ Backing Filesystem: extfs |
|
| 24 |
+ Dirs: 545 |
|
| 25 |
+ Execution Driver: native-0.2 |
|
| 26 |
+ Logging Driver: json-file |
|
| 27 |
+ Kernel Version: 3.13.0-24-generic |
|
| 28 |
+ Operating System: Ubuntu 14.04 LTS |
|
| 29 |
+ CPUs: 1 |
|
| 30 |
+ Name: prod-server-42 |
|
| 31 |
+ ID: 7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS |
|
| 32 |
+ Total Memory: 2 GiB |
|
| 33 |
+ Debug mode (server): false |
|
| 34 |
+ Debug mode (client): true |
|
| 35 |
+ File Descriptors: 10 |
|
| 36 |
+ Goroutines: 9 |
|
| 37 |
+ System Time: Tue Mar 10 18:38:57 UTC 2015 |
|
| 38 |
+ EventsListeners: 0 |
|
| 39 |
+ Init Path: /usr/bin/docker |
|
| 40 |
+ Docker Root Dir: /var/lib/docker |
|
| 41 |
+ Http Proxy: http://test:test@localhost:8080 |
|
| 42 |
+ Https Proxy: https://test:test@localhost:8080 |
|
| 43 |
+ No Proxy: 9.81.1.160 |
|
| 44 |
+ Username: svendowideit |
|
| 45 |
+ Registry: [https://index.docker.io/v1/] |
|
| 46 |
+ Labels: |
|
| 47 |
+ storage=ssd |
|
| 48 |
+ |
|
| 49 |
+The global `-D` option tells all `docker` commands to output debug information. |
|
| 50 |
+ |
|
| 51 |
+When sending issue reports, please use `docker version` and `docker -D info` to |
|
| 52 |
+ensure we know how your setup is configured. |
|
| 53 |
+ |
|
| 54 |
+ |
| 0 | 55 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,73 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "inspect" |
|
| 2 |
+description = "The inspect command description and usage" |
|
| 3 |
+keywords = ["inspect, container, json"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# inspect |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...] |
|
| 12 |
+ |
|
| 13 |
+ Return low-level information on a container or image |
|
| 14 |
+ |
|
| 15 |
+ -f, --format="" Format the output using the given go template |
|
| 16 |
+ |
|
| 17 |
+By default, this will render all results in a JSON array. If a format is |
|
| 18 |
+specified, the given template will be executed for each result. |
|
| 19 |
+ |
|
| 20 |
+Go's [text/template](http://golang.org/pkg/text/template/) package |
|
| 21 |
+describes all the details of the format. |
|
| 22 |
+ |
|
| 23 |
+## Examples |
|
| 24 |
+ |
|
| 25 |
+**Get an instance's IP address:** |
|
| 26 |
+ |
|
| 27 |
+For the most part, you can pick out any field from the JSON in a fairly |
|
| 28 |
+straightforward manner. |
|
| 29 |
+ |
|
| 30 |
+ $ docker inspect --format='{{.NetworkSettings.IPAddress}}' $INSTANCE_ID
|
|
| 31 |
+ |
|
| 32 |
+**Get an instance's MAC Address:** |
|
| 33 |
+ |
|
| 34 |
+For the most part, you can pick out any field from the JSON in a fairly |
|
| 35 |
+straightforward manner. |
|
| 36 |
+ |
|
| 37 |
+ $ docker inspect --format='{{.NetworkSettings.MacAddress}}' $INSTANCE_ID
|
|
| 38 |
+ |
|
| 39 |
+**Get an instance's log path:** |
|
| 40 |
+ |
|
| 41 |
+ $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
|
|
| 42 |
+ |
|
| 43 |
+**List All Port Bindings:** |
|
| 44 |
+ |
|
| 45 |
+One can loop over arrays and maps in the results to produce simple text |
|
| 46 |
+output: |
|
| 47 |
+ |
|
| 48 |
+ $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
|
|
| 49 |
+ |
|
| 50 |
+**Find a Specific Port Mapping:** |
|
| 51 |
+ |
|
| 52 |
+The `.Field` syntax doesn't work when the field name begins with a |
|
| 53 |
+number, but the template language's `index` function does. The |
|
| 54 |
+`.NetworkSettings.Ports` section contains a map of the internal port |
|
| 55 |
+mappings to a list of external address/port objects, so to grab just the |
|
| 56 |
+numeric public port, you use `index` to find the specific port map, and |
|
| 57 |
+then `index` 0 contains the first object inside of that. Then we ask for |
|
| 58 |
+the `HostPort` field to get the public address. |
|
| 59 |
+ |
|
| 60 |
+ $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
|
|
| 61 |
+ |
|
| 62 |
+**Get config:** |
|
| 63 |
+ |
|
| 64 |
+The `.Field` syntax doesn't work when the field contains JSON data, but |
|
| 65 |
+the template language's custom `json` function does. The `.config` |
|
| 66 |
+section contains complex JSON object, so to grab it as JSON, you use |
|
| 67 |
+`json` to convert the configuration object into JSON. |
|
| 68 |
+ |
|
| 69 |
+ $ docker inspect --format='{{json .config}}' $INSTANCE_ID
|
|
| 70 |
+ |
| 0 | 71 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,21 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "kill" |
|
| 2 |
+description = "The kill command description and usage" |
|
| 3 |
+keywords = ["container, kill, signal"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# kill |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...] |
|
| 12 |
+ |
|
| 13 |
+ Kill a running container using SIGKILL or a specified signal |
|
| 14 |
+ |
|
| 15 |
+ -s, --signal="KILL" Signal to send to the container |
|
| 16 |
+ |
|
| 17 |
+The main process inside the container will be sent `SIGKILL`, or any |
|
| 18 |
+signal specified with option `--signal`. |
| 0 | 19 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,37 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "load" |
|
| 2 |
+description = "The load command description and usage" |
|
| 3 |
+keywords = ["stdin, tarred, repository"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# load |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker load [OPTIONS] |
|
| 12 |
+ |
|
| 13 |
+ Load an image from a tar archive on STDIN |
|
| 14 |
+ |
|
| 15 |
+ -i, --input="" Read from a tar archive file, instead of STDIN |
|
| 16 |
+ |
|
| 17 |
+Loads a tarred repository from a file or the standard input stream. |
|
| 18 |
+Restores both images and tags. |
|
| 19 |
+ |
|
| 20 |
+ $ docker images |
|
| 21 |
+ REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 22 |
+ $ docker load < busybox.tar |
|
| 23 |
+ $ docker images |
|
| 24 |
+ REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 25 |
+ busybox latest 769b9341d937 7 weeks ago 2.489 MB |
|
| 26 |
+ $ docker load --input fedora.tar |
|
| 27 |
+ $ docker images |
|
| 28 |
+ REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE |
|
| 29 |
+ busybox latest 769b9341d937 7 weeks ago 2.489 MB |
|
| 30 |
+ fedora rawhide 0d20aec6529d 7 weeks ago 387 MB |
|
| 31 |
+ fedora 20 58394af37342 7 weeks ago 385.5 MB |
|
| 32 |
+ fedora heisenbug 58394af37342 7 weeks ago 385.5 MB |
|
| 33 |
+ fedora latest 58394af37342 7 weeks ago 385.5 MB |
|
| 34 |
+ |
| 0 | 35 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,29 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "login" |
|
| 2 |
+description = "The login command description and usage" |
|
| 3 |
+keywords = ["registry, login, image"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# login |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker login [OPTIONS] [SERVER] |
|
| 12 |
+ |
|
| 13 |
+ Register or log in to a Docker registry server, if no server is |
|
| 14 |
+ specified "https://index.docker.io/v1/" is the default. |
|
| 15 |
+ |
|
| 16 |
+ -e, --email="" Email |
|
| 17 |
+ -p, --password="" Password |
|
| 18 |
+ -u, --username="" Username |
|
| 19 |
+ |
|
| 20 |
+If you want to login to a self-hosted registry you can specify this by |
|
| 21 |
+adding the server name. |
|
| 22 |
+ |
|
| 23 |
+ example: |
|
| 24 |
+ $ docker login localhost:8080 |
|
| 25 |
+ |
|
| 26 |
+ |
| 0 | 27 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,24 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "logout" |
|
| 2 |
+description = "The logout command description and usage" |
|
| 3 |
+keywords = ["logout, docker, registry"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# logout |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker logout [SERVER] |
|
| 12 |
+ |
|
| 13 |
+ Log out from a Docker registry, if no server is |
|
| 14 |
+ specified "https://index.docker.io/v1/" is the default. |
|
| 15 |
+ |
|
| 16 |
+For example: |
|
| 17 |
+ |
|
| 18 |
+ $ docker logout localhost:8080 |
|
| 19 |
+ |
|
| 20 |
+ |
|
| 21 |
+ |
| 0 | 22 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,43 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "logs" |
|
| 2 |
+description = "The logs command description and usage" |
|
| 3 |
+keywords = ["logs, retrieve, docker"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# logs |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker logs [OPTIONS] CONTAINER |
|
| 12 |
+ |
|
| 13 |
+ Fetch the logs of a container |
|
| 14 |
+ |
|
| 15 |
+ -f, --follow=false Follow log output |
|
| 16 |
+ --since="" Show logs since timestamp |
|
| 17 |
+ -t, --timestamps=false Show timestamps |
|
| 18 |
+ --tail="all" Number of lines to show from the end of the logs |
|
| 19 |
+ |
|
| 20 |
+NOTE: this command is available only for containers with `json-file` logging |
|
| 21 |
+driver. |
|
| 22 |
+ |
|
| 23 |
+The `docker logs` command batch-retrieves logs present at the time of execution. |
|
| 24 |
+ |
|
| 25 |
+The `docker logs --follow` command will continue streaming the new output from |
|
| 26 |
+the container's `STDOUT` and `STDERR`. |
|
| 27 |
+ |
|
| 28 |
+Passing a negative number or a non-integer to `--tail` is invalid and the |
|
| 29 |
+value is set to `all` in that case. This behavior may change in the future. |
|
| 30 |
+ |
|
| 31 |
+The `docker logs --timestamp` commands will add an RFC3339Nano |
|
| 32 |
+timestamp, for example `2014-09-16T06:17:46.000000000Z`, to each |
|
| 33 |
+log entry. To ensure that the timestamps for are aligned the |
|
| 34 |
+nano-second part of the timestamp will be padded with zero when necessary. |
|
| 35 |
+ |
|
| 36 |
+The `--since` option shows only the container logs generated after |
|
| 37 |
+a given date. You can specify the date as an RFC 3339 date, a UNIX |
|
| 38 |
+timestamp, or a Go duration string (e.g. `1m30s`, `3h`). Docker computes |
|
| 39 |
+the date relative to the client machine’s time. You can combine |
|
| 40 |
+the `--since` option with either or both of the `--follow` or `--tail` options. |
| 0 | 41 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,27 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "pause" |
|
| 2 |
+description = "The pause command description and usage" |
|
| 3 |
+keywords = ["cgroups, container, suspend, SIGSTOP"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# pause |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker pause CONTAINER [CONTAINER...] |
|
| 12 |
+ |
|
| 13 |
+ Pause all processes within a container |
|
| 14 |
+ |
|
| 15 |
+The `docker pause` command uses the cgroups freezer to suspend all processes in |
|
| 16 |
+a container. Traditionally, when suspending a process the `SIGSTOP` signal is |
|
| 17 |
+used, which is observable by the process being suspended. With the cgroups freezer |
|
| 18 |
+the process is unaware, and unable to capture, that it is being suspended, |
|
| 19 |
+and subsequently resumed. |
|
| 20 |
+ |
|
| 21 |
+See the |
|
| 22 |
+[cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt) |
|
| 23 |
+for further details. |
|
| 24 |
+ |
| 0 | 25 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,33 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "port" |
|
| 2 |
+description = "The port command description and usage" |
|
| 3 |
+keywords = ["port, mapping, container"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# port |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker port CONTAINER [PRIVATE_PORT[/PROTO]] |
|
| 12 |
+ |
|
| 13 |
+ List port mappings for the CONTAINER, or lookup the public-facing port that is |
|
| 14 |
+ NAT-ed to the PRIVATE_PORT |
|
| 15 |
+ |
|
| 16 |
+You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or |
|
| 17 |
+just a specific mapping: |
|
| 18 |
+ |
|
| 19 |
+ $ docker ps test |
|
| 20 |
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
|
| 21 |
+ b650456536c7 busybox:latest top 54 minutes ago Up 54 minutes 0.0.0.0:1234->9876/tcp, 0.0.0.0:4321->7890/tcp test |
|
| 22 |
+ $ docker port test |
|
| 23 |
+ 7890/tcp -> 0.0.0.0:4321 |
|
| 24 |
+ 9876/tcp -> 0.0.0.0:1234 |
|
| 25 |
+ $ docker port test 7890/tcp |
|
| 26 |
+ 0.0.0.0:4321 |
|
| 27 |
+ $ docker port test 7890/udp |
|
| 28 |
+ 2014/06/24 11:53:36 Error: No public port '7890/udp' published for test |
|
| 29 |
+ $ docker port test 7890 |
|
| 30 |
+ 0.0.0.0:4321 |
| 0 | 31 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,64 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "ps" |
|
| 2 |
+description = "The ps command description and usage" |
|
| 3 |
+keywords = ["container, running, list"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# ps |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker ps [OPTIONS] |
|
| 12 |
+ |
|
| 13 |
+ List containers |
|
| 14 |
+ |
|
| 15 |
+ -a, --all=false Show all containers (default shows just running) |
|
| 16 |
+ --before="" Show only container created before Id or Name |
|
| 17 |
+ -f, --filter=[] Filter output based on conditions provided |
|
| 18 |
+ -l, --latest=false Show the latest created container, include non-running |
|
| 19 |
+ -n=-1 Show n last created containers, include non-running |
|
| 20 |
+ --no-trunc=false Don't truncate output |
|
| 21 |
+ -q, --quiet=false Only display numeric IDs |
|
| 22 |
+ -s, --size=false Display total file sizes |
|
| 23 |
+ --since="" Show created since Id or Name, include non-running |
|
| 24 |
+ |
|
| 25 |
+Running `docker ps --no-trunc` showing 2 linked containers. |
|
| 26 |
+ |
|
| 27 |
+ $ docker ps |
|
| 28 |
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
|
| 29 |
+ 4c01db0b339c ubuntu:12.04 bash 17 seconds ago Up 16 seconds 3300-3310/tcp webapp |
|
| 30 |
+ d7886598dbe2 crosbymichael/redis:latest /redis-server --dir 33 minutes ago Up 33 minutes 6379/tcp redis,webapp/db |
|
| 31 |
+ |
|
| 32 |
+`docker ps` will show only running containers by default. To see all containers: |
|
| 33 |
+`docker ps -a` |
|
| 34 |
+ |
|
| 35 |
+`docker ps` will group exposed ports into a single range if possible. E.g., a container that exposes TCP ports `100, 101, 102` will display `100-102/tcp` in the `PORTS` column. |
|
| 36 |
+ |
|
| 37 |
+## Filtering |
|
| 38 |
+ |
|
| 39 |
+The filtering flag (`-f` or `--filter)` format is a `key=value` pair. If there is more |
|
| 40 |
+than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`) |
|
| 41 |
+ |
|
| 42 |
+The currently supported filters are: |
|
| 43 |
+ |
|
| 44 |
+* id (container's id) |
|
| 45 |
+* label (`label=<key>` or `label=<key>=<value>`) |
|
| 46 |
+* name (container's name) |
|
| 47 |
+* exited (int - the code of exited containers. Only useful with `--all`) |
|
| 48 |
+* status (created|restarting|running|paused|exited) |
|
| 49 |
+ |
|
| 50 |
+## Successfully exited containers |
|
| 51 |
+ |
|
| 52 |
+ $ docker ps -a --filter 'exited=0' |
|
| 53 |
+ CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES |
|
| 54 |
+ ea09c3c82f6e registry:latest /srv/run.sh 2 weeks ago Exited (0) 2 weeks ago 127.0.0.1:5000->5000/tcp desperate_leakey |
|
| 55 |
+ 106ea823fe4e fedora:latest /bin/sh -c 'bash -l' 2 weeks ago Exited (0) 2 weeks ago determined_albattani |
|
| 56 |
+ 48ee228c9464 fedora:20 bash 2 weeks ago Exited (0) 2 weeks ago tender_torvalds |
|
| 57 |
+ |
|
| 58 |
+This shows all the containers that have exited with status of '0' |
|
| 59 |
+ |
|
| 60 |
+ |
|
| 61 |
+ |
| 0 | 62 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,51 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "pull" |
|
| 2 |
+description = "The pull command description and usage" |
|
| 3 |
+keywords = ["pull, image, hub, docker"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# pull |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker pull [OPTIONS] NAME[:TAG] | [REGISTRY_HOST[:REGISTRY_PORT]/]NAME[:TAG] |
|
| 12 |
+ |
|
| 13 |
+ Pull an image or a repository from the registry |
|
| 14 |
+ |
|
| 15 |
+ -a, --all-tags=false Download all tagged images in the repository |
|
| 16 |
+ |
|
| 17 |
+Most of your images will be created on top of a base image from the |
|
| 18 |
+[Docker Hub](https://hub.docker.com) registry. |
|
| 19 |
+ |
|
| 20 |
+[Docker Hub](https://hub.docker.com) contains many pre-built images that you |
|
| 21 |
+can `pull` and try without needing to define and configure your own. |
|
| 22 |
+ |
|
| 23 |
+It is also possible to manually specify the path of a registry to pull from. |
|
| 24 |
+For example, if you have set up a local registry, you can specify its path to |
|
| 25 |
+pull from it. A repository path is similar to a URL, but does not contain |
|
| 26 |
+a protocol specifier (`https://`, for example). |
|
| 27 |
+ |
|
| 28 |
+To download a particular image, or set of images (i.e., a repository), |
|
| 29 |
+use `docker pull`: |
|
| 30 |
+ |
|
| 31 |
+ $ docker pull debian |
|
| 32 |
+ # will pull the debian:latest image and its intermediate layers |
|
| 33 |
+ $ docker pull debian:testing |
|
| 34 |
+ # will pull the image named debian:testing and any intermediate |
|
| 35 |
+ # layers it is based on. |
|
| 36 |
+ $ docker pull debian@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf |
|
| 37 |
+ # will pull the image from the debian repository with the digest |
|
| 38 |
+ # sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf |
|
| 39 |
+ # and any intermediate layers it is based on. |
|
| 40 |
+ # (Typically the empty `scratch` image, a MAINTAINER layer, |
|
| 41 |
+ # and the un-tarred base). |
|
| 42 |
+ $ docker pull --all-tags centos |
|
| 43 |
+ # will pull all the images from the centos repository |
|
| 44 |
+ $ docker pull registry.hub.docker.com/debian |
|
| 45 |
+ # manually specifies the path to the default Docker registry. This could |
|
| 46 |
+ # be replaced with the path to a local registry to pull from another source. |
|
| 47 |
+ # sudo docker pull myhub.com:8080/test-image |
|
| 48 |
+ |
| 0 | 49 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,19 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "push" |
|
| 2 |
+description = "The push command description and usage" |
|
| 3 |
+keywords = ["share, push, image"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# push |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker push NAME[:TAG] |
|
| 12 |
+ |
|
| 13 |
+ Push an image or a repository to the registry |
|
| 14 |
+ |
|
| 15 |
+Use `docker push` to share your images to the [Docker Hub](https://hub.docker.com) |
|
| 16 |
+registry or to a self-hosted one. |
| 0 | 17 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,18 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "rename" |
|
| 2 |
+description = "The rename command description and usage" |
|
| 3 |
+keywords = ["rename, docker, container"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# rename |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker rename OLD_NAME NEW_NAME |
|
| 12 |
+ |
|
| 13 |
+ rename a existing container to a NEW_NAME |
|
| 14 |
+ |
|
| 15 |
+The `docker rename` command allows the container to be renamed to a different name. |
| 0 | 16 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,19 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "restart" |
|
| 2 |
+description = "The restart command description and usage" |
|
| 3 |
+keywords = ["restart, container, Docker"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# restart |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker restart [OPTIONS] CONTAINER [CONTAINER...] |
|
| 12 |
+ |
|
| 13 |
+ Restart a running container |
|
| 14 |
+ |
|
| 15 |
+ -t, --time=10 Seconds to wait for stop before killing the container |
|
| 16 |
+ |
| 0 | 17 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,48 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "rm" |
|
| 2 |
+description = "The rm command description and usage" |
|
| 3 |
+keywords = ["remove, Docker, container"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# rm |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...] |
|
| 12 |
+ |
|
| 13 |
+ Remove one or more containers |
|
| 14 |
+ |
|
| 15 |
+ -f, --force=false Force the removal of a running container (uses SIGKILL) |
|
| 16 |
+ -l, --link=false Remove the specified link |
|
| 17 |
+ -v, --volumes=false Remove the volumes associated with the container |
|
| 18 |
+ |
|
| 19 |
+## Examples |
|
| 20 |
+ |
|
| 21 |
+ $ docker rm /redis |
|
| 22 |
+ /redis |
|
| 23 |
+ |
|
| 24 |
+This will remove the container referenced under the link |
|
| 25 |
+`/redis`. |
|
| 26 |
+ |
|
| 27 |
+ $ docker rm --link /webapp/redis |
|
| 28 |
+ /webapp/redis |
|
| 29 |
+ |
|
| 30 |
+This will remove the underlying link between `/webapp` and the `/redis` |
|
| 31 |
+containers removing all network communication. |
|
| 32 |
+ |
|
| 33 |
+ $ docker rm --force redis |
|
| 34 |
+ redis |
|
| 35 |
+ |
|
| 36 |
+The main process inside the container referenced under the link `/redis` will receive |
|
| 37 |
+`SIGKILL`, then the container will be removed. |
|
| 38 |
+ |
|
| 39 |
+ $ docker rm $(docker ps -a -q) |
|
| 40 |
+ |
|
| 41 |
+This command will delete all stopped containers. The command |
|
| 42 |
+`docker ps -a -q` will return all existing container IDs and pass them to |
|
| 43 |
+the `rm` command which will delete them. Any running containers will not be |
|
| 44 |
+deleted. |
|
| 45 |
+ |
| 0 | 46 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,76 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "rmi" |
|
| 2 |
+description = "The rmi command description and usage" |
|
| 3 |
+keywords = ["remove, image, Docker"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# rmi |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker rmi [OPTIONS] IMAGE [IMAGE...] |
|
| 12 |
+ |
|
| 13 |
+ Remove one or more images |
|
| 14 |
+ |
|
| 15 |
+ -f, --force=false Force removal of the image |
|
| 16 |
+ --no-prune=false Do not delete untagged parents |
|
| 17 |
+ |
|
| 18 |
+ |
|
| 19 |
+You can remove an image using its short or long ID, its tag, or its digest. If |
|
| 20 |
+an image has one or more tag or digest reference, you must remove all of them |
|
| 21 |
+before the image is removed. |
|
| 22 |
+ |
|
| 23 |
+ $ docker images |
|
| 24 |
+ REPOSITORY TAG IMAGE ID CREATED SIZE |
|
| 25 |
+ test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 26 |
+ test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 27 |
+ test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 28 |
+ |
|
| 29 |
+ $ docker rmi fd484f19954f |
|
| 30 |
+ Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force |
|
| 31 |
+ 2013/12/11 05:47:16 Error: failed to remove one or more images |
|
| 32 |
+ |
|
| 33 |
+ $ docker rmi test1 |
|
| 34 |
+ Untagged: test1:latest |
|
| 35 |
+ $ docker rmi test2 |
|
| 36 |
+ Untagged: test2:latest |
|
| 37 |
+ |
|
| 38 |
+ $ docker images |
|
| 39 |
+ REPOSITORY TAG IMAGE ID CREATED SIZE |
|
| 40 |
+ test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 41 |
+ $ docker rmi test |
|
| 42 |
+ Untagged: test:latest |
|
| 43 |
+ Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8 |
|
| 44 |
+ |
|
| 45 |
+If you use the `-f` flag and specify the image's short or long ID, then this |
|
| 46 |
+command untags and removes all images that match the specified ID. |
|
| 47 |
+ |
|
| 48 |
+ $ docker images |
|
| 49 |
+ REPOSITORY TAG IMAGE ID CREATED SIZE |
|
| 50 |
+ test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 51 |
+ test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 52 |
+ test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB) |
|
| 53 |
+ |
|
| 54 |
+ $ docker rmi -f fd484f19954f |
|
| 55 |
+ Untagged: test1:latest |
|
| 56 |
+ Untagged: test:latest |
|
| 57 |
+ Untagged: test2:latest |
|
| 58 |
+ Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8 |
|
| 59 |
+ |
|
| 60 |
+An image pulled by digest has no tag associated with it: |
|
| 61 |
+ |
|
| 62 |
+ $ docker images --digests |
|
| 63 |
+ REPOSITORY TAG DIGEST IMAGE ID CREATED VIRTUAL SIZE |
|
| 64 |
+ localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB |
|
| 65 |
+ |
|
| 66 |
+To remove an image using its digest: |
|
| 67 |
+ |
|
| 68 |
+ $ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf |
|
| 69 |
+ Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf |
|
| 70 |
+ Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125 |
|
| 71 |
+ Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2 |
|
| 72 |
+ Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b |
|
| 73 |
+ |
| 0 | 74 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,481 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "run" |
|
| 2 |
+description = "The run command description and usage" |
|
| 3 |
+keywords = ["run, command, container"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# run |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] |
|
| 12 |
+ |
|
| 13 |
+ Run a command in a new container |
|
| 14 |
+ |
|
| 15 |
+ -a, --attach=[] Attach to STDIN, STDOUT or STDERR |
|
| 16 |
+ --add-host=[] Add a custom host-to-IP mapping (host:ip) |
|
| 17 |
+ --blkio-weight=0 Block IO weight (relative weight) |
|
| 18 |
+ -c, --cpu-shares=0 CPU shares (relative weight) |
|
| 19 |
+ --cap-add=[] Add Linux capabilities |
|
| 20 |
+ --cap-drop=[] Drop Linux capabilities |
|
| 21 |
+ --cidfile="" Write the container ID to the file |
|
| 22 |
+ --cpuset-cpus="" CPUs in which to allow execution (0-3, 0,1) |
|
| 23 |
+ --cpuset-mems="" Memory nodes (MEMs) in which to allow execution (0-3, 0,1) |
|
| 24 |
+ --cpu-period=0 Limit the CPU CFS (Completely Fair Scheduler) period |
|
| 25 |
+ --cpu-quota=0 Limit the CPU CFS (Completely Fair Scheduler) quota |
|
| 26 |
+ -d, --detach=false Run container in background and print container ID |
|
| 27 |
+ --device=[] Add a host device to the container |
|
| 28 |
+ --dns=[] Set custom DNS servers |
|
| 29 |
+ --dns-search=[] Set custom DNS search domains |
|
| 30 |
+ -e, --env=[] Set environment variables |
|
| 31 |
+ --entrypoint="" Overwrite the default ENTRYPOINT of the image |
|
| 32 |
+ --env-file=[] Read in a file of environment variables |
|
| 33 |
+ --expose=[] Expose a port or a range of ports |
|
| 34 |
+ -h, --hostname="" Container host name |
|
| 35 |
+ --help=false Print usage |
|
| 36 |
+ -i, --interactive=false Keep STDIN open even if not attached |
|
| 37 |
+ --ipc="" IPC namespace to use |
|
| 38 |
+ --link=[] Add link to another container |
|
| 39 |
+ --log-driver="" Logging driver for container |
|
| 40 |
+ --log-opt=[] Log driver specific options |
|
| 41 |
+ --lxc-conf=[] Add custom lxc options |
|
| 42 |
+ -m, --memory="" Memory limit |
|
| 43 |
+ -l, --label=[] Set metadata on the container (e.g., --label=com.example.key=value) |
|
| 44 |
+ --label-file=[] Read in a file of labels (EOL delimited) |
|
| 45 |
+ --mac-address="" Container MAC address (e.g. 92:d0:c6:0a:29:33) |
|
| 46 |
+ --memory-swap="" Total memory (memory + swap), '-1' to disable swap |
|
| 47 |
+ --name="" Assign a name to the container |
|
| 48 |
+ --net="bridge" Set the Network mode for the container |
|
| 49 |
+ --oom-kill-disable=false Whether to disable OOM Killer for the container or not |
|
| 50 |
+ -P, --publish-all=false Publish all exposed ports to random ports |
|
| 51 |
+ -p, --publish=[] Publish a container's port(s) to the host |
|
| 52 |
+ --pid="" PID namespace to use |
|
| 53 |
+ --uts="" UTS namespace to use |
|
| 54 |
+ --privileged=false Give extended privileges to this container |
|
| 55 |
+ --read-only=false Mount the container's root filesystem as read only |
|
| 56 |
+ --restart="no" Restart policy (no, on-failure[:max-retry], always) |
|
| 57 |
+ --rm=false Automatically remove the container when it exits |
|
| 58 |
+ --security-opt=[] Security Options |
|
| 59 |
+ --sig-proxy=true Proxy received signals to the process |
|
| 60 |
+ -t, --tty=false Allocate a pseudo-TTY |
|
| 61 |
+ -u, --user="" Username or UID (format: <name|uid>[:<group|gid>]) |
|
| 62 |
+ -v, --volume=[] Bind mount a volume |
|
| 63 |
+ --volumes-from=[] Mount volumes from the specified container(s) |
|
| 64 |
+ -w, --workdir="" Working directory inside the container |
|
| 65 |
+ |
|
| 66 |
+The `docker run` command first `creates` a writeable container layer over the |
|
| 67 |
+specified image, and then `starts` it using the specified command. That is, |
|
| 68 |
+`docker run` is equivalent to the API `/containers/create` then |
|
| 69 |
+`/containers/(id)/start`. A stopped container can be restarted with all its |
|
| 70 |
+previous changes intact using `docker start`. See `docker ps -a` to view a list |
|
| 71 |
+of all containers. |
|
| 72 |
+ |
|
| 73 |
+There is detailed information about `docker run` in the [Docker run reference]( |
|
| 74 |
+/reference/run/). |
|
| 75 |
+ |
|
| 76 |
+The `docker run` command can be used in combination with `docker commit` to |
|
| 77 |
+[*change the command that a container runs*](#commit-an-existing-container). |
|
| 78 |
+ |
|
| 79 |
+See the [Docker User Guide](/userguide/dockerlinks/) for more detailed |
|
| 80 |
+information about the `--expose`, `-p`, `-P` and `--link` parameters, |
|
| 81 |
+and linking containers. |
|
| 82 |
+ |
|
| 83 |
+## Examples |
|
| 84 |
+ |
|
| 85 |
+ $ docker run --name test -it debian |
|
| 86 |
+ $$ exit 13 |
|
| 87 |
+ exit |
|
| 88 |
+ $ echo $? |
|
| 89 |
+ 13 |
|
| 90 |
+ $ docker ps -a | grep test |
|
| 91 |
+ 275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test |
|
| 92 |
+ |
|
| 93 |
+In this example, we are running `bash` interactively in the `debian:latest` image, and giving |
|
| 94 |
+the container the name `test`. We then quit `bash` by running `exit 13`, which means `bash` |
|
| 95 |
+will have an exit code of `13`. This is then passed on to the caller of `docker run`, and |
|
| 96 |
+is recorded in the `test` container metadata. |
|
| 97 |
+ |
|
| 98 |
+ $ docker run --cidfile /tmp/docker_test.cid ubuntu echo "test" |
|
| 99 |
+ |
|
| 100 |
+This will create a container and print `test` to the console. The `cidfile` |
|
| 101 |
+flag makes Docker attempt to create a new file and write the container ID to it. |
|
| 102 |
+If the file exists already, Docker will return an error. Docker will close this |
|
| 103 |
+file when `docker run` exits. |
|
| 104 |
+ |
|
| 105 |
+ $ docker run -t -i --rm ubuntu bash |
|
| 106 |
+ root@bc338942ef20:/# mount -t tmpfs none /mnt |
|
| 107 |
+ mount: permission denied |
|
| 108 |
+ |
|
| 109 |
+This will *not* work, because by default, most potentially dangerous kernel |
|
| 110 |
+capabilities are dropped; including `cap_sys_admin` (which is required to mount |
|
| 111 |
+filesystems). However, the `--privileged` flag will allow it to run: |
|
| 112 |
+ |
|
| 113 |
+ $ docker run --privileged ubuntu bash |
|
| 114 |
+ root@50e3f57e16e6:/# mount -t tmpfs none /mnt |
|
| 115 |
+ root@50e3f57e16e6:/# df -h |
|
| 116 |
+ Filesystem Size Used Avail Use% Mounted on |
|
| 117 |
+ none 1.9G 0 1.9G 0% /mnt |
|
| 118 |
+ |
|
| 119 |
+The `--privileged` flag gives *all* capabilities to the container, and it also |
|
| 120 |
+lifts all the limitations enforced by the `device` cgroup controller. In other |
|
| 121 |
+words, the container can then do almost everything that the host can do. This |
|
| 122 |
+flag exists to allow special use-cases, like running Docker within Docker. |
|
| 123 |
+ |
|
| 124 |
+ $ docker run -w /path/to/dir/ -i -t ubuntu pwd |
|
| 125 |
+ |
|
| 126 |
+The `-w` lets the command being executed inside directory given, here |
|
| 127 |
+`/path/to/dir/`. If the path does not exists it is created inside the container. |
|
| 128 |
+ |
|
| 129 |
+ $ docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd |
|
| 130 |
+ |
|
| 131 |
+The `-v` flag mounts the current working directory into the container. The `-w` |
|
| 132 |
+lets the command being executed inside the current working directory, by |
|
| 133 |
+changing into the directory to the value returned by `pwd`. So this |
|
| 134 |
+combination executes the command using the container, but inside the |
|
| 135 |
+current working directory. |
|
| 136 |
+ |
|
| 137 |
+ $ docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash |
|
| 138 |
+ |
|
| 139 |
+When the host directory of a bind-mounted volume doesn't exist, Docker |
|
| 140 |
+will automatically create this directory on the host for you. In the |
|
| 141 |
+example above, Docker will create the `/doesnt/exist` |
|
| 142 |
+folder before starting your container. |
|
| 143 |
+ |
|
| 144 |
+ $ docker run --read-only -v /icanwrite busybox touch /icanwrite here |
|
| 145 |
+ |
|
| 146 |
+Volumes can be used in combination with `--read-only` to control where |
|
| 147 |
+a container writes files. The `--read-only` flag mounts the container's root |
|
| 148 |
+filesystem as read only prohibiting writes to locations other than the |
|
| 149 |
+specified volumes for the container. |
|
| 150 |
+ |
|
| 151 |
+ $ docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v ./static-docker:/usr/bin/docker busybox sh |
|
| 152 |
+ |
|
| 153 |
+By bind-mounting the docker unix socket and statically linked docker |
|
| 154 |
+binary (such as that provided by [https://get.docker.com]( |
|
| 155 |
+https://get.docker.com)), you give the container the full access to create and |
|
| 156 |
+manipulate the host's Docker daemon. |
|
| 157 |
+ |
|
| 158 |
+ $ docker run -p 127.0.0.1:80:8080 ubuntu bash |
|
| 159 |
+ |
|
| 160 |
+This binds port `8080` of the container to port `80` on `127.0.0.1` of |
|
| 161 |
+the host machine. The [Docker User Guide](/userguide/dockerlinks/) |
|
| 162 |
+explains in detail how to manipulate ports in Docker. |
|
| 163 |
+ |
|
| 164 |
+ $ docker run --expose 80 ubuntu bash |
|
| 165 |
+ |
|
| 166 |
+This exposes port `80` of the container for use within a link without |
|
| 167 |
+publishing the port to the host system's interfaces. The [Docker User |
|
| 168 |
+Guide](/userguide/dockerlinks) explains in detail how to manipulate |
|
| 169 |
+ports in Docker. |
|
| 170 |
+ |
|
| 171 |
+ $ docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash |
|
| 172 |
+ |
|
| 173 |
+This sets environmental variables in the container. For illustration all three |
|
| 174 |
+flags are shown here. Where `-e`, `--env` take an environment variable and |
|
| 175 |
+value, or if no `=` is provided, then that variable's current value is passed |
|
| 176 |
+through (i.e. `$MYVAR1` from the host is set to `$MYVAR1` in the container). |
|
| 177 |
+When no `=` is provided and that variable is not defined in the client's |
|
| 178 |
+environment then that variable will be removed from the container's list of |
|
| 179 |
+environment variables. |
|
| 180 |
+All three flags, `-e`, `--env` and `--env-file` can be repeated. |
|
| 181 |
+ |
|
| 182 |
+Regardless of the order of these three flags, the `--env-file` are processed |
|
| 183 |
+first, and then `-e`, `--env` flags. This way, the `-e` or `--env` will |
|
| 184 |
+override variables as needed. |
|
| 185 |
+ |
|
| 186 |
+ $ cat ./env.list |
|
| 187 |
+ TEST_FOO=BAR |
|
| 188 |
+ $ docker run --env TEST_FOO="This is a test" --env-file ./env.list busybox env | grep TEST_FOO |
|
| 189 |
+ TEST_FOO=This is a test |
|
| 190 |
+ |
|
| 191 |
+The `--env-file` flag takes a filename as an argument and expects each line |
|
| 192 |
+to be in the `VAR=VAL` format, mimicking the argument passed to `--env`. Comment |
|
| 193 |
+lines need only be prefixed with `#` |
|
| 194 |
+ |
|
| 195 |
+An example of a file passed with `--env-file` |
|
| 196 |
+ |
|
| 197 |
+ $ cat ./env.list |
|
| 198 |
+ TEST_FOO=BAR |
|
| 199 |
+ |
|
| 200 |
+ # this is a comment |
|
| 201 |
+ TEST_APP_DEST_HOST=10.10.0.127 |
|
| 202 |
+ TEST_APP_DEST_PORT=8888 |
|
| 203 |
+ |
|
| 204 |
+ # pass through this variable from the caller |
|
| 205 |
+ TEST_PASSTHROUGH |
|
| 206 |
+ $ sudo TEST_PASSTHROUGH=howdy docker run --env-file ./env.list busybox env |
|
| 207 |
+ HOME=/ |
|
| 208 |
+ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin |
|
| 209 |
+ HOSTNAME=5198e0745561 |
|
| 210 |
+ TEST_FOO=BAR |
|
| 211 |
+ TEST_APP_DEST_HOST=10.10.0.127 |
|
| 212 |
+ TEST_APP_DEST_PORT=8888 |
|
| 213 |
+ TEST_PASSTHROUGH=howdy |
|
| 214 |
+ |
|
| 215 |
+ $ docker run --name console -t -i ubuntu bash |
|
| 216 |
+ |
|
| 217 |
+A label is a a `key=value` pair that applies metadata to a container. To label a container with two labels: |
|
| 218 |
+ |
|
| 219 |
+ $ docker run -l my-label --label com.example.foo=bar ubuntu bash |
|
| 220 |
+ |
|
| 221 |
+The `my-label` key doesn't specify a value so the label defaults to an empty |
|
| 222 |
+string(`""`). To add multiple labels, repeat the label flag (`-l` or `--label`). |
|
| 223 |
+ |
|
| 224 |
+The `key=value` must be unique to avoid overwriting the label value. If you |
|
| 225 |
+specify labels with identical keys but different values, each subsequent value |
|
| 226 |
+overwrites the previous. Docker uses the last `key=value` you supply. |
|
| 227 |
+ |
|
| 228 |
+Use the `--label-file` flag to load multiple labels from a file. Delimit each |
|
| 229 |
+label in the file with an EOL mark. The example below loads labels from a |
|
| 230 |
+labels file in the current directory: |
|
| 231 |
+ |
|
| 232 |
+ $ docker run --label-file ./labels ubuntu bash |
|
| 233 |
+ |
|
| 234 |
+The label-file format is similar to the format for loading environment |
|
| 235 |
+variables. (Unlike environment variables, labels are not visible to processes |
|
| 236 |
+running inside a container.) The following example illustrates a label-file |
|
| 237 |
+format: |
|
| 238 |
+ |
|
| 239 |
+ com.example.label1="a label" |
|
| 240 |
+ |
|
| 241 |
+ # this is a comment |
|
| 242 |
+ com.example.label2=another\ label |
|
| 243 |
+ com.example.label3 |
|
| 244 |
+ |
|
| 245 |
+You can load multiple label-files by supplying multiple `--label-file` flags. |
|
| 246 |
+ |
|
| 247 |
+For additional information on working with labels, see [*Labels - custom |
|
| 248 |
+metadata in Docker*](/userguide/labels-custom-metadata/) in the Docker User |
|
| 249 |
+Guide. |
|
| 250 |
+ |
|
| 251 |
+ $ docker run --link /redis:redis --name console ubuntu bash |
|
| 252 |
+ |
|
| 253 |
+The `--link` flag will link the container named `/redis` into the newly |
|
| 254 |
+created container with the alias `redis`. The new container can access the |
|
| 255 |
+network and environment of the `redis` container via environment variables. |
|
| 256 |
+The `--link` flag will also just accept the form `<name or id>` in which case |
|
| 257 |
+the alias will match the name. For instance, you could have written the previous |
|
| 258 |
+example as: |
|
| 259 |
+ |
|
| 260 |
+ $ docker run --link redis --name console ubuntu bash |
|
| 261 |
+ |
|
| 262 |
+The `--name` flag will assign the name `console` to the newly created |
|
| 263 |
+container. |
|
| 264 |
+ |
|
| 265 |
+ $ docker run --volumes-from 777f7dc92da7 --volumes-from ba8c0c54f0f2:ro -i -t ubuntu pwd |
|
| 266 |
+ |
|
| 267 |
+The `--volumes-from` flag mounts all the defined volumes from the referenced |
|
| 268 |
+containers. Containers can be specified by repetitions of the `--volumes-from` |
|
| 269 |
+argument. The container ID may be optionally suffixed with `:ro` or `:rw` to |
|
| 270 |
+mount the volumes in read-only or read-write mode, respectively. By default, |
|
| 271 |
+the volumes are mounted in the same mode (read write or read only) as |
|
| 272 |
+the reference container. |
|
| 273 |
+ |
|
| 274 |
+Labeling systems like SELinux require that proper labels are placed on volume |
|
| 275 |
+content mounted into a container. Without a label, the security system might |
|
| 276 |
+prevent the processes running inside the container from using the content. By |
|
| 277 |
+default, Docker does not change the labels set by the OS. |
|
| 278 |
+ |
|
| 279 |
+To change the label in the container context, you can add either of two suffixes |
|
| 280 |
+`:z` or `:Z` to the volume mount. These suffixes tell Docker to relabel file |
|
| 281 |
+objects on the shared volumes. The `z` option tells Docker that two containers |
|
| 282 |
+share the volume content. As a result, Docker labels the content with a shared |
|
| 283 |
+content label. Shared volume labels allow all containers to read/write content. |
|
| 284 |
+The `Z` option tells Docker to label the content with a private unshared label. |
|
| 285 |
+Only the current container can use a private volume. |
|
| 286 |
+ |
|
| 287 |
+The `-a` flag tells `docker run` to bind to the container's `STDIN`, `STDOUT` |
|
| 288 |
+or `STDERR`. This makes it possible to manipulate the output and input as |
|
| 289 |
+needed. |
|
| 290 |
+ |
|
| 291 |
+ $ echo "test" | docker run -i -a stdin ubuntu cat - |
|
| 292 |
+ |
|
| 293 |
+This pipes data into a container and prints the container's ID by attaching |
|
| 294 |
+only to the container's `STDIN`. |
|
| 295 |
+ |
|
| 296 |
+ $ docker run -a stderr ubuntu echo test |
|
| 297 |
+ |
|
| 298 |
+This isn't going to print anything unless there's an error because we've |
|
| 299 |
+only attached to the `STDERR` of the container. The container's logs |
|
| 300 |
+still store what's been written to `STDERR` and `STDOUT`. |
|
| 301 |
+ |
|
| 302 |
+ $ cat somefile | docker run -i -a stdin mybuilder dobuild |
|
| 303 |
+ |
|
| 304 |
+This is how piping a file into a container could be done for a build. |
|
| 305 |
+The container's ID will be printed after the build is done and the build |
|
| 306 |
+logs could be retrieved using `docker logs`. This is |
|
| 307 |
+useful if you need to pipe a file or something else into a container and |
|
| 308 |
+retrieve the container's ID once the container has finished running. |
|
| 309 |
+ |
|
| 310 |
+ $ docker run --device=/dev/sdc:/dev/xvdc --device=/dev/sdd --device=/dev/zero:/dev/nulo -i -t ubuntu ls -l /dev/{xvdc,sdd,nulo}
|
|
| 311 |
+ brw-rw---- 1 root disk 8, 2 Feb 9 16:05 /dev/xvdc |
|
| 312 |
+ brw-rw---- 1 root disk 8, 3 Feb 9 16:05 /dev/sdd |
|
| 313 |
+ crw-rw-rw- 1 root root 1, 5 Feb 9 16:05 /dev/nulo |
|
| 314 |
+ |
|
| 315 |
+It is often necessary to directly expose devices to a container. The `--device` |
|
| 316 |
+option enables that. For example, a specific block storage device or loop |
|
| 317 |
+device or audio device can be added to an otherwise unprivileged container |
|
| 318 |
+(without the `--privileged` flag) and have the application directly access it. |
|
| 319 |
+ |
|
| 320 |
+By default, the container will be able to `read`, `write` and `mknod` these devices. |
|
| 321 |
+This can be overridden using a third `:rwm` set of options to each `--device` |
|
| 322 |
+flag: |
|
| 323 |
+ |
|
| 324 |
+ |
|
| 325 |
+ $ docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc |
|
| 326 |
+ |
|
| 327 |
+ Command (m for help): q |
|
| 328 |
+ $ docker run --device=/dev/sda:/dev/xvdc:ro --rm -it ubuntu fdisk /dev/xvdc |
|
| 329 |
+ You will not be able to write the partition table. |
|
| 330 |
+ |
|
| 331 |
+ Command (m for help): q |
|
| 332 |
+ |
|
| 333 |
+ $ docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc |
|
| 334 |
+ |
|
| 335 |
+ Command (m for help): q |
|
| 336 |
+ |
|
| 337 |
+ $ docker run --device=/dev/sda:/dev/xvdc:m --rm -it ubuntu fdisk /dev/xvdc |
|
| 338 |
+ fdisk: unable to open /dev/xvdc: Operation not permitted |
|
| 339 |
+ |
|
| 340 |
+> **Note:** |
|
| 341 |
+> `--device` cannot be safely used with ephemeral devices. Block devices |
|
| 342 |
+> that may be removed should not be added to untrusted containers with |
|
| 343 |
+> `--device`. |
|
| 344 |
+ |
|
| 345 |
+**A complete example:** |
|
| 346 |
+ |
|
| 347 |
+ $ docker run -d --name static static-web-files sh |
|
| 348 |
+ $ docker run -d --expose=8098 --name riak riakserver |
|
| 349 |
+ $ docker run -d -m 100m -e DEVELOPMENT=1 -e BRANCH=example-code -v $(pwd):/app/bin:ro --name app appserver |
|
| 350 |
+ $ docker run -d -p 1443:443 --dns=10.0.0.1 --dns-search=dev.org -v /var/log/httpd --volumes-from static --link riak --link app -h www.sven.dev.org --name web webserver |
|
| 351 |
+ $ docker run -t -i --rm --volumes-from web -w /var/log/httpd busybox tail -f access.log |
|
| 352 |
+ |
|
| 353 |
+This example shows five containers that might be set up to test a web |
|
| 354 |
+application change: |
|
| 355 |
+ |
|
| 356 |
+1. Start a pre-prepared volume image `static-web-files` (in the background) |
|
| 357 |
+ that has CSS, image and static HTML in it, (with a `VOLUME` instruction in |
|
| 358 |
+ the Dockerfile to allow the web server to use those files); |
|
| 359 |
+2. Start a pre-prepared `riakserver` image, give the container name `riak` and |
|
| 360 |
+ expose port `8098` to any containers that link to it; |
|
| 361 |
+3. Start the `appserver` image, restricting its memory usage to 100MB, setting |
|
| 362 |
+ two environment variables `DEVELOPMENT` and `BRANCH` and bind-mounting the |
|
| 363 |
+ current directory (`$(pwd)`) in the container in read-only mode as `/app/bin`; |
|
| 364 |
+4. Start the `webserver`, mapping port `443` in the container to port `1443` on |
|
| 365 |
+ the Docker server, setting the DNS server to `10.0.0.1` and DNS search |
|
| 366 |
+ domain to `dev.org`, creating a volume to put the log files into (so we can |
|
| 367 |
+ access it from another container), then importing the files from the volume |
|
| 368 |
+ exposed by the `static` container, and linking to all exposed ports from |
|
| 369 |
+ `riak` and `app`. Lastly, we set the hostname to `web.sven.dev.org` so its |
|
| 370 |
+ consistent with the pre-generated SSL certificate; |
|
| 371 |
+5. Finally, we create a container that runs `tail -f access.log` using the logs |
|
| 372 |
+ volume from the `web` container, setting the workdir to `/var/log/httpd`. The |
|
| 373 |
+ `--rm` option means that when the container exits, the container's layer is |
|
| 374 |
+ removed. |
|
| 375 |
+ |
|
| 376 |
+## Restart policies |
|
| 377 |
+ |
|
| 378 |
+Use Docker's `--restart` to specify a container's *restart policy*. A restart |
|
| 379 |
+policy controls whether the Docker daemon restarts a container after exit. |
|
| 380 |
+Docker supports the following restart policies: |
|
| 381 |
+ |
|
| 382 |
+<table> |
|
| 383 |
+ <thead> |
|
| 384 |
+ <tr> |
|
| 385 |
+ <th>Policy</th> |
|
| 386 |
+ <th>Result</th> |
|
| 387 |
+ </tr> |
|
| 388 |
+ </thead> |
|
| 389 |
+ <tbody> |
|
| 390 |
+ <tr> |
|
| 391 |
+ <td><strong>no</strong></td> |
|
| 392 |
+ <td> |
|
| 393 |
+ Do not automatically restart the container when it exits. This is the |
|
| 394 |
+ default. |
|
| 395 |
+ </td> |
|
| 396 |
+ </tr> |
|
| 397 |
+ <tr> |
|
| 398 |
+ <td> |
|
| 399 |
+ <span style="white-space: nowrap"> |
|
| 400 |
+ <strong>on-failure</strong>[:max-retries] |
|
| 401 |
+ </span> |
|
| 402 |
+ </td> |
|
| 403 |
+ <td> |
|
| 404 |
+ Restart only if the container exits with a non-zero exit status. |
|
| 405 |
+ Optionally, limit the number of restart retries the Docker |
|
| 406 |
+ daemon attempts. |
|
| 407 |
+ </td> |
|
| 408 |
+ </tr> |
|
| 409 |
+ <tr> |
|
| 410 |
+ <td><strong>always</strong></td> |
|
| 411 |
+ <td> |
|
| 412 |
+ Always restart the container regardless of the exit status. |
|
| 413 |
+ When you specify always, the Docker daemon will try to restart |
|
| 414 |
+ the container indefinitely. |
|
| 415 |
+ </td> |
|
| 416 |
+ </tr> |
|
| 417 |
+ </tbody> |
|
| 418 |
+</table> |
|
| 419 |
+ |
|
| 420 |
+ $ docker run --restart=always redis |
|
| 421 |
+ |
|
| 422 |
+This will run the `redis` container with a restart policy of **always** |
|
| 423 |
+so that if the container exits, Docker will restart it. |
|
| 424 |
+ |
|
| 425 |
+More detailed information on restart policies can be found in the |
|
| 426 |
+[Restart Policies (--restart)](/reference/run/#restart-policies-restart) |
|
| 427 |
+section of the Docker run reference page. |
|
| 428 |
+ |
|
| 429 |
+## Adding entries to a container hosts file |
|
| 430 |
+ |
|
| 431 |
+You can add other hosts into a container's `/etc/hosts` file by using one or |
|
| 432 |
+more `--add-host` flags. This example adds a static address for a host named |
|
| 433 |
+`docker`: |
|
| 434 |
+ |
|
| 435 |
+ $ docker run --add-host=docker:10.180.0.1 --rm -it debian |
|
| 436 |
+ $$ ping docker |
|
| 437 |
+ PING docker (10.180.0.1): 48 data bytes |
|
| 438 |
+ 56 bytes from 10.180.0.1: icmp_seq=0 ttl=254 time=7.600 ms |
|
| 439 |
+ 56 bytes from 10.180.0.1: icmp_seq=1 ttl=254 time=30.705 ms |
|
| 440 |
+ ^C--- docker ping statistics --- |
|
| 441 |
+ 2 packets transmitted, 2 packets received, 0% packet loss |
|
| 442 |
+ round-trip min/avg/max/stddev = 7.600/19.152/30.705/11.553 ms |
|
| 443 |
+ |
|
| 444 |
+Sometimes you need to connect to the Docker host from within your |
|
| 445 |
+container. To enable this, pass the Docker host's IP address to |
|
| 446 |
+the container using the `--add-host` flag. To find the host's address, |
|
| 447 |
+use the `ip addr show` command. |
|
| 448 |
+ |
|
| 449 |
+The flags you pass to `ip addr show` depend on whether you are |
|
| 450 |
+using IPv4 or IPv6 networking in your containers. Use the following |
|
| 451 |
+flags for IPv4 address retrieval for a network device named `eth0`: |
|
| 452 |
+ |
|
| 453 |
+ $ HOSTIP=`ip -4 addr show scope global dev eth0 | grep inet | awk '{print \$2}' | cut -d / -f 1`
|
|
| 454 |
+ $ docker run --add-host=docker:${HOSTIP} --rm -it debian
|
|
| 455 |
+ |
|
| 456 |
+For IPv6 use the `-6` flag instead of the `-4` flag. For other network |
|
| 457 |
+devices, replace `eth0` with the correct device name (for example `docker0` |
|
| 458 |
+for the bridge device). |
|
| 459 |
+ |
|
| 460 |
+### Setting ulimits in a container |
|
| 461 |
+ |
|
| 462 |
+Since setting `ulimit` settings in a container requires extra privileges not |
|
| 463 |
+available in the default container, you can set these using the `--ulimit` flag. |
|
| 464 |
+`--ulimit` is specified with a soft and hard limit as such: |
|
| 465 |
+`<type>=<soft limit>[:<hard limit>]`, for example: |
|
| 466 |
+ |
|
| 467 |
+ $ docker run --ulimit nofile=1024:1024 --rm debian ulimit -n |
|
| 468 |
+ 1024 |
|
| 469 |
+ |
|
| 470 |
+> **Note:** |
|
| 471 |
+> If you do not provide a `hard limit`, the `soft limit` will be used |
|
| 472 |
+> for both values. If no `ulimits` are set, they will be inherited from |
|
| 473 |
+> the default `ulimits` set on the daemon. `as` option is disabled now. |
|
| 474 |
+> In other words, the following script is not supported: |
|
| 475 |
+> `$ docker run -it --ulimit as=1024 fedora /bin/bash` |
|
| 476 |
+ |
|
| 477 |
+The values are sent to the appropriate `syscall` as they are set. |
|
| 478 |
+Docker doesn't perform any byte conversion. Take this into account when setting the values. |
| 0 | 479 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,37 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "save" |
|
| 2 |
+description = "The save command description and usage" |
|
| 3 |
+keywords = ["tarred, repository, backup"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# save |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker save [OPTIONS] IMAGE [IMAGE...] |
|
| 12 |
+ |
|
| 13 |
+ Save an image(s) to a tar archive (streamed to STDOUT by default) |
|
| 14 |
+ |
|
| 15 |
+ -o, --output="" Write to a file, instead of STDOUT |
|
| 16 |
+ |
|
| 17 |
+Produces a tarred repository to the standard output stream. |
|
| 18 |
+Contains all parent layers, and all tags + versions, or specified `repo:tag`, for |
|
| 19 |
+each argument provided. |
|
| 20 |
+ |
|
| 21 |
+It is used to create a backup that can then be used with `docker load` |
|
| 22 |
+ |
|
| 23 |
+ $ docker save busybox > busybox.tar |
|
| 24 |
+ $ ls -sh busybox.tar |
|
| 25 |
+ 2.7M busybox.tar |
|
| 26 |
+ $ docker save --output busybox.tar busybox |
|
| 27 |
+ $ ls -sh busybox.tar |
|
| 28 |
+ 2.7M busybox.tar |
|
| 29 |
+ $ docker save -o fedora-all.tar fedora |
|
| 30 |
+ $ docker save -o fedora-latest.tar fedora:latest |
|
| 31 |
+ |
|
| 32 |
+It is even useful to cherry-pick particular tags of an image repository |
|
| 33 |
+ |
|
| 34 |
+ $ docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy |
| 0 | 35 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,29 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "search" |
|
| 2 |
+description = "The search command description and usage" |
|
| 3 |
+keywords = ["search, hub, images"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# search |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker search [OPTIONS] TERM |
|
| 12 |
+ |
|
| 13 |
+ Search the Docker Hub for images |
|
| 14 |
+ |
|
| 15 |
+ --automated=false Only show automated builds |
|
| 16 |
+ --no-trunc=false Don't truncate output |
|
| 17 |
+ -s, --stars=0 Only displays with at least x stars |
|
| 18 |
+ |
|
| 19 |
+Search [Docker Hub](https://hub.docker.com) for images |
|
| 20 |
+ |
|
| 21 |
+See [*Find Public Images on Docker Hub*](/userguide/dockerrepos/#searching-for-images) for |
|
| 22 |
+more details on finding shared images from the command line. |
|
| 23 |
+ |
|
| 24 |
+> **Note:** |
|
| 25 |
+> Search queries will only return up to 25 results |
|
| 26 |
+ |
| 0 | 27 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,20 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "start" |
|
| 2 |
+description = "The start command description and usage" |
|
| 3 |
+keywords = ["Start, container, stopped"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# start |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker start [OPTIONS] CONTAINER [CONTAINER...] |
|
| 12 |
+ |
|
| 13 |
+ Start one or more stopped containers |
|
| 14 |
+ |
|
| 15 |
+ -a, --attach=false Attach STDOUT/STDERR and forward signals |
|
| 16 |
+ -i, --interactive=false Attach container's STDIN |
|
| 17 |
+ |
| 0 | 18 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,34 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "stats" |
|
| 2 |
+description = "The stats command description and usage" |
|
| 3 |
+keywords = ["container, resource, statistics"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# stats |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker stats CONTAINER [CONTAINER...] |
|
| 12 |
+ |
|
| 13 |
+ Display a live stream of one or more containers' resource usage statistics |
|
| 14 |
+ |
|
| 15 |
+ --help=false Print usage |
|
| 16 |
+ --no-stream=false Disable streaming stats and only pull the first result |
|
| 17 |
+ |
|
| 18 |
+Running `docker stats` on multiple containers |
|
| 19 |
+ |
|
| 20 |
+ $ docker stats redis1 redis2 |
|
| 21 |
+ CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O |
|
| 22 |
+ redis1 0.07% 796 KB/64 MB 1.21% 788 B/648 B |
|
| 23 |
+ redis2 0.07% 2.746 MB/64 MB 4.29% 1.266 KB/648 B |
|
| 24 |
+ |
|
| 25 |
+ |
|
| 26 |
+The `docker stats` command will only return a live stream of data for running |
|
| 27 |
+containers. Stopped containers will not return any data. |
|
| 28 |
+ |
|
| 29 |
+> **Note:** |
|
| 30 |
+> If you want more detailed information about a container's resource |
|
| 31 |
+> usage, use the API endpoint. |
|
| 0 | 32 |
\ No newline at end of file |
| 1 | 33 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,22 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "stop" |
|
| 2 |
+description = "The stop command description and usage" |
|
| 3 |
+keywords = ["stop, SIGKILL, SIGTERM"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# stop |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...] |
|
| 12 |
+ |
|
| 13 |
+ Stop a running container by sending SIGTERM and then SIGKILL after a |
|
| 14 |
+ grace period |
|
| 15 |
+ |
|
| 16 |
+ -t, --time=10 Seconds to wait for stop before killing it |
|
| 17 |
+ |
|
| 18 |
+The main process inside the container will receive `SIGTERM`, and after a grace |
|
| 19 |
+period, `SIGKILL`. |
|
| 0 | 20 |
\ No newline at end of file |
| 1 | 21 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,21 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "tag" |
|
| 2 |
+description = "The tag command description and usage" |
|
| 3 |
+keywords = ["tag, name, image"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# tag |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG] |
|
| 12 |
+ |
|
| 13 |
+ Tag an image into a repository |
|
| 14 |
+ |
|
| 15 |
+ -f, --force=false Force |
|
| 16 |
+ |
|
| 17 |
+You can group your images together using names and tags, and then upload them |
|
| 18 |
+to [*Share Images via Repositories*](/userguide/dockerrepos/#contributing-to-docker-hub). |
| 0 | 19 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,16 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "top" |
|
| 2 |
+description = "The top command description and usage" |
|
| 3 |
+keywords = ["container, running, processes"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# top |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker top CONTAINER [ps OPTIONS] |
|
| 12 |
+ |
|
| 13 |
+ Display the running processes of a container |
|
| 0 | 14 |
\ No newline at end of file |
| 1 | 15 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,23 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "unpause" |
|
| 2 |
+description = "The unpause command description and usage" |
|
| 3 |
+keywords = ["cgroups, suspend, container"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# unpause |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker unpause CONTAINER [CONTAINER...] |
|
| 12 |
+ |
|
| 13 |
+ Unpause all processes within a container |
|
| 14 |
+ |
|
| 15 |
+The `docker unpause` command uses the cgroups freezer to un-suspend all |
|
| 16 |
+processes in a container. |
|
| 17 |
+ |
|
| 18 |
+See the |
|
| 19 |
+[cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt) |
|
| 20 |
+for further details. |
| 0 | 21 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,31 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "version" |
|
| 2 |
+description = "The version command description and usage" |
|
| 3 |
+keywords = ["version, architecture, api"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# version |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker version |
|
| 12 |
+ |
|
| 13 |
+ Show the Docker version information. |
|
| 14 |
+ |
|
| 15 |
+Show the Docker version, API version, Git commit, Go version and |
|
| 16 |
+OS/architecture of both Docker client and daemon. Example use: |
|
| 17 |
+ |
|
| 18 |
+ $ docker version |
|
| 19 |
+ Client version: 1.5.0 |
|
| 20 |
+ Client API version: 1.17 |
|
| 21 |
+ Go version (client): go1.4.1 |
|
| 22 |
+ Git commit (client): a8a31ef |
|
| 23 |
+ OS/Arch (client): darwin/amd64 |
|
| 24 |
+ Server version: 1.5.0 |
|
| 25 |
+ Server API version: 1.17 |
|
| 26 |
+ Go version (server): go1.4.1 |
|
| 27 |
+ Git commit (server): a8a31ef |
|
| 28 |
+ OS/Arch (server): linux/amd64 |
|
| 0 | 29 |
\ No newline at end of file |
| 1 | 30 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,16 @@ |
| 0 |
+<!--[metadata]> |
|
| 1 |
+title = "wait" |
|
| 2 |
+description = "The wait command description and usage" |
|
| 3 |
+keywords = ["container, stop, wait"] |
|
| 4 |
+[menu.main] |
|
| 5 |
+parent = "smn_cli" |
|
| 6 |
+weight=1 |
|
| 7 |
+<![end-metadata]--> |
|
| 8 |
+ |
|
| 9 |
+# wait |
|
| 10 |
+ |
|
| 11 |
+ Usage: docker wait CONTAINER [CONTAINER...] |
|
| 12 |
+ |
|
| 13 |
+ Block until a container stops, then print its exit code. |
|
| 0 | 14 |
\ No newline at end of file |