github.com/wulonghui/docker@v1.8.0-rc2/man/docker.1.md (about) 1 % DOCKER(1) Docker User Manuals 2 % William Henry 3 % APRIL 2014 4 # NAME 5 docker \- Docker image and container command line interface 6 7 # SYNOPSIS 8 **docker** [OPTIONS] COMMAND [arg...] 9 10 # DESCRIPTION 11 **docker** has two distinct functions. It is used for starting the Docker 12 daemon and to run the CLI (i.e., to command the daemon to manage images, 13 containers etc.) So **docker** is both a server, as a daemon, and a client 14 to the daemon, through the CLI. 15 16 To run the Docker daemon you do not specify any of the commands listed below but 17 must specify the **-d** option. The other options listed below are for the 18 daemon only. 19 20 The Docker CLI has over 30 commands. The commands are listed below and each has 21 its own man page which explain usage and arguments. 22 23 To see the man page for a command run **man docker <command>**. 24 25 # OPTIONS 26 **-h**, **--help** 27 Print usage statement 28 29 **--api-cors-header**="" 30 Set CORS headers in the remote API. Default is cors disabled. Give urls like "http://foo, http://bar, ...". Give "*" to allow all. 31 32 **-b**, **--bridge**="" 33 Attach containers to a pre\-existing network bridge; use 'none' to disable container networking 34 35 **--bip**="" 36 Use the provided CIDR notation address for the dynamically created bridge (docker0); Mutually exclusive of \-b 37 38 **--config**="" 39 Specifies the location of the Docker client configuration files. The default is '~/.docker'. 40 41 **-D**, **--debug**=*true*|*false* 42 Enable debug mode. Default is false. 43 44 **-d**, **--daemon**=*true*|*false* 45 Enable daemon mode. Default is false. 46 47 **--default-gateway**="" 48 IPv4 address of the container default gateway; this address must be part of the bridge subnet (which is defined by \-b or \--bip) 49 50 **--default-gateway-v6**="" 51 IPv6 address of the container default gateway 52 53 **--dns**="" 54 Force Docker to use specific DNS servers 55 56 **-e**, **--exec-driver**="" 57 Force Docker to use specific exec driver. Default is `native`. 58 59 **--exec-opt**=[] 60 Set exec driver options. See EXEC DRIVER OPTIONS. 61 62 **--exec-root**="" 63 Path to use as the root of the Docker execdriver. Default is `/var/run/docker`. 64 65 **--fixed-cidr**="" 66 IPv4 subnet for fixed IPs (e.g., 10.20.0.0/16); this subnet must be nested in the bridge subnet (which is defined by \-b or \-\-bip) 67 68 **--fixed-cidr-v6**="" 69 IPv6 subnet for global IPv6 addresses (e.g., 2a00:1450::/64) 70 71 **-G**, **--group**="" 72 Group to assign the unix socket specified by -H when running in daemon mode. 73 use '' (the empty string) to disable setting of a group. Default is `docker`. 74 75 **-g**, **--graph**="" 76 Path to use as the root of the Docker runtime. Default is `/var/lib/docker`. 77 78 **-H**, **--host**=[unix:///var/run/docker.sock]: tcp://[host:port] to bind or 79 unix://[/path/to/socket] to use. 80 The socket(s) to bind to in daemon mode specified using one or more 81 tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd. 82 83 **--icc**=*true*|*false* 84 Allow unrestricted inter\-container and Docker daemon host communication. If disabled, containers can still be linked together using **--link** option (see **docker-run(1)**). Default is true. 85 86 **--ip**="" 87 Default IP address to use when binding container ports. Default is `0.0.0.0`. 88 89 **--ip-forward**=*true*|*false* 90 Enables IP forwarding on the Docker host. The default is `true`. This flag interacts with the IP forwarding setting on your host system's kernel. If your system has IP forwarding disabled, this setting enables it. If your system has IP forwarding enabled, setting this flag to `--ip-forward=false` has no effect. 91 92 This setting will also enable IPv6 forwarding if you have both `--ip-forward=true` and `--fixed-cidr-v6` set. Note that this may reject Router Advertisements and interfere with the host's existing IPv6 configuration. For more information, please consult the documentation about "Advanced Networking - IPv6". 93 94 **--ip-masq**=*true*|*false* 95 Enable IP masquerading for bridge's IP range. Default is true. 96 97 **--iptables**=*true*|*false* 98 Enable Docker's addition of iptables rules. Default is true. 99 100 **--ipv6**=*true*|*false* 101 Enable IPv6 support. Default is false. Docker will create an IPv6-enabled bridge with address fe80::1 which will allow you to create IPv6-enabled containers. Use together with `--fixed-cidr-v6` to provide globally routable IPv6 addresses. IPv6 forwarding will be enabled if not used with `--ip-forward=false`. This may collide with your host's current IPv6 settings. For more information please consult the documentation about "Advanced Networking - IPv6". 102 103 **-l**, **--log-level**="*debug*|*info*|*warn*|*error*|*fatal*"" 104 Set the logging level. Default is `info`. 105 106 **--label**="[]" 107 Set key=value labels to the daemon (displayed in `docker info`) 108 109 **--log-driver**="*json-file*|*syslog*|*journald*|*gelf*|*fluentd*|*none*" 110 Default driver for container logs. Default is `json-file`. 111 **Warning**: `docker logs` command works only for `json-file` logging driver. 112 113 **--log-opt**=[] 114 Logging driver specific options. 115 116 **--mtu**=VALUE 117 Set the containers network mtu. Default is `0`. 118 119 **-p**, **--pidfile**="" 120 Path to use for daemon PID file. Default is `/var/run/docker.pid` 121 122 **--registry-mirror**=<scheme>://<host> 123 Prepend a registry mirror to be used for image pulls. May be specified multiple times. 124 125 **-s**, **--storage-driver**="" 126 Force the Docker runtime to use a specific storage driver. 127 128 **--selinux-enabled**=*true*|*false* 129 Enable selinux support. Default is false. SELinux does not presently support the BTRFS storage driver. 130 131 **--storage-opt**=[] 132 Set storage driver options. See STORAGE DRIVER OPTIONS. 133 134 **-tls**=*true*|*false* 135 Use TLS; implied by --tlsverify. Default is false. 136 137 **-tlsverify**=*true*|*false* 138 Use TLS and verify the remote (daemon: verify client, client: verify daemon). 139 Default is false. 140 141 **--userland-proxy**=*true*|*false* 142 Rely on a userland proxy implementation for inter-container and outside-to-container loopback communications. Default is true. 143 144 **-v**, **--version**=*true*|*false* 145 Print version information and quit. Default is false. 146 147 # COMMANDS 148 **attach** 149 Attach to a running container 150 See **docker-attach(1)** for full documentation on the **attach** command. 151 152 **build** 153 Build an image from a Dockerfile 154 See **docker-build(1)** for full documentation on the **build** command. 155 156 **commit** 157 Create a new image from a container's changes 158 See **docker-commit(1)** for full documentation on the **commit** command. 159 160 **cp** 161 Copy files/folders from a container's filesystem to the host 162 See **docker-cp(1)** for full documentation on the **cp** command. 163 164 **create** 165 Create a new container 166 See **docker-create(1)** for full documentation on the **create** command. 167 168 **diff** 169 Inspect changes on a container's filesystem 170 See **docker-diff(1)** for full documentation on the **diff** command. 171 172 **events** 173 Get real time events from the server 174 See **docker-events(1)** for full documentation on the **events** command. 175 176 **exec** 177 Run a command in a running container 178 See **docker-exec(1)** for full documentation on the **exec** command. 179 180 **export** 181 Stream the contents of a container as a tar archive 182 See **docker-export(1)** for full documentation on the **export** command. 183 184 **history** 185 Show the history of an image 186 See **docker-history(1)** for full documentation on the **history** command. 187 188 **images** 189 List images 190 See **docker-images(1)** for full documentation on the **images** command. 191 192 **import** 193 Create a new filesystem image from the contents of a tarball 194 See **docker-import(1)** for full documentation on the **import** command. 195 196 **info** 197 Display system-wide information 198 See **docker-info(1)** for full documentation on the **info** command. 199 200 **inspect** 201 Return low-level information on a container or image 202 See **docker-inspect(1)** for full documentation on the **inspect** command. 203 204 **kill** 205 Kill a running container (which includes the wrapper process and everything 206 inside it) 207 See **docker-kill(1)** for full documentation on the **kill** command. 208 209 **load** 210 Load an image from a tar archive 211 See **docker-load(1)** for full documentation on the **load** command. 212 213 **login** 214 Register or login to a Docker Registry 215 See **docker-login(1)** for full documentation on the **login** command. 216 217 **logout** 218 Log the user out of a Docker Registry 219 See **docker-logout(1)** for full documentation on the **logout** command. 220 221 **logs** 222 Fetch the logs of a container 223 See **docker-logs(1)** for full documentation on the **logs** command. 224 225 **pause** 226 Pause all processes within a container 227 See **docker-pause(1)** for full documentation on the **pause** command. 228 229 **port** 230 Lookup the public-facing port which is NAT-ed to PRIVATE_PORT 231 See **docker-port(1)** for full documentation on the **port** command. 232 233 **ps** 234 List containers 235 See **docker-ps(1)** for full documentation on the **ps** command. 236 237 **pull** 238 Pull an image or a repository from a Docker Registry 239 See **docker-pull(1)** for full documentation on the **pull** command. 240 241 **push** 242 Push an image or a repository to a Docker Registry 243 See **docker-push(1)** for full documentation on the **push** command. 244 245 **restart** 246 Restart a running container 247 See **docker-restart(1)** for full documentation on the **restart** command. 248 249 **rm** 250 Remove one or more containers 251 See **docker-rm(1)** for full documentation on the **rm** command. 252 253 **rmi** 254 Remove one or more images 255 See **docker-rmi(1)** for full documentation on the **rmi** command. 256 257 **run** 258 Run a command in a new container 259 See **docker-run(1)** for full documentation on the **run** command. 260 261 **save** 262 Save an image to a tar archive 263 See **docker-save(1)** for full documentation on the **save** command. 264 265 **search** 266 Search for an image in the Docker index 267 See **docker-search(1)** for full documentation on the **search** command. 268 269 **start** 270 Start a stopped container 271 See **docker-start(1)** for full documentation on the **start** command. 272 273 **stats** 274 Display a live stream of one or more containers' resource usage statistics 275 See **docker-stats(1)** for full documentation on the **stats** command. 276 277 **stop** 278 Stop a running container 279 See **docker-stop(1)** for full documentation on the **stop** command. 280 281 **tag** 282 Tag an image into a repository 283 See **docker-tag(1)** for full documentation on the **tag** command. 284 285 **top** 286 Lookup the running processes of a container 287 See **docker-top(1)** for full documentation on the **top** command. 288 289 **unpause** 290 Unpause all processes within a container 291 See **docker-unpause(1)** for full documentation on the **unpause** command. 292 293 **version** 294 Show the Docker version information 295 See **docker-version(1)** for full documentation on the **version** command. 296 297 **wait** 298 Block until a container stops, then print its exit code 299 See **docker-wait(1)** for full documentation on the **wait** command. 300 301 # STORAGE DRIVER OPTIONS 302 303 Docker uses storage backends (known as "graphdrivers" in the Docker 304 internals) to create writable containers from images. Many of these 305 backends use operating system level technologies and can be 306 configured. 307 308 Specify options to the storage backend with **--storage-opt** flags. The only 309 backend that currently takes options is *devicemapper*. Therefore use these 310 flags with **-s=**devicemapper. 311 312 Specifically for devicemapper, the default is a "loopback" model which 313 requires no pre-configuration, but is extremely inefficient. Do not 314 use it in production. 315 316 To make the best use of Docker with the devicemapper backend, you must 317 have a recent version of LVM. Use `lvm` to create a thin pool; for 318 more information see `man lvmthin`. Then, use `--storage-opt 319 dm.thinpooldev` to tell the Docker engine to use that pool for 320 allocating images and container snapshots. 321 322 Here is the list of *devicemapper* options: 323 324 #### dm.thinpooldev 325 326 Specifies a custom block storage device to use for the thin pool. 327 328 If using a block device for device mapper storage, it is best to use 329 `lvm` to create and manage the thin-pool volume. This volume is then 330 handed to Docker to create snapshot volumes needed for images and 331 containers. 332 333 Managing the thin-pool outside of Docker makes for the most feature-rich method 334 of having Docker utilize device mapper thin provisioning as the backing storage 335 for Docker's containers. The highlights of the LVM-based thin-pool management 336 feature include: automatic or interactive thin-pool resize support, dynamically 337 changing thin-pool features, automatic thinp metadata checking when lvm activates 338 the thin-pool, etc. 339 340 Example use: `docker -d --storage-opt dm.thinpooldev=/dev/mapper/thin-pool` 341 342 #### dm.basesize 343 344 Specifies the size to use when creating the base device, which limits 345 the size of images and containers. The default value is 100G. Note, 346 thin devices are inherently "sparse", so a 100G device which is mostly 347 empty doesn't use 100 GB of space on the pool. However, the filesystem 348 will use more space for base images the larger the device 349 is. 350 351 This value affects the system-wide "base" empty filesystem that may already 352 be initialized and inherited by pulled images. Typically, a change to this 353 value requires additional steps to take effect: 354 355 $ sudo service docker stop 356 $ sudo rm -rf /var/lib/docker 357 $ sudo service docker start 358 359 Example use: `docker -d --storage-opt dm.basesize=20G` 360 361 #### dm.fs 362 363 Specifies the filesystem type to use for the base device. The 364 supported options are `ext4` and `xfs`. The default is `ext4`. 365 366 Example use: `docker -d --storage-opt dm.fs=xfs` 367 368 #### dm.mkfsarg 369 370 Specifies extra mkfs arguments to be used when creating the base device. 371 372 Example use: `docker -d --storage-opt "dm.mkfsarg=-O ^has_journal"` 373 374 #### dm.mountopt 375 376 Specifies extra mount options used when mounting the thin devices. 377 378 Example use: `docker -d --storage-opt dm.mountopt=nodiscard` 379 380 #### dm.use_deferred_removal 381 382 Enables use of deferred device removal if `libdm` and the kernel driver 383 support the mechanism. 384 385 Deferred device removal means that if device is busy when devices are 386 being removed/deactivated, then a deferred removal is scheduled on 387 device. And devices automatically go away when last user of the device 388 exits. 389 390 For example, when a container exits, its associated thin device is removed. If 391 that device has leaked into some other mount namespace and can't be removed, 392 the container exit still succeeds and this option causes the system to schedule 393 the device for deferred removal. It does not wait in a loop trying to remove a busy 394 device. 395 396 Example use: `docker -d --storage-opt dm.use_deferred_removal=true` 397 398 #### dm.loopdatasize 399 400 **Note**: This option configures devicemapper loopback, which should not be used in production. 401 402 Specifies the size to use when creating the loopback file for the 403 "data" device which is used for the thin pool. The default size is 404 100G. The file is sparse, so it will not initially take up 405 this much space. 406 407 Example use: `docker -d --storage-opt dm.loopdatasize=200G` 408 409 #### dm.loopmetadatasize 410 411 **Note**: This option configures devicemapper loopback, which should not be used in production. 412 413 Specifies the size to use when creating the loopback file for the 414 "metadadata" device which is used for the thin pool. The default size 415 is 2G. The file is sparse, so it will not initially take up 416 this much space. 417 418 Example use: `docker -d --storage-opt dm.loopmetadatasize=4G` 419 420 #### dm.datadev 421 422 (Deprecated, use `dm.thinpooldev`) 423 424 Specifies a custom blockdevice to use for data for a 425 Docker-managed thin pool. It is better to use `dm.thinpooldev` - see 426 the documentation for it above for discussion of the advantages. 427 428 #### dm.metadatadev 429 430 (Deprecated, use `dm.thinpooldev`) 431 432 Specifies a custom blockdevice to use for metadata for a 433 Docker-managed thin pool. See `dm.datadev` for why this is 434 deprecated. 435 436 #### dm.blocksize 437 438 Specifies a custom blocksize to use for the thin pool. The default 439 blocksize is 64K. 440 441 Example use: `docker -d --storage-opt dm.blocksize=512K` 442 443 #### dm.blkdiscard 444 445 Enables or disables the use of `blkdiscard` when removing devicemapper 446 devices. This is disabled by default due to the additional latency, 447 but as a special case with loopback devices it will be enabled, in 448 order to re-sparsify the loopback file on image/container removal. 449 450 Disabling this on loopback can lead to *much* faster container removal 451 times, but it also prevents the space used in `/var/lib/docker` directory 452 from being returned to the system for other use when containers are 453 removed. 454 455 Example use: `docker -d --storage-opt dm.blkdiscard=false` 456 457 #### dm.override_udev_sync_check 458 459 By default, the devicemapper backend attempts to synchronize with the 460 `udev` device manager for the Linux kernel. This option allows 461 disabling that synchronization, to continue even though the 462 configuration may be buggy. 463 464 To view the `udev` sync support of a Docker daemon that is using the 465 `devicemapper` driver, run: 466 467 $ docker info 468 [...] 469 Udev Sync Supported: true 470 [...] 471 472 When `udev` sync support is `true`, then `devicemapper` and `udev` can 473 coordinate the activation and deactivation of devices for containers. 474 475 When `udev` sync support is `false`, a race condition occurs between 476 the`devicemapper` and `udev` during create and cleanup. The race 477 condition results in errors and failures. (For information on these 478 failures, see 479 [docker#4036](https://github.com/docker/docker/issues/4036)) 480 481 To allow the `docker` daemon to start, regardless of whether `udev` sync is 482 `false`, set `dm.override_udev_sync_check` to true: 483 484 $ docker -d --storage-opt dm.override_udev_sync_check=true 485 486 When this value is `true`, the driver continues and simply warns you 487 the errors are happening. 488 489 **Note**: The ideal is to pursue a `docker` daemon and environment 490 that does support synchronizing with `udev`. For further discussion on 491 this topic, see 492 [docker#4036](https://github.com/docker/docker/issues/4036). 493 Otherwise, set this flag for migrating existing Docker daemons to a 494 daemon with a supported environment. 495 496 # EXEC DRIVER OPTIONS 497 498 Use the **--exec-opt** flags to specify options to the exec-driver. The only 499 driver that accepts this flag is the *native* (libcontainer) driver. As a 500 result, you must also specify **-s=**native for this option to have effect. The 501 following is the only *native* option: 502 503 #### native.cgroupdriver 504 Specifies the management of the container's `cgroups`. You can specify 505 `cgroupfs` or `systemd`. If you specify `systemd` and it is not available, the 506 system uses `cgroupfs`. 507 508 #### Client 509 For specific client examples please see the man page for the specific Docker 510 command. For example: 511 512 man docker-run 513 514 # HISTORY 515 April 2014, Originally compiled by William Henry (whenry at redhat dot com) based on docker.com source material and internal work.