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