github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/dockerd.md (about) 1 --- 2 title: "dockerd" 3 aliases: ["/engine/reference/commandline/daemon/"] 4 description: "The daemon command description and usage" 5 keywords: "container, daemon, runtime" 6 --- 7 8 <!-- This file is maintained within the docker/cli GitHub 9 repository at https://github.com/docker/cli/. Make all 10 pull requests against that repo. If you see this file in 11 another repository, consider it read-only there, as it will 12 periodically be overwritten by the definitive file. Pull 13 requests which include edits to this file in other repositories 14 will be rejected. 15 --> 16 17 # daemon 18 19 ```markdown 20 Usage: dockerd COMMAND 21 22 A self-sufficient runtime for containers. 23 24 Options: 25 --add-runtime runtime Register an additional OCI compatible runtime (default []) 26 --allow-nondistributable-artifacts list Push nondistributable artifacts to specified registries (default []) 27 --api-cors-header string Set CORS headers in the Engine API 28 --authorization-plugin list Authorization plugins to load (default []) 29 --bip string Specify network bridge IP 30 -b, --bridge string Attach containers to a network bridge 31 --cgroup-parent string Set parent cgroup for all containers 32 --cluster-advertise string Address or interface name to advertise 33 --cluster-store string URL of the distributed storage backend 34 --cluster-store-opt map Set cluster store options (default map[]) 35 --config-file string Daemon configuration file (default "/etc/docker/daemon.json") 36 --containerd string Path to containerd socket 37 --cpu-rt-period int Limit the CPU real-time period in microseconds 38 --cpu-rt-runtime int Limit the CPU real-time runtime in microseconds 39 --data-root string Root directory of persistent Docker state (default "/var/lib/docker") 40 -D, --debug Enable debug mode 41 --default-gateway ip Container default gateway IPv4 address 42 --default-gateway-v6 ip Container default gateway IPv6 address 43 --default-address-pool Set the default address pool for local node networks 44 --default-runtime string Default OCI runtime for containers (default "runc") 45 --default-ulimit ulimit Default ulimits for containers (default []) 46 --dns list DNS server to use (default []) 47 --dns-opt list DNS options to use (default []) 48 --dns-search list DNS search domains to use (default []) 49 --exec-opt list Runtime execution options (default []) 50 --exec-root string Root directory for execution state files (default "/var/run/docker") 51 --experimental Enable experimental features 52 --fixed-cidr string IPv4 subnet for fixed IPs 53 --fixed-cidr-v6 string IPv6 subnet for fixed IPs 54 -G, --group string Group for the unix socket (default "docker") 55 --help Print usage 56 -H, --host list Daemon socket(s) to connect to (default []) 57 --icc Enable inter-container communication (default true) 58 --init Run an init in the container to forward signals and reap processes 59 --init-path string Path to the docker-init binary 60 --insecure-registry list Enable insecure registry communication (default []) 61 --ip ip Default IP when binding container ports (default 0.0.0.0) 62 --ip-forward Enable net.ipv4.ip_forward (default true) 63 --ip-masq Enable IP masquerading (default true) 64 --iptables Enable addition of iptables rules (default true) 65 --ipv6 Enable IPv6 networking 66 --label list Set key=value labels to the daemon (default []) 67 --live-restore Enable live restore of docker when containers are still running 68 --log-driver string Default driver for container logs (default "json-file") 69 -l, --log-level string Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info") 70 --log-opt map Default log driver options for containers (default map[]) 71 --max-concurrent-downloads int Set the max concurrent downloads for each pull (default 3) 72 --max-concurrent-uploads int Set the max concurrent uploads for each push (default 5) 73 --metrics-addr string Set default address and port to serve the metrics api on 74 --mtu int Set the containers network MTU 75 --node-generic-resources list Advertise user-defined resource 76 --no-new-privileges Set no-new-privileges by default for new containers 77 --oom-score-adjust int Set the oom_score_adj for the daemon (default -500) 78 -p, --pidfile string Path to use for daemon PID file (default "/var/run/docker.pid") 79 --raw-logs Full timestamps without ANSI coloring 80 --registry-mirror list Preferred Docker registry mirror (default []) 81 --seccomp-profile string Path to seccomp profile 82 --selinux-enabled Enable selinux support 83 --shutdown-timeout int Set the default shutdown timeout (default 15) 84 -s, --storage-driver string Storage driver to use 85 --storage-opt list Storage driver options (default []) 86 --swarm-default-advertise-addr string Set default address or interface for swarm advertised address 87 --tls Use TLS; implied by --tlsverify 88 --tlscacert string Trust certs signed only by this CA (default "~/.docker/ca.pem") 89 --tlscert string Path to TLS certificate file (default "~/.docker/cert.pem") 90 --tlskey string Path to TLS key file (default ~/.docker/key.pem") 91 --tlsverify Use TLS and verify the remote 92 --userland-proxy Use userland proxy for loopback traffic (default true) 93 --userland-proxy-path string Path to the userland proxy binary 94 --userns-remap string User/Group setting for user namespaces 95 -v, --version Print version information and quit 96 ``` 97 98 Options with [] may be specified multiple times. 99 100 ## Description 101 102 `dockerd` is the persistent process that manages containers. Docker 103 uses different binaries for the daemon and client. To run the daemon you 104 type `dockerd`. 105 106 To run the daemon with debug output, use `dockerd -D` or add `"debug": true` to 107 the `daemon.json` file. 108 109 > **Note**: In Docker 1.13 and higher, enable experimental features by starting 110 > `dockerd` with the `--experimental` flag or adding `"experimental": true` to the 111 > `daemon.json` file. In earlier Docker versions, a different build was required 112 > to enable experimental features. 113 114 ## Examples 115 116 ### Daemon socket option 117 118 The Docker daemon can listen for [Docker Engine API](../api/) 119 requests via three different types of Socket: `unix`, `tcp`, and `fd`. 120 121 By default, a `unix` domain socket (or IPC socket) is created at 122 `/var/run/docker.sock`, requiring either `root` permission, or `docker` group 123 membership. 124 125 If you need to access the Docker daemon remotely, you need to enable the `tcp` 126 Socket. Beware that the default setup provides un-encrypted and 127 un-authenticated direct access to the Docker daemon - and should be secured 128 either using the [built in HTTPS encrypted socket](https://docs.docker.com/engine/security/https/), or by 129 putting a secure web proxy in front of it. You can listen on port `2375` on all 130 network interfaces with `-H tcp://0.0.0.0:2375`, or on a particular network 131 interface using its IP address: `-H tcp://192.168.59.103:2375`. It is 132 conventional to use port `2375` for un-encrypted, and port `2376` for encrypted 133 communication with the daemon. 134 135 > **Note**: If you're using an HTTPS encrypted socket, keep in mind that only 136 > TLS1.0 and greater are supported. Protocols SSLv3 and under are not 137 > supported anymore for security reasons. 138 139 On Systemd based systems, you can communicate with the daemon via 140 [Systemd socket activation](http://0pointer.de/blog/projects/socket-activation.html), 141 use `dockerd -H fd://`. Using `fd://` will work perfectly for most setups but 142 you can also specify individual sockets: `dockerd -H fd://3`. If the 143 specified socket activated files aren't found, then Docker will exit. You can 144 find examples of using Systemd socket activation with Docker and Systemd in the 145 [Docker source tree](https://github.com/docker/docker/tree/master/contrib/init/systemd/). 146 147 You can configure the Docker daemon to listen to multiple sockets at the same 148 time using multiple `-H` options: 149 150 ```bash 151 # listen using the default unix socket, and on 2 specific IP addresses on this host. 152 153 $ sudo dockerd -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2 154 ``` 155 156 The Docker client will honor the `DOCKER_HOST` environment variable to set the 157 `-H` flag for the client. Use **one** of the following commands: 158 159 ```bash 160 $ docker -H tcp://0.0.0.0:2375 ps 161 ``` 162 163 ```bash 164 $ export DOCKER_HOST="tcp://0.0.0.0:2375" 165 166 $ docker ps 167 ``` 168 169 Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than 170 the empty string is equivalent to setting the `--tlsverify` flag. The following 171 are equivalent: 172 173 ```bash 174 $ docker --tlsverify ps 175 # or 176 $ export DOCKER_TLS_VERIFY=1 177 $ docker ps 178 ``` 179 180 The Docker client will honor the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` 181 environment variables (or the lowercase versions thereof). `HTTPS_PROXY` takes 182 precedence over `HTTP_PROXY`. 183 184 Starting with Docker 18.09, the Docker client supports connecting to a remote 185 daemon via SSH: 186 187 ``` 188 $ docker -H ssh://me@example.com:22 ps 189 $ docker -H ssh://me@example.com ps 190 $ docker -H ssh://example.com ps 191 ``` 192 193 To use SSH connection, you need to set up `ssh` so that it can reach the 194 remote host with public key authentication. 195 Also, you need to have `docker` binary 18.09 or later on the daemon host. 196 197 #### Bind Docker to another host/port or a Unix socket 198 199 > **Warning**: 200 > Changing the default `docker` daemon binding to a 201 > TCP port or Unix *docker* user group will increase your security risks 202 > by allowing non-root users to gain *root* access on the host. Make sure 203 > you control access to `docker`. If you are binding 204 > to a TCP port, anyone with access to that port has full Docker access; 205 > so it is not advisable on an open network. 206 207 With `-H` it is possible to make the Docker daemon to listen on a 208 specific IP and port. By default, it will listen on 209 `unix:///var/run/docker.sock` to allow only local connections by the 210 *root* user. You *could* set it to `0.0.0.0:2375` or a specific host IP 211 to give access to everybody, but that is **not recommended** because 212 then it is trivial for someone to gain root access to the host where the 213 daemon is running. 214 215 Similarly, the Docker client can use `-H` to connect to a custom port. 216 The Docker client will default to connecting to `unix:///var/run/docker.sock` 217 on Linux, and `tcp://127.0.0.1:2376` on Windows. 218 219 `-H` accepts host and port assignment in the following format: 220 221 tcp://[host]:[port][path] or unix://path 222 223 For example: 224 225 - `tcp://` -> TCP connection to `127.0.0.1` on either port `2376` when TLS encryption 226 is on, or port `2375` when communication is in plain text. 227 - `tcp://host:2375` -> TCP connection on 228 host:2375 229 - `tcp://host:2375/path` -> TCP connection on 230 host:2375 and prepend path to all requests 231 - `unix://path/to/socket` -> Unix socket located 232 at `path/to/socket` 233 234 `-H`, when empty, will default to the same value as 235 when no `-H` was passed in. 236 237 `-H` also accepts short form for TCP bindings: `host:` or `host:port` or `:port` 238 239 Run Docker in daemon mode: 240 241 ```bash 242 $ sudo <path to>/dockerd -H 0.0.0.0:5555 & 243 ``` 244 245 Download an `ubuntu` image: 246 247 ```bash 248 $ docker -H :5555 pull ubuntu 249 ``` 250 251 You can use multiple `-H`, for example, if you want to listen on both 252 TCP and a Unix socket 253 254 ```bash 255 # Run docker in daemon mode 256 $ sudo <path to>/dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock & 257 # Download an ubuntu image, use default Unix socket 258 $ docker pull ubuntu 259 # OR use the TCP port 260 $ docker -H tcp://127.0.0.1:2375 pull ubuntu 261 ``` 262 263 ### Daemon storage-driver 264 265 On Linux, the Docker daemon has support for several different image layer storage 266 drivers: `aufs`, `devicemapper`, `btrfs`, `zfs`, `overlay` and `overlay2`. 267 268 The `aufs` driver is the oldest, but is based on a Linux kernel patch-set that 269 is unlikely to be merged into the main kernel. These are also known to cause 270 some serious kernel crashes. However `aufs` allows containers to share 271 executable and shared library memory, so is a useful choice when running 272 thousands of containers with the same program or libraries. 273 274 The `devicemapper` driver uses thin provisioning and Copy on Write (CoW) 275 snapshots. For each devicemapper graph location – typically 276 `/var/lib/docker/devicemapper` – a thin pool is created based on two block 277 devices, one for data and one for metadata. By default, these block devices 278 are created automatically by using loopback mounts of automatically created 279 sparse files. Refer to [Devicemapper options](#devicemapper-options) below 280 for a way how to customize this setup. 281 [~jpetazzo/Resizing Docker containers with the Device Mapper plugin](http://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/) 282 article explains how to tune your existing setup without the use of options. 283 284 The `btrfs` driver is very fast for `docker build` - but like `devicemapper` 285 does not share executable memory between devices. Use 286 `dockerd -s btrfs -g /mnt/btrfs_partition`. 287 288 The `zfs` driver is probably not as fast as `btrfs` but has a longer track record 289 on stability. Thanks to `Single Copy ARC` shared blocks between clones will be 290 cached only once. Use `dockerd -s zfs`. To select a different zfs filesystem 291 set `zfs.fsname` option as described in [ZFS options](#zfs-options). 292 293 The `overlay` is a very fast union filesystem. It is now merged in the main 294 Linux kernel as of [3.18.0](https://lkml.org/lkml/2014/10/26/137). `overlay` 295 also supports page cache sharing, this means multiple containers accessing 296 the same file can share a single page cache entry (or entries), it makes 297 `overlay` as efficient with memory as `aufs` driver. Call 298 `dockerd -s overlay` to use it. 299 300 > **Note**: As promising as `overlay` is, the feature is still quite young and 301 > should not be used in production. Most notably, using `overlay` can cause 302 > excessive inode consumption (especially as the number of images grows), as 303 > well as > being incompatible with the use of RPMs. 304 305 The `overlay2` uses the same fast union filesystem but takes advantage of 306 [additional features](https://lkml.org/lkml/2015/2/11/106) added in Linux 307 kernel 4.0 to avoid excessive inode consumption. Call `dockerd -s overlay2` 308 to use it. 309 310 > **Note**: Both `overlay` and `overlay2` are currently unsupported on `btrfs` 311 > or any Copy on Write filesystem and should only be used over `ext4` partitions. 312 313 On Windows, the Docker daemon supports a single image layer storage driver 314 depending on the image platform: `windowsfilter` for Windows images, and 315 `lcow` for Linux containers on Windows. 316 317 ### Options per storage driver 318 319 Particular storage-driver can be configured with options specified with 320 `--storage-opt` flags. Options for `devicemapper` are prefixed with `dm`, 321 options for `zfs` start with `zfs`, options for `btrfs` start with `btrfs` 322 and options for `lcow` start with `lcow`. 323 324 #### Devicemapper options 325 326 This is an example of the configuration file for devicemapper on Linux: 327 328 ```json 329 { 330 "storage-driver": "devicemapper", 331 "storage-opts": [ 332 "dm.thinpooldev=/dev/mapper/thin-pool", 333 "dm.use_deferred_deletion=true", 334 "dm.use_deferred_removal=true" 335 ] 336 } 337 ``` 338 339 ##### `dm.thinpooldev` 340 341 Specifies a custom block storage device to use for the thin pool. 342 343 If using a block device for device mapper storage, it is best to use `lvm` 344 to create and manage the thin-pool volume. This volume is then handed to Docker 345 to exclusively create snapshot volumes needed for images and containers. 346 347 Managing the thin-pool outside of Engine makes for the most feature-rich 348 method of having Docker utilize device mapper thin provisioning as the 349 backing storage for Docker containers. The highlights of the lvm-based 350 thin-pool management feature include: automatic or interactive thin-pool 351 resize support, dynamically changing thin-pool features, automatic thinp 352 metadata checking when lvm activates the thin-pool, etc. 353 354 As a fallback if no thin pool is provided, loopback files are 355 created. Loopback is very slow, but can be used without any 356 pre-configuration of storage. It is strongly recommended that you do 357 not use loopback in production. Ensure your Engine daemon has a 358 `--storage-opt dm.thinpooldev` argument provided. 359 360 ###### Example: 361 362 ```bash 363 $ sudo dockerd --storage-opt dm.thinpooldev=/dev/mapper/thin-pool 364 ``` 365 366 ##### `dm.directlvm_device` 367 368 As an alternative to providing a thin pool as above, Docker can setup a block 369 device for you. 370 371 ###### Example: 372 373 ```bash 374 $ sudo dockerd --storage-opt dm.directlvm_device=/dev/xvdf 375 ``` 376 377 ##### `dm.thinp_percent` 378 379 Sets the percentage of passed in block device to use for storage. 380 381 ###### Example: 382 383 ```bash 384 $ sudo dockerd --storage-opt dm.thinp_percent=95 385 ``` 386 387 ##### `dm.thinp_metapercent` 388 389 Sets the percentage of the passed in block device to use for metadata storage. 390 391 ###### Example: 392 393 ```bash 394 $ sudo dockerd --storage-opt dm.thinp_metapercent=1 395 ``` 396 397 ##### `dm.thinp_autoextend_threshold` 398 399 Sets the value of the percentage of space used before `lvm` attempts to 400 autoextend the available space [100 = disabled] 401 402 ###### Example: 403 404 ```bash 405 $ sudo dockerd --storage-opt dm.thinp_autoextend_threshold=80 406 ``` 407 408 ##### `dm.thinp_autoextend_percent` 409 410 Sets the value percentage value to increase the thin pool by when `lvm` 411 attempts to autoextend the available space [100 = disabled] 412 413 ###### Example: 414 415 ```bash 416 $ sudo dockerd --storage-opt dm.thinp_autoextend_percent=20 417 ``` 418 419 420 ##### `dm.basesize` 421 422 Specifies the size to use when creating the base device, which limits the 423 size of images and containers. The default value is 10G. Note, thin devices 424 are inherently "sparse", so a 10G device which is mostly empty doesn't use 425 10 GB of space on the pool. However, the filesystem will use more space for 426 the empty case the larger the device is. 427 428 The base device size can be increased at daemon restart which will allow 429 all future images and containers (based on those new images) to be of the 430 new base device size. 431 432 ###### Examples 433 434 ```bash 435 $ sudo dockerd --storage-opt dm.basesize=50G 436 ``` 437 438 This will increase the base device size to 50G. The Docker daemon will throw an 439 error if existing base device size is larger than 50G. A user can use 440 this option to expand the base device size however shrinking is not permitted. 441 442 This value affects the system-wide "base" empty filesystem 443 that may already be initialized and inherited by pulled images. Typically, 444 a change to this value requires additional steps to take effect: 445 446 ```bash 447 $ sudo service docker stop 448 449 $ sudo rm -rf /var/lib/docker 450 451 $ sudo service docker start 452 ``` 453 454 455 ##### `dm.loopdatasize` 456 457 > **Note**: This option configures devicemapper loopback, which should not 458 > be used in production. 459 460 Specifies the size to use when creating the loopback file for the 461 "data" device which is used for the thin pool. The default size is 462 100G. The file is sparse, so it will not initially take up this 463 much space. 464 465 ###### Example 466 467 ```bash 468 $ sudo dockerd --storage-opt dm.loopdatasize=200G 469 ``` 470 471 ##### `dm.loopmetadatasize` 472 473 > **Note**: This option configures devicemapper loopback, which should not 474 > be used in production. 475 476 Specifies the size to use when creating the loopback file for the 477 "metadata" device which is used for the thin pool. The default size 478 is 2G. The file is sparse, so it will not initially take up 479 this much space. 480 481 ###### Example 482 483 ```bash 484 $ sudo dockerd --storage-opt dm.loopmetadatasize=4G 485 ``` 486 487 ##### `dm.fs` 488 489 Specifies the filesystem type to use for the base device. The supported 490 options are "ext4" and "xfs". The default is "xfs" 491 492 ###### Example 493 494 ```bash 495 $ sudo dockerd --storage-opt dm.fs=ext4 496 ``` 497 498 ##### `dm.mkfsarg` 499 500 Specifies extra mkfs arguments to be used when creating the base device. 501 502 ###### Example 503 504 ```bash 505 $ sudo dockerd --storage-opt "dm.mkfsarg=-O ^has_journal" 506 ``` 507 508 ##### `dm.mountopt` 509 510 Specifies extra mount options used when mounting the thin devices. 511 512 ###### Example 513 514 ```bash 515 $ sudo dockerd --storage-opt dm.mountopt=nodiscard 516 ``` 517 518 ##### `dm.datadev` 519 520 (Deprecated, use `dm.thinpooldev`) 521 522 Specifies a custom blockdevice to use for data for the thin pool. 523 524 If using a block device for device mapper storage, ideally both `datadev` and 525 `metadatadev` should be specified to completely avoid using the loopback 526 device. 527 528 ###### Example 529 530 ```bash 531 $ sudo dockerd \ 532 --storage-opt dm.datadev=/dev/sdb1 \ 533 --storage-opt dm.metadatadev=/dev/sdc1 534 ``` 535 536 ##### `dm.metadatadev` 537 538 (Deprecated, use `dm.thinpooldev`) 539 540 Specifies a custom blockdevice to use for metadata for the thin pool. 541 542 For best performance the metadata should be on a different spindle than the 543 data, or even better on an SSD. 544 545 If setting up a new metadata pool it is required to be valid. This can be 546 achieved by zeroing the first 4k to indicate empty metadata, like this: 547 548 ```bash 549 $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1 550 ``` 551 552 ###### Example 553 554 ```bash 555 $ sudo dockerd \ 556 --storage-opt dm.datadev=/dev/sdb1 \ 557 --storage-opt dm.metadatadev=/dev/sdc1 558 ``` 559 560 ##### `dm.blocksize` 561 562 Specifies a custom blocksize to use for the thin pool. The default 563 blocksize is 64K. 564 565 ###### Example 566 567 ```bash 568 $ sudo dockerd --storage-opt dm.blocksize=512K 569 ``` 570 571 ##### `dm.blkdiscard` 572 573 Enables or disables the use of `blkdiscard` when removing devicemapper 574 devices. This is enabled by default (only) if using loopback devices and is 575 required to resparsify the loopback file on image/container removal. 576 577 Disabling this on loopback can lead to *much* faster container removal 578 times, but will make the space used in `/var/lib/docker` directory not be 579 returned to the system for other use when containers are removed. 580 581 ###### Examples 582 583 ```bash 584 $ sudo dockerd --storage-opt dm.blkdiscard=false 585 ``` 586 587 ##### `dm.override_udev_sync_check` 588 589 Overrides the `udev` synchronization checks between `devicemapper` and `udev`. 590 `udev` is the device manager for the Linux kernel. 591 592 To view the `udev` sync support of a Docker daemon that is using the 593 `devicemapper` driver, run: 594 595 ```bash 596 $ docker info 597 [...] 598 Udev Sync Supported: true 599 [...] 600 ``` 601 602 When `udev` sync support is `true`, then `devicemapper` and udev can 603 coordinate the activation and deactivation of devices for containers. 604 605 When `udev` sync support is `false`, a race condition occurs between 606 the`devicemapper` and `udev` during create and cleanup. The race condition 607 results in errors and failures. (For information on these failures, see 608 [docker#4036](https://github.com/docker/docker/issues/4036)) 609 610 To allow the `docker` daemon to start, regardless of `udev` sync not being 611 supported, set `dm.override_udev_sync_check` to true: 612 613 ```bash 614 $ sudo dockerd --storage-opt dm.override_udev_sync_check=true 615 ``` 616 617 When this value is `true`, the `devicemapper` continues and simply warns 618 you the errors are happening. 619 620 > **Note**: The ideal is to pursue a `docker` daemon and environment that does 621 > support synchronizing with `udev`. For further discussion on this 622 > topic, see [docker#4036](https://github.com/docker/docker/issues/4036). 623 > Otherwise, set this flag for migrating existing Docker daemons to 624 > a daemon with a supported environment. 625 626 ##### `dm.use_deferred_removal` 627 628 Enables use of deferred device removal if `libdm` and the kernel driver 629 support the mechanism. 630 631 Deferred device removal means that if device is busy when devices are 632 being removed/deactivated, then a deferred removal is scheduled on 633 device. And devices automatically go away when last user of the device 634 exits. 635 636 For example, when a container exits, its associated thin device is removed. 637 If that device has leaked into some other mount namespace and can't be 638 removed, the container exit still succeeds and this option causes the 639 system to schedule the device for deferred removal. It does not wait in a 640 loop trying to remove a busy device. 641 642 ###### Example 643 644 ```bash 645 $ sudo dockerd --storage-opt dm.use_deferred_removal=true 646 ``` 647 648 ##### `dm.use_deferred_deletion` 649 650 Enables use of deferred device deletion for thin pool devices. By default, 651 thin pool device deletion is synchronous. Before a container is deleted, 652 the Docker daemon removes any associated devices. If the storage driver 653 can not remove a device, the container deletion fails and daemon returns. 654 655 ```none 656 Error deleting container: Error response from daemon: Cannot destroy container 657 ``` 658 659 To avoid this failure, enable both deferred device deletion and deferred 660 device removal on the daemon. 661 662 ```bash 663 $ sudo dockerd \ 664 --storage-opt dm.use_deferred_deletion=true \ 665 --storage-opt dm.use_deferred_removal=true 666 ``` 667 668 With these two options enabled, if a device is busy when the driver is 669 deleting a container, the driver marks the device as deleted. Later, when 670 the device isn't in use, the driver deletes it. 671 672 In general it should be safe to enable this option by default. It will help 673 when unintentional leaking of mount point happens across multiple mount 674 namespaces. 675 676 ##### `dm.min_free_space` 677 678 Specifies the min free space percent in a thin pool require for new device 679 creation to succeed. This check applies to both free data space as well 680 as free metadata space. Valid values are from 0% - 99%. Value 0% disables 681 free space checking logic. If user does not specify a value for this option, 682 the Engine uses a default value of 10%. 683 684 Whenever a new a thin pool device is created (during `docker pull` or during 685 container creation), the Engine checks if the minimum free space is 686 available. If sufficient space is unavailable, then device creation fails 687 and any relevant `docker` operation fails. 688 689 To recover from this error, you must create more free space in the thin pool 690 to recover from the error. You can create free space by deleting some images 691 and containers from the thin pool. You can also add more storage to the thin 692 pool. 693 694 To add more space to a LVM (logical volume management) thin pool, just add 695 more storage to the volume group container thin pool; this should automatically 696 resolve any errors. If your configuration uses loop devices, then stop the 697 Engine daemon, grow the size of loop files and restart the daemon to resolve 698 the issue. 699 700 ###### Example 701 702 ```bash 703 $ sudo dockerd --storage-opt dm.min_free_space=10% 704 ``` 705 706 ##### `dm.xfs_nospace_max_retries` 707 708 Specifies the maximum number of retries XFS should attempt to complete 709 IO when ENOSPC (no space) error is returned by underlying storage device. 710 711 By default XFS retries infinitely for IO to finish and this can result 712 in unkillable process. To change this behavior one can set 713 xfs_nospace_max_retries to say 0 and XFS will not retry IO after getting 714 ENOSPC and will shutdown filesystem. 715 716 ###### Example 717 718 ```bash 719 $ sudo dockerd --storage-opt dm.xfs_nospace_max_retries=0 720 ``` 721 722 ##### `dm.libdm_log_level` 723 724 Specifies the maxmimum `libdm` log level that will be forwarded to the 725 `dockerd` log (as specified by `--log-level`). This option is primarily 726 intended for debugging problems involving `libdm`. Using values other than the 727 defaults may cause false-positive warnings to be logged. 728 729 Values specified must fall within the range of valid `libdm` log levels. At the 730 time of writing, the following is the list of `libdm` log levels as well as 731 their corresponding levels when output by `dockerd`. 732 733 | `libdm` Level | Value | `--log-level` | 734 | ------------- | -----:| ------------- | 735 | `_LOG_FATAL` | 2 | error | 736 | `_LOG_ERR` | 3 | error | 737 | `_LOG_WARN` | 4 | warn | 738 | `_LOG_NOTICE` | 5 | info | 739 | `_LOG_INFO` | 6 | info | 740 | `_LOG_DEBUG` | 7 | debug | 741 742 ###### Example 743 744 ```bash 745 $ sudo dockerd \ 746 --log-level debug \ 747 --storage-opt dm.libdm_log_level=7 748 ``` 749 750 #### ZFS options 751 752 ##### `zfs.fsname` 753 754 Set zfs filesystem under which docker will create its own datasets. 755 By default docker will pick up the zfs filesystem where docker graph 756 (`/var/lib/docker`) is located. 757 758 ###### Example 759 760 ```bash 761 $ sudo dockerd -s zfs --storage-opt zfs.fsname=zroot/docker 762 ``` 763 764 #### Btrfs options 765 766 ##### `btrfs.min_space` 767 768 Specifies the minimum size to use when creating the subvolume which is used 769 for containers. If user uses disk quota for btrfs when creating or running 770 a container with **--storage-opt size** option, docker should ensure the 771 **size** cannot be smaller than **btrfs.min_space**. 772 773 ###### Example 774 775 ```bash 776 $ sudo dockerd -s btrfs --storage-opt btrfs.min_space=10G 777 ``` 778 779 #### Overlay2 options 780 781 ##### `overlay2.override_kernel_check` 782 783 Overrides the Linux kernel version check allowing overlay2. Support for 784 specifying multiple lower directories needed by overlay2 was added to the 785 Linux kernel in 4.0.0. However, some older kernel versions may be patched 786 to add multiple lower directory support for OverlayFS. This option should 787 only be used after verifying this support exists in the kernel. Applying 788 this option on a kernel without this support will cause failures on mount. 789 790 ##### `overlay2.size` 791 792 Sets the default max size of the container. It is supported only when the 793 backing fs is `xfs` and mounted with `pquota` mount option. Under these 794 conditions the user can pass any size less then the backing fs size. 795 796 ###### Example 797 798 ```bash 799 $ sudo dockerd -s overlay2 --storage-opt overlay2.size=1G 800 ``` 801 802 803 #### Windowsfilter options 804 805 ##### `size` 806 807 Specifies the size to use when creating the sandbox which is used for containers. 808 Defaults to 20G. 809 810 ###### Example 811 812 ```PowerShell 813 C:\> dockerd --storage-opt size=40G 814 ``` 815 816 #### LCOW (Linux Containers on Windows) options 817 818 ##### `lcow.globalmode` 819 820 Specifies whether the daemon instantiates utility VM instances as required 821 (recommended and default if omitted), or uses single global utility VM (better 822 performance, but has security implications and not recommended for production 823 deployments). 824 825 ###### Example 826 827 ```PowerShell 828 C:\> dockerd --storage-opt lcow.globalmode=false 829 ``` 830 831 ##### `lcow.kirdpath` 832 833 Specifies the folder path to the location of a pair of kernel and initrd files 834 used for booting a utility VM. Defaults to `%ProgramFiles%\Linux Containers`. 835 836 ###### Example 837 838 ```PowerShell 839 C:\> dockerd --storage-opt lcow.kirdpath=c:\path\to\files 840 ``` 841 842 ##### `lcow.kernel` 843 844 Specifies the filename of a kernel file located in the `lcow.kirdpath` path. 845 Defaults to `bootx64.efi`. 846 847 ###### Example 848 849 ```PowerShell 850 C:\> dockerd --storage-opt lcow.kernel=kernel.efi 851 ``` 852 853 ##### `lcow.initrd` 854 855 Specifies the filename of an initrd file located in the `lcow.kirdpath` path. 856 Defaults to `initrd.img`. 857 858 ###### Example 859 860 ```PowerShell 861 C:\> dockerd --storage-opt lcow.initrd=myinitrd.img 862 ``` 863 864 ##### `lcow.bootparameters` 865 866 Specifies additional boot parameters for booting utility VMs when in kernel/ 867 initrd mode. Ignored if the utility VM is booting from VHD. These settings 868 are kernel specific. 869 870 ###### Example 871 872 ```PowerShell 873 C:\> dockerd --storage-opt "lcow.bootparameters='option=value'" 874 ``` 875 876 ##### `lcow.vhdx` 877 878 Specifies a custom VHDX to boot a utility VM, as an alternate to kernel 879 and initrd booting. Defaults to `uvm.vhdx` under `lcow.kirdpath`. 880 881 ###### Example 882 883 ```PowerShell 884 C:\> dockerd --storage-opt lcow.vhdx=custom.vhdx 885 ``` 886 887 ##### `lcow.timeout` 888 889 Specifies the timeout for utility VM operations in seconds. Defaults 890 to 300. 891 892 ###### Example 893 894 ```PowerShell 895 C:\> dockerd --storage-opt lcow.timeout=240 896 ``` 897 898 ##### `lcow.sandboxsize` 899 900 Specifies the size in GB to use when creating the sandbox which is used for 901 containers. Defaults to 20. Cannot be less than 20. 902 903 ###### Example 904 905 ```PowerShell 906 C:\> dockerd --storage-opt lcow.sandboxsize=40 907 ``` 908 909 ### Docker runtime execution options 910 911 The Docker daemon relies on a 912 [OCI](https://github.com/opencontainers/runtime-spec) compliant runtime 913 (invoked via the `containerd` daemon) as its interface to the Linux 914 kernel `namespaces`, `cgroups`, and `SELinux`. 915 916 By default, the Docker daemon automatically starts `containerd`. If you want to 917 control `containerd` startup, manually start `containerd` and pass the path to 918 the `containerd` socket using the `--containerd` flag. For example: 919 920 ```bash 921 $ sudo dockerd --containerd /var/run/dev/docker-containerd.sock 922 ``` 923 924 Runtimes can be registered with the daemon either via the 925 configuration file or using the `--add-runtime` command line argument. 926 927 The following is an example adding 2 runtimes via the configuration: 928 929 ```json 930 { 931 "default-runtime": "runc", 932 "runtimes": { 933 "runc": { 934 "path": "runc" 935 }, 936 "custom": { 937 "path": "/usr/local/bin/my-runc-replacement", 938 "runtimeArgs": [ 939 "--debug" 940 ] 941 } 942 } 943 } 944 ``` 945 946 This is the same example via the command line: 947 948 ```bash 949 $ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-runc-replacement 950 ``` 951 952 > **Note**: Defining runtime arguments via the command line is not supported. 953 954 #### Options for the runtime 955 956 You can configure the runtime using options specified 957 with the `--exec-opt` flag. All the flag's options have the `native` prefix. A 958 single `native.cgroupdriver` option is available. 959 960 The `native.cgroupdriver` option specifies the management of the container's 961 cgroups. You can only specify `cgroupfs` or `systemd`. If you specify 962 `systemd` and it is not available, the system errors out. If you omit the 963 `native.cgroupdriver` option,` cgroupfs` is used. 964 965 This example sets the `cgroupdriver` to `systemd`: 966 967 ```bash 968 $ sudo dockerd --exec-opt native.cgroupdriver=systemd 969 ``` 970 971 Setting this option applies to all containers the daemon launches. 972 973 Also Windows Container makes use of `--exec-opt` for special purpose. Docker user 974 can specify default container isolation technology with this, for example: 975 976 ```console 977 > dockerd --exec-opt isolation=hyperv 978 ``` 979 980 Will make `hyperv` the default isolation technology on Windows. If no isolation 981 value is specified on daemon start, on Windows client, the default is 982 `hyperv`, and on Windows server, the default is `process`. 983 984 ### Daemon DNS options 985 986 To set the DNS server for all Docker containers, use: 987 988 ```bash 989 $ sudo dockerd --dns 8.8.8.8 990 ``` 991 992 To set the DNS search domain for all Docker containers, use: 993 994 ```bash 995 $ sudo dockerd --dns-search example.com 996 ``` 997 998 ### Allow push of nondistributable artifacts 999 1000 Some images (e.g., Windows base images) contain artifacts whose distribution is 1001 restricted by license. When these images are pushed to a registry, restricted 1002 artifacts are not included. 1003 1004 To override this behavior for specific registries, use the 1005 `--allow-nondistributable-artifacts` option in one of the following forms: 1006 1007 * `--allow-nondistributable-artifacts myregistry:5000` tells the Docker daemon 1008 to push nondistributable artifacts to myregistry:5000. 1009 * `--allow-nondistributable-artifacts 10.1.0.0/16` tells the Docker daemon to 1010 push nondistributable artifacts to all registries whose resolved IP address 1011 is within the subnet described by the CIDR syntax. 1012 1013 This option can be used multiple times. 1014 1015 This option is useful when pushing images containing nondistributable artifacts 1016 to a registry on an air-gapped network so hosts on that network can pull the 1017 images without connecting to another server. 1018 1019 > **Warning**: Nondistributable artifacts typically have restrictions on how 1020 > and where they can be distributed and shared. Only use this feature to push 1021 > artifacts to private registries and ensure that you are in compliance with 1022 > any terms that cover redistributing nondistributable artifacts. 1023 1024 ### Insecure registries 1025 1026 Docker considers a private registry either secure or insecure. In the rest of 1027 this section, *registry* is used for *private registry*, and `myregistry:5000` 1028 is a placeholder example for a private registry. 1029 1030 A secure registry uses TLS and a copy of its CA certificate is placed on the 1031 Docker host at `/etc/docker/certs.d/myregistry:5000/ca.crt`. An insecure 1032 registry is either not using TLS (i.e., listening on plain text HTTP), or is 1033 using TLS with a CA certificate not known by the Docker daemon. The latter can 1034 happen when the certificate was not found under 1035 `/etc/docker/certs.d/myregistry:5000/`, or if the certificate verification 1036 failed (i.e., wrong CA). 1037 1038 By default, Docker assumes all, but local (see local registries below), 1039 registries are secure. Communicating with an insecure registry is not possible 1040 if Docker assumes that registry is secure. In order to communicate with an 1041 insecure registry, the Docker daemon requires `--insecure-registry` in one of 1042 the following two forms: 1043 1044 * `--insecure-registry myregistry:5000` tells the Docker daemon that 1045 myregistry:5000 should be considered insecure. 1046 * `--insecure-registry 10.1.0.0/16` tells the Docker daemon that all registries 1047 whose domain resolve to an IP address is part of the subnet described by the 1048 CIDR syntax, should be considered insecure. 1049 1050 The flag can be used multiple times to allow multiple registries to be marked 1051 as insecure. 1052 1053 If an insecure registry is not marked as insecure, `docker pull`, 1054 `docker push`, and `docker search` will result in an error message prompting 1055 the user to either secure or pass the `--insecure-registry` flag to the Docker 1056 daemon as described above. 1057 1058 Local registries, whose IP address falls in the 127.0.0.0/8 range, are 1059 automatically marked as insecure as of Docker 1.3.2. It is not recommended to 1060 rely on this, as it may change in the future. 1061 1062 Enabling `--insecure-registry`, i.e., allowing un-encrypted and/or untrusted 1063 communication, can be useful when running a local registry. However, 1064 because its use creates security vulnerabilities it should ONLY be enabled for 1065 testing purposes. For increased security, users should add their CA to their 1066 system's list of trusted CAs instead of enabling `--insecure-registry`. 1067 1068 #### Legacy Registries 1069 1070 Starting with Docker 17.12, operations against registries supporting only the 1071 legacy v1 protocol are no longer supported. Specifically, the daemon will not 1072 attempt `push`, `pull` and `login` to v1 registries. The exception to this is 1073 `search` which can still be performed on v1 registries. 1074 1075 The `disable-legacy-registry` configuration option has been removed and, when 1076 used, will produce an error on daemon startup. 1077 1078 1079 ### Running a Docker daemon behind an HTTPS_PROXY 1080 1081 When running inside a LAN that uses an `HTTPS` proxy, the Docker Hub 1082 certificates will be replaced by the proxy's certificates. These certificates 1083 need to be added to your Docker host's configuration: 1084 1085 1. Install the `ca-certificates` package for your distribution 1086 2. Ask your network admin for the proxy's CA certificate and append them to 1087 `/etc/pki/tls/certs/ca-bundle.crt` 1088 3. Then start your Docker daemon with `HTTPS_PROXY=http://username:password@proxy:port/ dockerd`. 1089 The `username:` and `password@` are optional - and are only needed if your 1090 proxy is set up to require authentication. 1091 1092 This will only add the proxy and authentication to the Docker daemon's requests - 1093 your `docker build`s and running containers will need extra configuration to 1094 use the proxy 1095 1096 ### Default `ulimit` settings 1097 1098 `--default-ulimit` allows you to set the default `ulimit` options to use for 1099 all containers. It takes the same options as `--ulimit` for `docker run`. If 1100 these defaults are not set, `ulimit` settings will be inherited, if not set on 1101 `docker run`, from the Docker daemon. Any `--ulimit` options passed to 1102 `docker run` will overwrite these defaults. 1103 1104 Be careful setting `nproc` with the `ulimit` flag as `nproc` is designed by Linux to 1105 set the maximum number of processes available to a user, not to a container. For details 1106 please check the [run](run.md) reference. 1107 1108 ### Node discovery 1109 1110 The `--cluster-advertise` option specifies the `host:port` or `interface:port` 1111 combination that this particular daemon instance should use when advertising 1112 itself to the cluster. The daemon is reached by remote hosts through this value. 1113 If you specify an interface, make sure it includes the IP address of the actual 1114 Docker host. For Engine installation created through `docker-machine`, the 1115 interface is typically `eth1`. 1116 1117 The daemon uses [libkv](https://github.com/docker/libkv/) to advertise 1118 the node within the cluster. Some key-value backends support mutual 1119 TLS. To configure the client TLS settings used by the daemon can be configured 1120 using the `--cluster-store-opt` flag, specifying the paths to PEM encoded 1121 files. For example: 1122 1123 ```bash 1124 $ sudo dockerd \ 1125 --cluster-advertise 192.168.1.2:2376 \ 1126 --cluster-store etcd://192.168.1.2:2379 \ 1127 --cluster-store-opt kv.cacertfile=/path/to/ca.pem \ 1128 --cluster-store-opt kv.certfile=/path/to/cert.pem \ 1129 --cluster-store-opt kv.keyfile=/path/to/key.pem 1130 ``` 1131 1132 The currently supported cluster store options are: 1133 1134 | Option | Description | 1135 |:----------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| 1136 | `discovery.heartbeat` | Specifies the heartbeat timer in seconds which is used by the daemon as a `keepalive` mechanism to make sure discovery module treats the node as alive in the cluster. If not configured, the default value is 20 seconds. | 1137 | `discovery.ttl` | Specifies the TTL (time-to-live) in seconds which is used by the discovery module to timeout a node if a valid heartbeat is not received within the configured ttl value. If not configured, the default value is 60 seconds. | 1138 | `kv.cacertfile` | Specifies the path to a local file with PEM encoded CA certificates to trust. | 1139 | `kv.certfile` | Specifies the path to a local file with a PEM encoded certificate. This certificate is used as the client cert for communication with the Key/Value store. | 1140 | `kv.keyfile` | Specifies the path to a local file with a PEM encoded private key. This private key is used as the client key for communication with the Key/Value store. | 1141 | `kv.path` | Specifies the path in the Key/Value store. If not configured, the default value is 'docker/nodes'. | 1142 1143 ### Access authorization 1144 1145 Docker's access authorization can be extended by authorization plugins that your 1146 organization can purchase or build themselves. You can install one or more 1147 authorization plugins when you start the Docker `daemon` using the 1148 `--authorization-plugin=PLUGIN_ID` option. 1149 1150 ```bash 1151 $ sudo dockerd --authorization-plugin=plugin1 --authorization-plugin=plugin2,... 1152 ``` 1153 1154 The `PLUGIN_ID` value is either the plugin's name or a path to its specification 1155 file. The plugin's implementation determines whether you can specify a name or 1156 path. Consult with your Docker administrator to get information about the 1157 plugins available to you. 1158 1159 Once a plugin is installed, requests made to the `daemon` through the 1160 command line or Docker's Engine API are allowed or denied by the plugin. 1161 If you have multiple plugins installed, each plugin, in order, must 1162 allow the request for it to complete. 1163 1164 For information about how to create an authorization plugin, see [authorization 1165 plugin](../../extend/plugins_authorization.md) section in the Docker extend section of this documentation. 1166 1167 1168 ### Daemon user namespace options 1169 1170 The Linux kernel 1171 [user namespace support](http://man7.org/linux/man-pages/man7/user_namespaces.7.html) 1172 provides additional security by enabling a process, and therefore a container, 1173 to have a unique range of user and group IDs which are outside the traditional 1174 user and group range utilized by the host system. Potentially the most important 1175 security improvement is that, by default, container processes running as the 1176 `root` user will have expected administrative privilege (with some restrictions) 1177 inside the container but will effectively be mapped to an unprivileged `uid` on 1178 the host. 1179 1180 For details about how to use this feature, as well as limitations, see 1181 [Isolate containers with a user namespace](https://docs.docker.com/engine/security/userns-remap/). 1182 1183 ### Miscellaneous options 1184 1185 IP masquerading uses address translation to allow containers without a public 1186 IP to talk to other machines on the Internet. This may interfere with some 1187 network topologies and can be disabled with `--ip-masq=false`. 1188 1189 Docker supports softlinks for the Docker data directory (`/var/lib/docker`) and 1190 for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be 1191 set like this: 1192 1193 DOCKER_TMPDIR=/mnt/disk2/tmp /usr/local/bin/dockerd -D -g /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1 1194 # or 1195 export DOCKER_TMPDIR=/mnt/disk2/tmp 1196 /usr/local/bin/dockerd -D -g /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1 1197 1198 #### Default cgroup parent 1199 1200 The `--cgroup-parent` option allows you to set the default cgroup parent 1201 to use for containers. If this option is not set, it defaults to `/docker` for 1202 fs cgroup driver and `system.slice` for systemd cgroup driver. 1203 1204 If the cgroup has a leading forward slash (`/`), the cgroup is created 1205 under the root cgroup, otherwise the cgroup is created under the daemon 1206 cgroup. 1207 1208 Assuming the daemon is running in cgroup `daemoncgroup`, 1209 `--cgroup-parent=/foobar` creates a cgroup in 1210 `/sys/fs/cgroup/memory/foobar`, whereas using `--cgroup-parent=foobar` 1211 creates the cgroup in `/sys/fs/cgroup/memory/daemoncgroup/foobar` 1212 1213 The systemd cgroup driver has different rules for `--cgroup-parent`. Systemd 1214 represents hierarchy by slice and the name of the slice encodes the location in 1215 the tree. So `--cgroup-parent` for systemd cgroups should be a slice name. A 1216 name can consist of a dash-separated series of names, which describes the path 1217 to the slice from the root slice. For example, `--cgroup-parent=user-a-b.slice` 1218 means the memory cgroup for the container is created in 1219 `/sys/fs/cgroup/memory/user.slice/user-a.slice/user-a-b.slice/docker-<id>.scope`. 1220 1221 This setting can also be set per container, using the `--cgroup-parent` 1222 option on `docker create` and `docker run`, and takes precedence over 1223 the `--cgroup-parent` option on the daemon. 1224 1225 #### Daemon metrics 1226 1227 The `--metrics-addr` option takes a tcp address to serve the metrics API. 1228 This feature is still experimental, therefore, the daemon must be running in experimental 1229 mode for this feature to work. 1230 1231 To serve the metrics API on localhost:1337 you would specify `--metrics-addr 127.0.0.1:1337` 1232 allowing you to make requests on the API at `127.0.0.1:1337/metrics` to receive metrics in the 1233 [prometheus](https://prometheus.io/docs/instrumenting/exposition_formats/) format. 1234 1235 If you are running a prometheus server you can add this address to your scrape configs 1236 to have prometheus collect metrics on Docker. For more information 1237 on prometheus you can view the website [here](https://prometheus.io/). 1238 1239 ```none 1240 scrape_configs: 1241 - job_name: 'docker' 1242 static_configs: 1243 - targets: ['127.0.0.1:1337'] 1244 ``` 1245 1246 Please note that this feature is still marked as experimental as metrics and metric 1247 names could change while this feature is still in experimental. Please provide 1248 feedback on what you would like to see collected in the API. 1249 1250 #### Node Generic Resources 1251 1252 The `--node-generic-resources` option takes a list of key-value 1253 pair (`key=value`) that allows you to advertise user defined resources 1254 in a swarm cluster. 1255 1256 The current expected use case is to advertise NVIDIA GPUs so that services 1257 requesting `NVIDIA-GPU=[0-16]` can land on a node that has enough GPUs for 1258 the task to run. 1259 1260 Example of usage: 1261 ```json 1262 { 1263 "node-generic-resources": ["NVIDIA-GPU=UUID1", "NVIDIA-GPU=UUID2"] 1264 } 1265 ``` 1266 1267 ### Daemon configuration file 1268 1269 The `--config-file` option allows you to set any configuration option 1270 for the daemon in a JSON format. This file uses the same flag names as keys, 1271 except for flags that allow several entries, where it uses the plural 1272 of the flag name, e.g., `labels` for the `label` flag. 1273 1274 The options set in the configuration file must not conflict with options set 1275 via flags. The docker daemon fails to start if an option is duplicated between 1276 the file and the flags, regardless their value. We do this to avoid 1277 silently ignore changes introduced in configuration reloads. 1278 For example, the daemon fails to start if you set daemon labels 1279 in the configuration file and also set daemon labels via the `--label` flag. 1280 Options that are not present in the file are ignored when the daemon starts. 1281 1282 ##### On Linux 1283 1284 The default location of the configuration file on Linux is 1285 `/etc/docker/daemon.json`. The `--config-file` flag can be used to specify a 1286 non-default location. 1287 1288 This is a full example of the allowed configuration options on Linux: 1289 1290 ```json 1291 { 1292 "authorization-plugins": [], 1293 "data-root": "", 1294 "dns": [], 1295 "dns-opts": [], 1296 "dns-search": [], 1297 "exec-opts": [], 1298 "exec-root": "", 1299 "experimental": false, 1300 "features": {}, 1301 "storage-driver": "", 1302 "storage-opts": [], 1303 "labels": [], 1304 "live-restore": true, 1305 "log-driver": "", 1306 "log-opts": {}, 1307 "mtu": 0, 1308 "pidfile": "", 1309 "cluster-store": "", 1310 "cluster-store-opts": {}, 1311 "cluster-advertise": "", 1312 "max-concurrent-downloads": 3, 1313 "max-concurrent-uploads": 5, 1314 "default-shm-size": "64M", 1315 "shutdown-timeout": 15, 1316 "debug": true, 1317 "hosts": [], 1318 "log-level": "", 1319 "tls": true, 1320 "tlsverify": true, 1321 "tlscacert": "", 1322 "tlscert": "", 1323 "tlskey": "", 1324 "swarm-default-advertise-addr": "", 1325 "api-cors-header": "", 1326 "selinux-enabled": false, 1327 "userns-remap": "", 1328 "group": "", 1329 "cgroup-parent": "", 1330 "default-ulimits": {}, 1331 "init": false, 1332 "init-path": "/usr/libexec/docker-init", 1333 "ipv6": false, 1334 "iptables": false, 1335 "ip-forward": false, 1336 "ip-masq": false, 1337 "userland-proxy": false, 1338 "userland-proxy-path": "/usr/libexec/docker-proxy", 1339 "ip": "0.0.0.0", 1340 "bridge": "", 1341 "bip": "", 1342 "fixed-cidr": "", 1343 "fixed-cidr-v6": "", 1344 "default-gateway": "", 1345 "default-gateway-v6": "", 1346 "icc": false, 1347 "raw-logs": false, 1348 "allow-nondistributable-artifacts": [], 1349 "registry-mirrors": [], 1350 "seccomp-profile": "", 1351 "insecure-registries": [], 1352 "no-new-privileges": false, 1353 "default-runtime": "runc", 1354 "oom-score-adjust": -500, 1355 "node-generic-resources": ["NVIDIA-GPU=UUID1", "NVIDIA-GPU=UUID2"], 1356 "runtimes": { 1357 "cc-runtime": { 1358 "path": "/usr/bin/cc-runtime" 1359 }, 1360 "custom": { 1361 "path": "/usr/local/bin/my-runc-replacement", 1362 "runtimeArgs": [ 1363 "--debug" 1364 ] 1365 } 1366 }, 1367 "default-address-pools":[{"base":"172.80.0.0/16","size":24}, 1368 {"base":"172.90.0.0/16","size":24}] 1369 } 1370 ``` 1371 1372 > **Note:** You cannot set options in `daemon.json` that have already been set on 1373 > daemon startup as a flag. 1374 > On systems that use `systemd` to start the Docker daemon, `-H` is already set, so 1375 > you cannot use the `hosts` key in `daemon.json` to add listening addresses. 1376 > See https://docs.docker.com/engine/admin/systemd/#custom-docker-daemon-options for how 1377 > to accomplish this task with a systemd drop-in file. 1378 1379 ##### On Windows 1380 1381 The default location of the configuration file on Windows is 1382 `%programdata%\docker\config\daemon.json`. The `--config-file` flag can be 1383 used to specify a non-default location. 1384 1385 This is a full example of the allowed configuration options on Windows: 1386 1387 ```json 1388 { 1389 "authorization-plugins": [], 1390 "data-root": "", 1391 "dns": [], 1392 "dns-opts": [], 1393 "dns-search": [], 1394 "exec-opts": [], 1395 "experimental": false, 1396 "features":{}, 1397 "storage-driver": "", 1398 "storage-opts": [], 1399 "labels": [], 1400 "log-driver": "", 1401 "mtu": 0, 1402 "pidfile": "", 1403 "cluster-store": "", 1404 "cluster-advertise": "", 1405 "max-concurrent-downloads": 3, 1406 "max-concurrent-uploads": 5, 1407 "shutdown-timeout": 15, 1408 "debug": true, 1409 "hosts": [], 1410 "log-level": "", 1411 "tlsverify": true, 1412 "tlscacert": "", 1413 "tlscert": "", 1414 "tlskey": "", 1415 "swarm-default-advertise-addr": "", 1416 "group": "", 1417 "default-ulimits": {}, 1418 "bridge": "", 1419 "fixed-cidr": "", 1420 "raw-logs": false, 1421 "allow-nondistributable-artifacts": [], 1422 "registry-mirrors": [], 1423 "insecure-registries": [] 1424 } 1425 ``` 1426 1427 #### Feature options 1428 The optional field `features` in `daemon.json` allows users to enable or disable specific 1429 daemon features. For example, `{"features":{"buildkit": true}}` enables `buildkit` as the 1430 default docker image builder. 1431 1432 The list of currently supported feature options: 1433 - `buildkit`: It enables `buildkit` as default builder when set to `true` or disables it by 1434 `false`. Note that if this option is not explicitly set in the daemon config file, then it 1435 is up to the cli to determine which builder to invoke. 1436 1437 #### Configuration reload behavior 1438 1439 Some options can be reconfigured when the daemon is running without requiring 1440 to restart the process. We use the `SIGHUP` signal in Linux to reload, and a global event 1441 in Windows with the key `Global\docker-daemon-config-$PID`. The options can 1442 be modified in the configuration file but still will check for conflicts with 1443 the provided flags. The daemon fails to reconfigure itself 1444 if there are conflicts, but it won't stop execution. 1445 1446 The list of currently supported options that can be reconfigured is this: 1447 1448 - `debug`: it changes the daemon to debug mode when set to true. 1449 - `cluster-store`: it reloads the discovery store with the new address. 1450 - `cluster-store-opts`: it uses the new options to reload the discovery store. 1451 - `cluster-advertise`: it modifies the address advertised after reloading. 1452 - `labels`: it replaces the daemon labels with a new set of labels. 1453 - `live-restore`: Enables [keeping containers alive during daemon downtime](https://docs.docker.com/config/containers/live-restore/). 1454 - `max-concurrent-downloads`: it updates the max concurrent downloads for each pull. 1455 - `max-concurrent-uploads`: it updates the max concurrent uploads for each push. 1456 - `default-runtime`: it updates the runtime to be used if not is 1457 specified at container creation. It defaults to "default" which is 1458 the runtime shipped with the official docker packages. 1459 - `runtimes`: it updates the list of available OCI runtimes that can 1460 be used to run containers. 1461 - `authorization-plugin`: it specifies the authorization plugins to use. 1462 - `allow-nondistributable-artifacts`: Replaces the set of registries to which the daemon will push nondistributable artifacts with a new set of registries. 1463 - `insecure-registries`: it replaces the daemon insecure registries with a new set of insecure registries. If some existing insecure registries in daemon's configuration are not in newly reloaded insecure resgitries, these existing ones will be removed from daemon's config. 1464 - `registry-mirrors`: it replaces the daemon registry mirrors with a new set of registry mirrors. If some existing registry mirrors in daemon's configuration are not in newly reloaded registry mirrors, these existing ones will be removed from daemon's config. 1465 - `shutdown-timeout`: it replaces the daemon's existing configuration timeout with a new timeout for shutting down all containers. 1466 - `features`: it explicitly enables or disables specific features. 1467 1468 Updating and reloading the cluster configurations such as `--cluster-store`, 1469 `--cluster-advertise` and `--cluster-store-opts` will take effect only if 1470 these configurations were not previously configured. If `--cluster-store` 1471 has been provided in flags and `cluster-advertise` not, `cluster-advertise` 1472 can be added in the configuration file without accompanied by `--cluster-store`. 1473 Configuration reload will log a warning message if it detects a change in 1474 previously configured cluster configurations. 1475 1476 1477 ### Run multiple daemons 1478 1479 > **Note:** Running multiple daemons on a single host is considered as "experimental". The user should be aware of 1480 > unsolved problems. This solution may not work properly in some cases. Solutions are currently under development 1481 > and will be delivered in the near future. 1482 1483 This section describes how to run multiple Docker daemons on a single host. To 1484 run multiple daemons, you must configure each daemon so that it does not 1485 conflict with other daemons on the same host. You can set these options either 1486 by providing them as flags, or by using a [daemon configuration file](#daemon-configuration-file). 1487 1488 The following daemon options must be configured for each daemon: 1489 1490 ```none 1491 -b, --bridge= Attach containers to a network bridge 1492 --exec-root=/var/run/docker Root of the Docker execdriver 1493 --data-root=/var/lib/docker Root of persisted Docker data 1494 -p, --pidfile=/var/run/docker.pid Path to use for daemon PID file 1495 -H, --host=[] Daemon socket(s) to connect to 1496 --iptables=true Enable addition of iptables rules 1497 --config-file=/etc/docker/daemon.json Daemon configuration file 1498 --tlscacert="~/.docker/ca.pem" Trust certs signed only by this CA 1499 --tlscert="~/.docker/cert.pem" Path to TLS certificate file 1500 --tlskey="~/.docker/key.pem" Path to TLS key file 1501 ``` 1502 1503 When your daemons use different values for these flags, you can run them on the same host without any problems. 1504 It is very important to properly understand the meaning of those options and to use them correctly. 1505 1506 - The `-b, --bridge=` flag is set to `docker0` as default bridge network. It is created automatically when you install Docker. 1507 If you are not using the default, you must create and configure the bridge manually or just set it to 'none': `--bridge=none` 1508 - `--exec-root` is the path where the container state is stored. The default value is `/var/run/docker`. Specify the path for 1509 your running daemon here. 1510 - `--data-root` is the path where persisted data such as images, volumes, and 1511 cluster state are stored. The default value is `/var/lib/docker`. To avoid any 1512 conflict with other daemons, set this parameter separately for each daemon. 1513 - `-p, --pidfile=/var/run/docker.pid` is the path where the process ID of the daemon is stored. Specify the path for your 1514 pid file here. 1515 - `--host=[]` specifies where the Docker daemon will listen for client connections. If unspecified, it defaults to `/var/run/docker.sock`. 1516 - `--iptables=false` prevents the Docker daemon from adding iptables rules. If 1517 multiple daemons manage iptables rules, they may overwrite rules set by another 1518 daemon. Be aware that disabling this option requires you to manually add 1519 iptables rules to expose container ports. If you prevent Docker from adding 1520 iptables rules, Docker will also not add IP masquerading rules, even if you set 1521 `--ip-masq` to `true`. Without IP masquerading rules, Docker containers will not be 1522 able to connect to external hosts or the internet when using network other than 1523 default bridge. 1524 - `--config-file=/etc/docker/daemon.json` is the path where configuration file is stored. You can use it instead of 1525 daemon flags. Specify the path for each daemon. 1526 - `--tls*` Docker daemon supports `--tlsverify` mode that enforces encrypted and authenticated remote connections. 1527 The `--tls*` options enable use of specific certificates for individual daemons. 1528 1529 Example script for a separate “bootstrap” instance of the Docker daemon without network: 1530 1531 ```bash 1532 $ sudo dockerd \ 1533 -H unix:///var/run/docker-bootstrap.sock \ 1534 -p /var/run/docker-bootstrap.pid \ 1535 --iptables=false \ 1536 --ip-masq=false \ 1537 --bridge=none \ 1538 --data-root=/var/lib/docker-bootstrap \ 1539 --exec-root=/var/run/docker-bootstrap 1540 ```