github.com/gondor/docker@v1.9.0-rc1/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 to advertise 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 --storage-opt dm.thinpooldev=/dev/mapper/thin-pool 209 210 * `dm.basesize` 211 212 Specifies the size to use when creating the base device, which limits the 213 size of images and containers. The default value is 100G. Note, thin devices 214 are inherently "sparse", so a 100G device which is mostly empty doesn't use 215 100 GB of space on the pool. However, the filesystem will use more space for 216 the empty case the larger the device is. 217 218 This value affects the system-wide "base" empty filesystem 219 that may already be initialized and inherited by pulled images. Typically, 220 a change to this value requires additional steps to take effect: 221 222 $ sudo service docker stop 223 $ sudo rm -rf /var/lib/docker 224 $ sudo service docker start 225 226 Example use: 227 228 $ docker daemon --storage-opt dm.basesize=20G 229 230 * `dm.loopdatasize` 231 232 >**Note**: This option configures devicemapper loopback, which should not be used in production. 233 234 Specifies the size to use when creating the loopback file for the 235 "data" device which is used for the thin pool. The default size is 236 100G. The file is sparse, so it will not initially take up this 237 much space. 238 239 Example use: 240 241 $ docker daemon --storage-opt dm.loopdatasize=200G 242 243 * `dm.loopmetadatasize` 244 245 >**Note**: This option configures devicemapper loopback, which should not be used in production. 246 247 Specifies the size to use when creating the loopback file for the 248 "metadata" device which is used for the thin pool. The default size 249 is 2G. The file is sparse, so it will not initially take up 250 this much space. 251 252 Example use: 253 254 $ docker daemon --storage-opt dm.loopmetadatasize=4G 255 256 * `dm.fs` 257 258 Specifies the filesystem type to use for the base device. The supported 259 options are "ext4" and "xfs". The default is "ext4" 260 261 Example use: 262 263 $ docker daemon --storage-opt dm.fs=xfs 264 265 * `dm.mkfsarg` 266 267 Specifies extra mkfs arguments to be used when creating the base device. 268 269 Example use: 270 271 $ docker daemon --storage-opt "dm.mkfsarg=-O ^has_journal" 272 273 * `dm.mountopt` 274 275 Specifies extra mount options used when mounting the thin devices. 276 277 Example use: 278 279 $ docker daemon --storage-opt dm.mountopt=nodiscard 280 281 * `dm.datadev` 282 283 (Deprecated, use `dm.thinpooldev`) 284 285 Specifies a custom blockdevice to use for data for the thin pool. 286 287 If using a block device for device mapper storage, ideally both datadev and 288 metadatadev should be specified to completely avoid using the loopback 289 device. 290 291 Example use: 292 293 $ docker daemon --storage-opt dm.datadev=/dev/sdb1 --storage-opt dm.metadatadev=/dev/sdc1 294 295 * `dm.metadatadev` 296 297 (Deprecated, use `dm.thinpooldev`) 298 299 Specifies a custom blockdevice to use for metadata for the thin pool. 300 301 For best performance the metadata should be on a different spindle than the 302 data, or even better on an SSD. 303 304 If setting up a new metadata pool it is required to be valid. This can be 305 achieved by zeroing the first 4k to indicate empty metadata, like this: 306 307 $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1 308 309 Example use: 310 311 $ docker daemon --storage-opt dm.datadev=/dev/sdb1 --storage-opt dm.metadatadev=/dev/sdc1 312 313 * `dm.blocksize` 314 315 Specifies a custom blocksize to use for the thin pool. The default 316 blocksize is 64K. 317 318 Example use: 319 320 $ docker daemon --storage-opt dm.blocksize=512K 321 322 * `dm.blkdiscard` 323 324 Enables or disables the use of blkdiscard when removing devicemapper 325 devices. This is enabled by default (only) if using loopback devices and is 326 required to resparsify the loopback file on image/container removal. 327 328 Disabling this on loopback can lead to *much* faster container removal 329 times, but will make the space used in `/var/lib/docker` directory not be 330 returned to the system for other use when containers are removed. 331 332 Example use: 333 334 $ docker daemon --storage-opt dm.blkdiscard=false 335 336 * `dm.override_udev_sync_check` 337 338 Overrides the `udev` synchronization checks between `devicemapper` and `udev`. 339 `udev` is the device manager for the Linux kernel. 340 341 To view the `udev` sync support of a Docker daemon that is using the 342 `devicemapper` driver, run: 343 344 $ docker info 345 [...] 346 Udev Sync Supported: true 347 [...] 348 349 When `udev` sync support is `true`, then `devicemapper` and udev can 350 coordinate the activation and deactivation of devices for containers. 351 352 When `udev` sync support is `false`, a race condition occurs between 353 the`devicemapper` and `udev` during create and cleanup. The race condition 354 results in errors and failures. (For information on these failures, see 355 [docker#4036](https://github.com/docker/docker/issues/4036)) 356 357 To allow the `docker` daemon to start, regardless of `udev` sync not being 358 supported, set `dm.override_udev_sync_check` to true: 359 360 $ docker daemon --storage-opt dm.override_udev_sync_check=true 361 362 When this value is `true`, the `devicemapper` continues and simply warns 363 you the errors are happening. 364 365 > **Note:** 366 > The ideal is to pursue a `docker` daemon and environment that does 367 > support synchronizing with `udev`. For further discussion on this 368 > topic, see [docker#4036](https://github.com/docker/docker/issues/4036). 369 > Otherwise, set this flag for migrating existing Docker daemons to 370 > a daemon with a supported environment. 371 372 * `dm.use_deferred_removal` 373 374 Enables use of deferred device removal if `libdm` and the kernel driver 375 support the mechanism. 376 377 Deferred device removal means that if device is busy when devices are 378 being removed/deactivated, then a deferred removal is scheduled on 379 device. And devices automatically go away when last user of the device 380 exits. 381 382 For example, when a container exits, its associated thin device is removed. 383 If that device has leaked into some other mount namespace and can't be 384 removed, the container exit still succeeds and this option causes the 385 system to schedule the device for deferred removal. It does not wait in a 386 loop trying to remove a busy device. 387 388 Example use: `docker daemon --storage-opt dm.use_deferred_removal=true` 389 390 * `dm.use_deferred_deletion` 391 392 Enables use of deferred device deletion for thin pool devices. By default, 393 thin pool device deletion is synchronous. Before a container is deleted, 394 the Docker daemon removes any associated devices. If the storage driver 395 can not remove a device, the container deletion fails and daemon returns. 396 397 `Error deleting container: Error response from daemon: Cannot destroy container` 398 399 To avoid this failure, enable both deferred device deletion and deferred 400 device removal on the daemon. 401 402 `docker daemon --storage-opt dm.use_deferred_deletion=true --storage-opt dm.use_deferred_removal=true` 403 404 With these two options enabled, if a device is busy when the driver is 405 deleting a container, the driver marks the device as deleted. Later, when 406 the device isn't in use, the driver deletes it. 407 408 In general it should be safe to enable this option by default. It will help 409 when unintentional leaking of mount point happens across multiple mount 410 namespaces. 411 412 Currently supported options of `zfs`: 413 414 * `zfs.fsname` 415 416 Set zfs filesystem under which docker will create its own datasets. 417 By default docker will pick up the zfs filesystem where docker graph 418 (`/var/lib/docker`) is located. 419 420 Example use: 421 422 $ docker daemon -s zfs --storage-opt zfs.fsname=zroot/docker 423 424 ## Docker execdriver option 425 426 The Docker daemon uses a specifically built `libcontainer` execution driver as 427 its interface to the Linux kernel `namespaces`, `cgroups`, and `SELinux`. 428 429 There is still legacy support for the original [LXC userspace tools]( 430 https://linuxcontainers.org/) via the `lxc` execution driver, however, this is 431 not where the primary development of new functionality is taking place. 432 Add `-e lxc` to the daemon flags to use the `lxc` execution driver. 433 434 ## Options for the native execdriver 435 436 You can configure the `native` (libcontainer) execdriver using options specified 437 with the `--exec-opt` flag. All the flag's options have the `native` prefix. A 438 single `native.cgroupdriver` option is available. 439 440 The `native.cgroupdriver` option specifies the management of the container's 441 cgroups. You can specify `cgroupfs` or `systemd`. If you specify `systemd` and 442 it is not available, the system uses `cgroupfs`. By default, if no option is 443 specified, the execdriver first tries `systemd` and falls back to `cgroupfs`. 444 This example sets the execdriver to `cgroupfs`: 445 446 $ sudo docker daemon --exec-opt native.cgroupdriver=cgroupfs 447 448 Setting this option applies to all containers the daemon launches. 449 450 ## Daemon DNS options 451 452 To set the DNS server for all Docker containers, use 453 `docker daemon --dns 8.8.8.8`. 454 455 To set the DNS search domain for all Docker containers, use 456 `docker daemon --dns-search example.com`. 457 458 ## Insecure registries 459 460 Docker considers a private registry either secure or insecure. In the rest of 461 this section, *registry* is used for *private registry*, and `myregistry:5000` 462 is a placeholder example for a private registry. 463 464 A secure registry uses TLS and a copy of its CA certificate is placed on the 465 Docker host at `/etc/docker/certs.d/myregistry:5000/ca.crt`. An insecure 466 registry is either not using TLS (i.e., listening on plain text HTTP), or is 467 using TLS with a CA certificate not known by the Docker daemon. The latter can 468 happen when the certificate was not found under 469 `/etc/docker/certs.d/myregistry:5000/`, or if the certificate verification 470 failed (i.e., wrong CA). 471 472 By default, Docker assumes all, but local (see local registries below), 473 registries are secure. Communicating with an insecure registry is not possible 474 if Docker assumes that registry is secure. In order to communicate with an 475 insecure registry, the Docker daemon requires `--insecure-registry` in one of 476 the following two forms: 477 478 * `--insecure-registry myregistry:5000` tells the Docker daemon that 479 myregistry:5000 should be considered insecure. 480 * `--insecure-registry 10.1.0.0/16` tells the Docker daemon that all registries 481 whose domain resolve to an IP address is part of the subnet described by the 482 CIDR syntax, should be considered insecure. 483 484 The flag can be used multiple times to allow multiple registries to be marked 485 as insecure. 486 487 If an insecure registry is not marked as insecure, `docker pull`, 488 `docker push`, and `docker search` will result in an error message prompting 489 the user to either secure or pass the `--insecure-registry` flag to the Docker 490 daemon as described above. 491 492 Local registries, whose IP address falls in the 127.0.0.0/8 range, are 493 automatically marked as insecure as of Docker 1.3.2. It is not recommended to 494 rely on this, as it may change in the future. 495 496 Enabling `--insecure-registry`, i.e., allowing un-encrypted and/or untrusted 497 communication, can be useful when running a local registry. However, 498 because its use creates security vulnerabilities it should ONLY be enabled for 499 testing purposes. For increased security, users should add their CA to their 500 system's list of trusted CAs instead of enabling `--insecure-registry`. 501 502 ## Legacy Registries 503 504 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. 505 506 ## Running a Docker daemon behind a HTTPS_PROXY 507 508 When running inside a LAN that uses a `HTTPS` proxy, the Docker Hub 509 certificates will be replaced by the proxy's certificates. These certificates 510 need to be added to your Docker host's configuration: 511 512 1. Install the `ca-certificates` package for your distribution 513 2. Ask your network admin for the proxy's CA certificate and append them to 514 `/etc/pki/tls/certs/ca-bundle.crt` 515 3. Then start your Docker daemon with `HTTPS_PROXY=http://username:password@proxy:port/ docker daemon`. 516 The `username:` and `password@` are optional - and are only needed if your 517 proxy is set up to require authentication. 518 519 This will only add the proxy and authentication to the Docker daemon's requests - 520 your `docker build`s and running containers will need extra configuration to 521 use the proxy 522 523 ## Default Ulimits 524 525 `--default-ulimit` allows you to set the default `ulimit` options to use for 526 all containers. It takes the same options as `--ulimit` for `docker run`. If 527 these defaults are not set, `ulimit` settings will be inherited, if not set on 528 `docker run`, from the Docker daemon. Any `--ulimit` options passed to 529 `docker run` will overwrite these defaults. 530 531 Be careful setting `nproc` with the `ulimit` flag as `nproc` is designed by Linux to 532 set the maximum number of processes available to a user, not to a container. For details 533 please check the [run](run.md) reference. 534 535 ## Nodes discovery 536 537 `--cluster-advertise` specifies the 'host:port' combination that this particular 538 daemon instance should use when advertising itself to the cluster. The daemon 539 is reached by remote hosts on this 'host:port' combination. 540 541 The daemon uses [libkv](https://github.com/docker/libkv/) to advertise 542 the node within the cluster. Some Key/Value backends support mutual 543 TLS, and the client TLS settings used by the daemon can be configured 544 using the `--cluster-store-opt` flag, specifying the paths to PEM encoded 545 files. For example: 546 547 ```bash 548 docker daemon \ 549 --cluster-advertise 192.168.1.2:2376 \ 550 --cluster-store etcd://192.168.1.2:2379 \ 551 --cluster-store-opt kv.cacertfile=/path/to/ca.pem \ 552 --cluster-store-opt kv.certfile=/path/to/cert.pem \ 553 --cluster-store-opt kv.keyfile=/path/to/key.pem 554 ``` 555 556 The currently supported cluster store options are: 557 558 * `kv.cacertfile` 559 560 Specifies the path to a local file with PEM encoded CA certificates to trust 561 562 * `kv.certfile` 563 564 Specifies the path to a local file with a PEM encoded certificate. This 565 certificate is used as the client cert for communication with the 566 Key/Value store. 567 568 * `kv.keyfile` 569 570 Specifies the path to a local file with a PEM encoded private key. This 571 private key is used as the client key for communication with the 572 Key/Value store. 573 574 575 ## Miscellaneous options 576 577 IP masquerading uses address translation to allow containers without a public 578 IP to talk to other machines on the Internet. This may interfere with some 579 network topologies and can be disabled with `--ip-masq=false`. 580 581 Docker supports softlinks for the Docker data directory (`/var/lib/docker`) and 582 for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be 583 set like this: 584 585 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 586 # or 587 export DOCKER_TMPDIR=/mnt/disk2/tmp 588 /usr/local/bin/docker daemon -D -g /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1