github.com/tompao/docker@v1.9.1/docs/reference/commandline/daemon.md (about) 1 <!--[metadata]> 2 +++ 3 title = "daemon" 4 description = "The daemon command description and usage" 5 keywords = ["container, daemon, runtime"] 6 [menu.main] 7 parent = "smn_cli" 8 weight = -1 9 +++ 10 <![end-metadata]--> 11 12 # daemon 13 14 Usage: docker daemon [OPTIONS] 15 16 A self-sufficient runtime for linux containers. 17 18 Options: 19 --api-cors-header="" Set CORS headers in the remote API 20 -b, --bridge="" Attach containers to a network bridge 21 --bip="" Specify network bridge IP 22 -D, --debug=false Enable debug mode 23 --default-gateway="" Container default gateway IPv4 address 24 --default-gateway-v6="" Container default gateway IPv6 address 25 --cluster-store="" URL of the distributed storage backend 26 --cluster-advertise="" Address of the daemon instance on the cluster 27 --cluster-store-opt=map[] Set cluster options 28 --dns=[] DNS server to use 29 --dns-opt=[] DNS options to use 30 --dns-search=[] DNS search domains to use 31 --default-ulimit=[] Set default ulimit settings for containers 32 -e, --exec-driver="native" Exec driver to use 33 --exec-opt=[] Set exec driver options 34 --exec-root="/var/run/docker" Root of the Docker execdriver 35 --fixed-cidr="" IPv4 subnet for fixed IPs 36 --fixed-cidr-v6="" IPv6 subnet for fixed IPs 37 -G, --group="docker" Group for the unix socket 38 -g, --graph="/var/lib/docker" Root of the Docker runtime 39 -H, --host=[] Daemon socket(s) to connect to 40 --help=false Print usage 41 --icc=true Enable inter-container communication 42 --insecure-registry=[] Enable insecure registry communication 43 --ip=0.0.0.0 Default IP when binding container ports 44 --ip-forward=true Enable net.ipv4.ip_forward 45 --ip-masq=true Enable IP masquerading 46 --iptables=true Enable addition of iptables rules 47 --ipv6=false Enable IPv6 networking 48 -l, --log-level="info" Set the logging level 49 --label=[] Set key=value labels to the daemon 50 --log-driver="json-file" Default driver for container logs 51 --log-opt=[] Log driver specific options 52 --mtu=0 Set the containers network MTU 53 --disable-legacy-registry=false Do not contact legacy registries 54 -p, --pidfile="/var/run/docker.pid" Path to use for daemon PID file 55 --registry-mirror=[] Preferred Docker registry mirror 56 -s, --storage-driver="" Storage driver to use 57 --selinux-enabled=false Enable selinux support 58 --storage-opt=[] Set storage driver options 59 --tls=false Use TLS; implied by --tlsverify 60 --tlscacert="~/.docker/ca.pem" Trust certs signed only by this CA 61 --tlscert="~/.docker/cert.pem" Path to TLS certificate file 62 --tlskey="~/.docker/key.pem" Path to TLS key file 63 --tlsverify=false Use TLS and verify the remote 64 --userland-proxy=true Use userland proxy for loopback traffic 65 66 Options with [] may be specified multiple times. 67 68 The Docker daemon is the persistent process that manages containers. Docker 69 uses the same binary for both the daemon and client. To run the daemon you 70 type `docker daemon`. 71 72 To run the daemon with debug output, use `docker daemon -D`. 73 74 ## Daemon socket option 75 76 The Docker daemon can listen for [Docker Remote API](../api/docker_remote_api.md) 77 requests via three different types of Socket: `unix`, `tcp`, and `fd`. 78 79 By default, a `unix` domain socket (or IPC socket) is created at 80 `/var/run/docker.sock`, requiring either `root` permission, or `docker` group 81 membership. 82 83 If you need to access the Docker daemon remotely, you need to enable the `tcp` 84 Socket. Beware that the default setup provides un-encrypted and 85 un-authenticated direct access to the Docker daemon - and should be secured 86 either using the [built in HTTPS encrypted socket](../../articles/https/), or by 87 putting a secure web proxy in front of it. You can listen on port `2375` on all 88 network interfaces with `-H tcp://0.0.0.0:2375`, or on a particular network 89 interface using its IP address: `-H tcp://192.168.59.103:2375`. It is 90 conventional to use port `2375` for un-encrypted, and port `2376` for encrypted 91 communication with the daemon. 92 93 > **Note:** 94 > If you're using an HTTPS encrypted socket, keep in mind that only 95 > TLS1.0 and greater are supported. Protocols SSLv3 and under are not 96 > supported anymore for security reasons. 97 98 On Systemd based systems, you can communicate with the daemon via 99 [Systemd socket activation](http://0pointer.de/blog/projects/socket-activation.html), 100 use `docker daemon -H fd://`. Using `fd://` will work perfectly for most setups but 101 you can also specify individual sockets: `docker daemon -H fd://3`. If the 102 specified socket activated files aren't found, then Docker will exit. You can 103 find examples of using Systemd socket activation with Docker and Systemd in the 104 [Docker source tree](https://github.com/docker/docker/tree/master/contrib/init/systemd/). 105 106 You can configure the Docker daemon to listen to multiple sockets at the same 107 time using multiple `-H` options: 108 109 # listen using the default unix socket, and on 2 specific IP addresses on this host. 110 docker daemon -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2 111 112 The Docker client will honor the `DOCKER_HOST` environment variable to set the 113 `-H` flag for the client. 114 115 $ docker -H tcp://0.0.0.0:2375 ps 116 # or 117 $ export DOCKER_HOST="tcp://0.0.0.0:2375" 118 $ docker ps 119 # both are equal 120 121 Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than 122 the empty string is equivalent to setting the `--tlsverify` flag. The following 123 are equivalent: 124 125 $ docker --tlsverify ps 126 # or 127 $ export DOCKER_TLS_VERIFY=1 128 $ docker ps 129 130 The Docker client will honor the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` 131 environment variables (or the lowercase versions thereof). `HTTPS_PROXY` takes 132 precedence over `HTTP_PROXY`. 133 134 ### Daemon storage-driver option 135 136 The Docker daemon has support for several different image layer storage 137 drivers: `aufs`, `devicemapper`, `btrfs`, `zfs` and `overlay`. 138 139 The `aufs` driver is the oldest, but is based on a Linux kernel patch-set that 140 is unlikely to be merged into the main kernel. These are also known to cause 141 some serious kernel crashes. However, `aufs` is also the only storage driver 142 that allows containers to share executable and shared library memory, so is a 143 useful choice when running thousands of containers with the same program or 144 libraries. 145 146 The `devicemapper` driver uses thin provisioning and Copy on Write (CoW) 147 snapshots. For each devicemapper graph location – typically 148 `/var/lib/docker/devicemapper` – a thin pool is created based on two block 149 devices, one for data and one for metadata. By default, these block devices 150 are created automatically by using loopback mounts of automatically created 151 sparse files. Refer to [Storage driver options](#storage-driver-options) below 152 for a way how to customize this setup. 153 [~jpetazzo/Resizing Docker containers with the Device Mapper plugin](http://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/) 154 article explains how to tune your existing setup without the use of options. 155 156 The `btrfs` driver is very fast for `docker build` - but like `devicemapper` 157 does not share executable memory between devices. Use 158 `docker daemon -s btrfs -g /mnt/btrfs_partition`. 159 160 The `zfs` driver is probably not fast as `btrfs` but has a longer track record 161 on stability. Thanks to `Single Copy ARC` shared blocks between clones will be 162 cached only once. Use `docker daemon -s zfs`. To select a different zfs filesystem 163 set `zfs.fsname` option as described in [Storage driver options](#storage-driver-options). 164 165 The `overlay` is a very fast union filesystem. It is now merged in the main 166 Linux kernel as of [3.18.0](https://lkml.org/lkml/2014/10/26/137). Call 167 `docker daemon -s overlay` to use it. 168 169 > **Note:** 170 > As promising as `overlay` is, the feature is still quite young and should not 171 > be used in production. Most notably, using `overlay` can cause excessive 172 > inode consumption (especially as the number of images grows), as well as 173 > being incompatible with the use of RPMs. 174 175 > **Note:** 176 > It is currently unsupported on `btrfs` or any Copy on Write filesystem 177 > and should only be used over `ext4` partitions. 178 179 ### Storage driver options 180 181 Particular storage-driver can be configured with options specified with 182 `--storage-opt` flags. Options for `devicemapper` are prefixed with `dm` and 183 options for `zfs` start with `zfs`. 184 185 * `dm.thinpooldev` 186 187 Specifies a custom block storage device to use for the thin pool. 188 189 If using a block device for device mapper storage, it is best to use `lvm` 190 to create and manage the thin-pool volume. This volume is then handed to Docker 191 to exclusively create snapshot volumes needed for images and containers. 192 193 Managing the thin-pool outside of Docker makes for the most feature-rich 194 method of having Docker utilize device mapper thin provisioning as the 195 backing storage for Docker's containers. The highlights of the lvm-based 196 thin-pool management feature include: automatic or interactive thin-pool 197 resize support, dynamically changing thin-pool features, automatic thinp 198 metadata checking when lvm activates the thin-pool, etc. 199 200 As a fallback if no thin pool is provided, loopback files will be 201 created. Loopback is very slow, but can be used without any 202 pre-configuration of storage. It is strongly recommended that you do 203 not use loopback in production. Ensure your Docker daemon has a 204 `--storage-opt dm.thinpooldev` argument provided. 205 206 Example use: 207 208 $ docker daemon \ 209 --storage-opt dm.thinpooldev=/dev/mapper/thin-pool 210 211 * `dm.basesize` 212 213 Specifies the size to use when creating the base device, which limits the 214 size of images and containers. The default value is 100G. Note, thin devices 215 are inherently "sparse", so a 100G device which is mostly empty doesn't use 216 100 GB of space on the pool. However, the filesystem will use more space for 217 the empty case the larger the device is. 218 219 This value affects the system-wide "base" empty filesystem 220 that may already be initialized and inherited by pulled images. Typically, 221 a change to this value requires additional steps to take effect: 222 223 $ sudo service docker stop 224 $ sudo rm -rf /var/lib/docker 225 $ sudo service docker start 226 227 Example use: 228 229 $ docker daemon --storage-opt dm.basesize=20G 230 231 * `dm.loopdatasize` 232 233 > **Note**: 234 > This option configures devicemapper loopback, which should not 235 > be used in production. 236 237 Specifies the size to use when creating the loopback file for the 238 "data" device which is used for the thin pool. The default size is 239 100G. The file is sparse, so it will not initially take up this 240 much space. 241 242 Example use: 243 244 $ docker daemon --storage-opt dm.loopdatasize=200G 245 246 * `dm.loopmetadatasize` 247 248 > **Note**: 249 > This option configures devicemapper loopback, which should not 250 > be used in production. 251 252 Specifies the size to use when creating the loopback file for the 253 "metadata" device which is used for the thin pool. The default size 254 is 2G. The file is sparse, so it will not initially take up 255 this much space. 256 257 Example use: 258 259 $ docker daemon --storage-opt dm.loopmetadatasize=4G 260 261 * `dm.fs` 262 263 Specifies the filesystem type to use for the base device. The supported 264 options are "ext4" and "xfs". The default is "xfs" 265 266 Example use: 267 268 $ docker daemon --storage-opt dm.fs=ext4 269 270 * `dm.mkfsarg` 271 272 Specifies extra mkfs arguments to be used when creating the base device. 273 274 Example use: 275 276 $ docker daemon --storage-opt "dm.mkfsarg=-O ^has_journal" 277 278 * `dm.mountopt` 279 280 Specifies extra mount options used when mounting the thin devices. 281 282 Example use: 283 284 $ docker daemon --storage-opt dm.mountopt=nodiscard 285 286 * `dm.datadev` 287 288 (Deprecated, use `dm.thinpooldev`) 289 290 Specifies a custom blockdevice to use for data for the thin pool. 291 292 If using a block device for device mapper storage, ideally both datadev and 293 metadatadev should be specified to completely avoid using the loopback 294 device. 295 296 Example use: 297 298 $ docker daemon \ 299 --storage-opt dm.datadev=/dev/sdb1 \ 300 --storage-opt dm.metadatadev=/dev/sdc1 301 302 * `dm.metadatadev` 303 304 (Deprecated, use `dm.thinpooldev`) 305 306 Specifies a custom blockdevice to use for metadata for the thin pool. 307 308 For best performance the metadata should be on a different spindle than the 309 data, or even better on an SSD. 310 311 If setting up a new metadata pool it is required to be valid. This can be 312 achieved by zeroing the first 4k to indicate empty metadata, like this: 313 314 $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1 315 316 Example use: 317 318 $ docker daemon \ 319 --storage-opt dm.datadev=/dev/sdb1 \ 320 --storage-opt dm.metadatadev=/dev/sdc1 321 322 * `dm.blocksize` 323 324 Specifies a custom blocksize to use for the thin pool. The default 325 blocksize is 64K. 326 327 Example use: 328 329 $ docker daemon --storage-opt dm.blocksize=512K 330 331 * `dm.blkdiscard` 332 333 Enables or disables the use of blkdiscard when removing devicemapper 334 devices. This is enabled by default (only) if using loopback devices and is 335 required to resparsify the loopback file on image/container removal. 336 337 Disabling this on loopback can lead to *much* faster container removal 338 times, but will make the space used in `/var/lib/docker` directory not be 339 returned to the system for other use when containers are removed. 340 341 Example use: 342 343 $ docker daemon --storage-opt dm.blkdiscard=false 344 345 * `dm.override_udev_sync_check` 346 347 Overrides the `udev` synchronization checks between `devicemapper` and `udev`. 348 `udev` is the device manager for the Linux kernel. 349 350 To view the `udev` sync support of a Docker daemon that is using the 351 `devicemapper` driver, run: 352 353 $ docker info 354 [...] 355 Udev Sync Supported: true 356 [...] 357 358 When `udev` sync support is `true`, then `devicemapper` and udev can 359 coordinate the activation and deactivation of devices for containers. 360 361 When `udev` sync support is `false`, a race condition occurs between 362 the`devicemapper` and `udev` during create and cleanup. The race condition 363 results in errors and failures. (For information on these failures, see 364 [docker#4036](https://github.com/docker/docker/issues/4036)) 365 366 To allow the `docker` daemon to start, regardless of `udev` sync not being 367 supported, set `dm.override_udev_sync_check` to true: 368 369 $ docker daemon --storage-opt dm.override_udev_sync_check=true 370 371 When this value is `true`, the `devicemapper` continues and simply warns 372 you the errors are happening. 373 374 > **Note:** 375 > The ideal is to pursue a `docker` daemon and environment that does 376 > support synchronizing with `udev`. For further discussion on this 377 > topic, see [docker#4036](https://github.com/docker/docker/issues/4036). 378 > Otherwise, set this flag for migrating existing Docker daemons to 379 > a daemon with a supported environment. 380 381 * `dm.use_deferred_removal` 382 383 Enables use of deferred device removal if `libdm` and the kernel driver 384 support the mechanism. 385 386 Deferred device removal means that if device is busy when devices are 387 being removed/deactivated, then a deferred removal is scheduled on 388 device. And devices automatically go away when last user of the device 389 exits. 390 391 For example, when a container exits, its associated thin device is removed. 392 If that device has leaked into some other mount namespace and can't be 393 removed, the container exit still succeeds and this option causes the 394 system to schedule the device for deferred removal. It does not wait in a 395 loop trying to remove a busy device. 396 397 Example use: 398 399 $ docker daemon --storage-opt dm.use_deferred_removal=true 400 401 * `dm.use_deferred_deletion` 402 403 Enables use of deferred device deletion for thin pool devices. By default, 404 thin pool device deletion is synchronous. Before a container is deleted, 405 the Docker daemon removes any associated devices. If the storage driver 406 can not remove a device, the container deletion fails and daemon returns. 407 408 Error deleting container: Error response from daemon: Cannot destroy container 409 410 To avoid this failure, enable both deferred device deletion and deferred 411 device removal on the daemon. 412 413 $ docker daemon \ 414 --storage-opt dm.use_deferred_deletion=true \ 415 --storage-opt dm.use_deferred_removal=true 416 417 With these two options enabled, if a device is busy when the driver is 418 deleting a container, the driver marks the device as deleted. Later, when 419 the device isn't in use, the driver deletes it. 420 421 In general it should be safe to enable this option by default. It will help 422 when unintentional leaking of mount point happens across multiple mount 423 namespaces. 424 425 Currently supported options of `zfs`: 426 427 * `zfs.fsname` 428 429 Set zfs filesystem under which docker will create its own datasets. 430 By default docker will pick up the zfs filesystem where docker graph 431 (`/var/lib/docker`) is located. 432 433 Example use: 434 435 $ docker daemon -s zfs --storage-opt zfs.fsname=zroot/docker 436 437 ## Docker execdriver option 438 439 The Docker daemon uses a specifically built `libcontainer` execution driver as 440 its interface to the Linux kernel `namespaces`, `cgroups`, and `SELinux`. 441 442 There is still legacy support for the original [LXC userspace tools]( 443 https://linuxcontainers.org/) via the `lxc` execution driver, however, this is 444 not where the primary development of new functionality is taking place. 445 Add `-e lxc` to the daemon flags to use the `lxc` execution driver. 446 447 ## Options for the native execdriver 448 449 You can configure the `native` (libcontainer) execdriver using options specified 450 with the `--exec-opt` flag. All the flag's options have the `native` prefix. A 451 single `native.cgroupdriver` option is available. 452 453 The `native.cgroupdriver` option specifies the management of the container's 454 cgroups. You can specify `cgroupfs` or `systemd`. If you specify `systemd` and 455 it is not available, the system uses `cgroupfs`. By default, if no option is 456 specified, the execdriver first tries `systemd` and falls back to `cgroupfs`. 457 This example sets the execdriver to `cgroupfs`: 458 459 $ sudo docker daemon --exec-opt native.cgroupdriver=cgroupfs 460 461 Setting this option applies to all containers the daemon launches. 462 463 ## Daemon DNS options 464 465 To set the DNS server for all Docker containers, use 466 `docker daemon --dns 8.8.8.8`. 467 468 To set the DNS search domain for all Docker containers, use 469 `docker daemon --dns-search example.com`. 470 471 ## Insecure registries 472 473 Docker considers a private registry either secure or insecure. In the rest of 474 this section, *registry* is used for *private registry*, and `myregistry:5000` 475 is a placeholder example for a private registry. 476 477 A secure registry uses TLS and a copy of its CA certificate is placed on the 478 Docker host at `/etc/docker/certs.d/myregistry:5000/ca.crt`. An insecure 479 registry is either not using TLS (i.e., listening on plain text HTTP), or is 480 using TLS with a CA certificate not known by the Docker daemon. The latter can 481 happen when the certificate was not found under 482 `/etc/docker/certs.d/myregistry:5000/`, or if the certificate verification 483 failed (i.e., wrong CA). 484 485 By default, Docker assumes all, but local (see local registries below), 486 registries are secure. Communicating with an insecure registry is not possible 487 if Docker assumes that registry is secure. In order to communicate with an 488 insecure registry, the Docker daemon requires `--insecure-registry` in one of 489 the following two forms: 490 491 * `--insecure-registry myregistry:5000` tells the Docker daemon that 492 myregistry:5000 should be considered insecure. 493 * `--insecure-registry 10.1.0.0/16` tells the Docker daemon that all registries 494 whose domain resolve to an IP address is part of the subnet described by the 495 CIDR syntax, should be considered insecure. 496 497 The flag can be used multiple times to allow multiple registries to be marked 498 as insecure. 499 500 If an insecure registry is not marked as insecure, `docker pull`, 501 `docker push`, and `docker search` will result in an error message prompting 502 the user to either secure or pass the `--insecure-registry` flag to the Docker 503 daemon as described above. 504 505 Local registries, whose IP address falls in the 127.0.0.0/8 range, are 506 automatically marked as insecure as of Docker 1.3.2. It is not recommended to 507 rely on this, as it may change in the future. 508 509 Enabling `--insecure-registry`, i.e., allowing un-encrypted and/or untrusted 510 communication, can be useful when running a local registry. However, 511 because its use creates security vulnerabilities it should ONLY be enabled for 512 testing purposes. For increased security, users should add their CA to their 513 system's list of trusted CAs instead of enabling `--insecure-registry`. 514 515 ## Legacy Registries 516 517 Enabling `--disable-legacy-registry` forces a docker daemon to only interact with registries which support the V2 protocol. Specifically, the daemon will not attempt `push`, `pull` and `login` to v1 registries. The exception to this is `search` which can still be performed on v1 registries. 518 519 ## Running a Docker daemon behind a HTTPS_PROXY 520 521 When running inside a LAN that uses a `HTTPS` proxy, the Docker Hub 522 certificates will be replaced by the proxy's certificates. These certificates 523 need to be added to your Docker host's configuration: 524 525 1. Install the `ca-certificates` package for your distribution 526 2. Ask your network admin for the proxy's CA certificate and append them to 527 `/etc/pki/tls/certs/ca-bundle.crt` 528 3. Then start your Docker daemon with `HTTPS_PROXY=http://username:password@proxy:port/ docker daemon`. 529 The `username:` and `password@` are optional - and are only needed if your 530 proxy is set up to require authentication. 531 532 This will only add the proxy and authentication to the Docker daemon's requests - 533 your `docker build`s and running containers will need extra configuration to 534 use the proxy 535 536 ## Default Ulimits 537 538 `--default-ulimit` allows you to set the default `ulimit` options to use for 539 all containers. It takes the same options as `--ulimit` for `docker run`. If 540 these defaults are not set, `ulimit` settings will be inherited, if not set on 541 `docker run`, from the Docker daemon. Any `--ulimit` options passed to 542 `docker run` will overwrite these defaults. 543 544 Be careful setting `nproc` with the `ulimit` flag as `nproc` is designed by Linux to 545 set the maximum number of processes available to a user, not to a container. For details 546 please check the [run](run.md) reference. 547 548 ## Nodes discovery 549 550 The `--cluster-advertise` option specifies the 'host:port' or `interface:port` 551 combination that this particular daemon instance should use when advertising 552 itself to the cluster. The daemon is reached by remote hosts through this value. 553 If you specify an interface, make sure it includes the IP address of the actual 554 Docker host. For Engine installation created through `docker-machine`, the 555 interface is typically `eth1`. 556 557 The daemon uses [libkv](https://github.com/docker/libkv/) to advertise 558 the node within the cluster. Some key-value backends support mutual 559 TLS. To configure the client TLS settings used by the daemon can be configured 560 using the `--cluster-store-opt` flag, specifying the paths to PEM encoded 561 files. For example: 562 563 ```bash 564 docker daemon \ 565 --cluster-advertise 192.168.1.2:2376 \ 566 --cluster-store etcd://192.168.1.2:2379 \ 567 --cluster-store-opt kv.cacertfile=/path/to/ca.pem \ 568 --cluster-store-opt kv.certfile=/path/to/cert.pem \ 569 --cluster-store-opt kv.keyfile=/path/to/key.pem 570 ``` 571 572 The currently supported cluster store options are: 573 574 * `kv.cacertfile` 575 576 Specifies the path to a local file with PEM encoded CA certificates to trust 577 578 * `kv.certfile` 579 580 Specifies the path to a local file with a PEM encoded certificate. This 581 certificate is used as the client cert for communication with the 582 Key/Value store. 583 584 * `kv.keyfile` 585 586 Specifies the path to a local file with a PEM encoded private key. This 587 private key is used as the client key for communication with the 588 Key/Value store. 589 590 591 ## Miscellaneous options 592 593 IP masquerading uses address translation to allow containers without a public 594 IP to talk to other machines on the Internet. This may interfere with some 595 network topologies and can be disabled with `--ip-masq=false`. 596 597 Docker supports softlinks for the Docker data directory (`/var/lib/docker`) and 598 for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be 599 set like this: 600 601 DOCKER_TMPDIR=/mnt/disk2/tmp /usr/local/bin/docker daemon -D -g /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1 602 # or 603 export DOCKER_TMPDIR=/mnt/disk2/tmp 604 /usr/local/bin/docker daemon -D -g /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1