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