github.com/kobeld/docker@v1.12.0-rc1/docs/reference/commandline/dockerd.md (about) 1 <!--[metadata]> 2 +++ 3 title = "dockerd" 4 aliases = ["/engine/reference/commandline/daemon/"] 5 description = "The daemon command description and usage" 6 keywords = ["container, daemon, runtime"] 7 [menu.main] 8 parent = "smn_cli" 9 weight = -1 10 +++ 11 <![end-metadata]--> 12 13 # daemon 14 15 Usage: dockerd [OPTIONS] 16 17 A self-sufficient runtime for linux containers. 18 19 Options: 20 --api-cors-header="" Set CORS headers in the remote API 21 --authorization-plugin=[] Set authorization plugins to load 22 -b, --bridge="" Attach containers to a network bridge 23 --bip="" Specify network bridge IP 24 --cgroup-parent= Set parent cgroup for all containers 25 --cluster-store="" URL of the distributed storage backend 26 --cluster-advertise="" Address of the daemon instance on the cluster 27 --cluster-store-opt=map[] Set cluster options 28 --config-file=/etc/docker/daemon.json Daemon configuration file 29 --containerd Path to containerd socket 30 -D, --debug Enable debug mode 31 --default-gateway="" Container default gateway IPv4 address 32 --default-gateway-v6="" Container default gateway IPv6 address 33 --dns=[] DNS server to use 34 --dns-opt=[] DNS options to use 35 --dns-search=[] DNS search domains to use 36 --default-ulimit=[] Set default ulimit settings for containers 37 --exec-opt=[] Set runtime execution options 38 --exec-root="/var/run/docker" Root directory for execution state files 39 --fixed-cidr="" IPv4 subnet for fixed IPs 40 --fixed-cidr-v6="" IPv6 subnet for fixed IPs 41 -G, --group="docker" Group for the unix socket 42 -g, --graph="/var/lib/docker" Root of the Docker runtime 43 -H, --host=[] Daemon socket(s) to connect to 44 --help Print usage 45 --icc=true Enable inter-container communication 46 --insecure-registry=[] Enable insecure registry communication 47 --ip=0.0.0.0 Default IP when binding container ports 48 --ip-forward=true Enable net.ipv4.ip_forward 49 --ip-masq=true Enable IP masquerading 50 --iptables=true Enable addition of iptables rules 51 --ipv6 Enable IPv6 networking 52 -l, --log-level="info" Set the logging level 53 --label=[] Set key=value labels to the daemon 54 --log-driver="json-file" Default driver for container logs 55 --log-opt=[] Log driver specific options 56 --mtu=0 Set the containers network MTU 57 --max-concurrent-downloads=3 Set the max concurrent downloads for each pull 58 --max-concurrent-uploads=5 Set the max concurrent uploads for each push 59 --disable-legacy-registry Do not contact legacy registries 60 -p, --pidfile="/var/run/docker.pid" Path to use for daemon PID file 61 --raw-logs Full timestamps without ANSI coloring 62 --registry-mirror=[] Preferred Docker registry mirror 63 --add-runtime=[] Register an additional OCI compatible runtime 64 -s, --storage-driver="" Storage driver to use 65 --selinux-enabled Enable selinux support 66 --storage-opt=[] Set storage driver options 67 --tls Use TLS; implied by --tlsverify 68 --tlscacert="~/.docker/ca.pem" Trust certs signed only by this CA 69 --tlscert="~/.docker/cert.pem" Path to TLS certificate file 70 --tlskey="~/.docker/key.pem" Path to TLS key file 71 --tlsverify Use TLS and verify the remote 72 --userns-remap="default" Enable user namespace remapping 73 --userland-proxy=true Use userland proxy for loopback traffic 74 75 Options with [] may be specified multiple times. 76 77 dockerd is the persistent process that manages containers. Docker 78 uses different binaries for the daemon and client. To run the daemon you 79 type `dockerd`. 80 81 To run the daemon with debug output, use `dockerd -D`. 82 83 ## Daemon socket option 84 85 The Docker daemon can listen for [Docker Remote API](../api/docker_remote_api.md) 86 requests via three different types of Socket: `unix`, `tcp`, and `fd`. 87 88 By default, a `unix` domain socket (or IPC socket) is created at 89 `/var/run/docker.sock`, requiring either `root` permission, or `docker` group 90 membership. 91 92 If you need to access the Docker daemon remotely, you need to enable the `tcp` 93 Socket. Beware that the default setup provides un-encrypted and 94 un-authenticated direct access to the Docker daemon - and should be secured 95 either using the [built in HTTPS encrypted socket](../../security/https.md), or by 96 putting a secure web proxy in front of it. You can listen on port `2375` on all 97 network interfaces with `-H tcp://0.0.0.0:2375`, or on a particular network 98 interface using its IP address: `-H tcp://192.168.59.103:2375`. It is 99 conventional to use port `2375` for un-encrypted, and port `2376` for encrypted 100 communication with the daemon. 101 102 > **Note:** 103 > If you're using an HTTPS encrypted socket, keep in mind that only 104 > TLS1.0 and greater are supported. Protocols SSLv3 and under are not 105 > supported anymore for security reasons. 106 107 On Systemd based systems, you can communicate with the daemon via 108 [Systemd socket activation](http://0pointer.de/blog/projects/socket-activation.html), 109 use `dockerd -H fd://`. Using `fd://` will work perfectly for most setups but 110 you can also specify individual sockets: `dockerd -H fd://3`. If the 111 specified socket activated files aren't found, then Docker will exit. You can 112 find examples of using Systemd socket activation with Docker and Systemd in the 113 [Docker source tree](https://github.com/docker/docker/tree/master/contrib/init/systemd/). 114 115 You can configure the Docker daemon to listen to multiple sockets at the same 116 time using multiple `-H` options: 117 118 # listen using the default unix socket, and on 2 specific IP addresses on this host. 119 dockerd -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2 120 121 The Docker client will honor the `DOCKER_HOST` environment variable to set the 122 `-H` flag for the client. 123 124 $ docker -H tcp://0.0.0.0:2375 ps 125 # or 126 $ export DOCKER_HOST="tcp://0.0.0.0:2375" 127 $ docker ps 128 # both are equal 129 130 Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than 131 the empty string is equivalent to setting the `--tlsverify` flag. The following 132 are equivalent: 133 134 $ docker --tlsverify ps 135 # or 136 $ export DOCKER_TLS_VERIFY=1 137 $ docker ps 138 139 The Docker client will honor the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` 140 environment variables (or the lowercase versions thereof). `HTTPS_PROXY` takes 141 precedence over `HTTP_PROXY`. 142 143 ### Bind Docker to another host/port or a Unix socket 144 145 > **Warning**: 146 > Changing the default `docker` daemon binding to a 147 > TCP port or Unix *docker* user group will increase your security risks 148 > by allowing non-root users to gain *root* access on the host. Make sure 149 > you control access to `docker`. If you are binding 150 > to a TCP port, anyone with access to that port has full Docker access; 151 > so it is not advisable on an open network. 152 153 With `-H` it is possible to make the Docker daemon to listen on a 154 specific IP and port. By default, it will listen on 155 `unix:///var/run/docker.sock` to allow only local connections by the 156 *root* user. You *could* set it to `0.0.0.0:2375` or a specific host IP 157 to give access to everybody, but that is **not recommended** because 158 then it is trivial for someone to gain root access to the host where the 159 daemon is running. 160 161 Similarly, the Docker client can use `-H` to connect to a custom port. 162 The Docker client will default to connecting to `unix:///var/run/docker.sock` 163 on Linux, and `tcp://127.0.0.1:2376` on Windows. 164 165 `-H` accepts host and port assignment in the following format: 166 167 tcp://[host]:[port][path] or unix://path 168 169 For example: 170 171 - `tcp://` -> TCP connection to `127.0.0.1` on either port `2376` when TLS encryption 172 is on, or port `2375` when communication is in plain text. 173 - `tcp://host:2375` -> TCP connection on 174 host:2375 175 - `tcp://host:2375/path` -> TCP connection on 176 host:2375 and prepend path to all requests 177 - `unix://path/to/socket` -> Unix socket located 178 at `path/to/socket` 179 180 `-H`, when empty, will default to the same value as 181 when no `-H` was passed in. 182 183 `-H` also accepts short form for TCP bindings: 184 185 `host:` or `host:port` or `:port` 186 187 Run Docker in daemon mode: 188 189 $ sudo <path to>/dockerd -H 0.0.0.0:5555 & 190 191 Download an `ubuntu` image: 192 193 $ docker -H :5555 pull ubuntu 194 195 You can use multiple `-H`, for example, if you want to listen on both 196 TCP and a Unix socket 197 198 # Run docker in daemon mode 199 $ sudo <path to>/dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock & 200 # Download an ubuntu image, use default Unix socket 201 $ docker pull ubuntu 202 # OR use the TCP port 203 $ docker -H tcp://127.0.0.1:2375 pull ubuntu 204 205 ### Daemon storage-driver option 206 207 The Docker daemon has support for several different image layer storage 208 drivers: `aufs`, `devicemapper`, `btrfs`, `zfs`, `overlay` and `overlay2`. 209 210 The `aufs` driver is the oldest, but is based on a Linux kernel patch-set that 211 is unlikely to be merged into the main kernel. These are also known to cause 212 some serious kernel crashes. However, `aufs` is also the only storage driver 213 that allows containers to share executable and shared library memory, so is a 214 useful choice when running thousands of containers with the same program or 215 libraries. 216 217 The `devicemapper` driver uses thin provisioning and Copy on Write (CoW) 218 snapshots. For each devicemapper graph location – typically 219 `/var/lib/docker/devicemapper` – a thin pool is created based on two block 220 devices, one for data and one for metadata. By default, these block devices 221 are created automatically by using loopback mounts of automatically created 222 sparse files. Refer to [Storage driver options](#storage-driver-options) below 223 for a way how to customize this setup. 224 [~jpetazzo/Resizing Docker containers with the Device Mapper plugin](http://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/) 225 article explains how to tune your existing setup without the use of options. 226 227 The `btrfs` driver is very fast for `docker build` - but like `devicemapper` 228 does not share executable memory between devices. Use 229 `dockerd -s btrfs -g /mnt/btrfs_partition`. 230 231 The `zfs` driver is probably not as fast as `btrfs` but has a longer track record 232 on stability. Thanks to `Single Copy ARC` shared blocks between clones will be 233 cached only once. Use `dockerd -s zfs`. To select a different zfs filesystem 234 set `zfs.fsname` option as described in [Storage driver options](#storage-driver-options). 235 236 The `overlay` is a very fast union filesystem. It is now merged in the main 237 Linux kernel as of [3.18.0](https://lkml.org/lkml/2014/10/26/137). Call 238 `dockerd -s overlay` to use it. 239 240 > **Note:** 241 > As promising as `overlay` is, the feature is still quite young and should not 242 > be used in production. Most notably, using `overlay` can cause excessive 243 > inode consumption (especially as the number of images grows), as well as 244 > being incompatible with the use of RPMs. 245 246 The `overlay2` uses the same fast union filesystem but takes advantage of 247 [additional features](https://lkml.org/lkml/2015/2/11/106) added in Linux 248 kernel 4.0 to avoid excessive inode consumption. Call `dockerd -s overlay2` 249 to use it. 250 251 > **Note:** 252 > Both `overlay` and `overlay2` are currently unsupported on `btrfs` or any 253 > Copy on Write filesystem and should only be used over `ext4` partitions. 254 255 ### Storage driver options 256 257 Particular storage-driver can be configured with options specified with 258 `--storage-opt` flags. Options for `devicemapper` are prefixed with `dm`, 259 options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`. 260 261 #### Devicemapper options 262 263 * `dm.thinpooldev` 264 265 Specifies a custom block storage device to use for the thin pool. 266 267 If using a block device for device mapper storage, it is best to use `lvm` 268 to create and manage the thin-pool volume. This volume is then handed to Docker 269 to exclusively create snapshot volumes needed for images and containers. 270 271 Managing the thin-pool outside of Engine makes for the most feature-rich 272 method of having Docker utilize device mapper thin provisioning as the 273 backing storage for Docker containers. The highlights of the lvm-based 274 thin-pool management feature include: automatic or interactive thin-pool 275 resize support, dynamically changing thin-pool features, automatic thinp 276 metadata checking when lvm activates the thin-pool, etc. 277 278 As a fallback if no thin pool is provided, loopback files are 279 created. Loopback is very slow, but can be used without any 280 pre-configuration of storage. It is strongly recommended that you do 281 not use loopback in production. Ensure your Engine daemon has a 282 `--storage-opt dm.thinpooldev` argument provided. 283 284 Example use: 285 286 $ dockerd \ 287 --storage-opt dm.thinpooldev=/dev/mapper/thin-pool 288 289 * `dm.basesize` 290 291 Specifies the size to use when creating the base device, which limits the 292 size of images and containers. The default value is 10G. Note, thin devices 293 are inherently "sparse", so a 10G device which is mostly empty doesn't use 294 10 GB of space on the pool. However, the filesystem will use more space for 295 the empty case the larger the device is. 296 297 The base device size can be increased at daemon restart which will allow 298 all future images and containers (based on those new images) to be of the 299 new base device size. 300 301 Example use: 302 303 $ dockerd --storage-opt dm.basesize=50G 304 305 This will increase the base device size to 50G. The Docker daemon will throw an 306 error if existing base device size is larger than 50G. A user can use 307 this option to expand the base device size however shrinking is not permitted. 308 309 This value affects the system-wide "base" empty filesystem 310 that may already be initialized and inherited by pulled images. Typically, 311 a change to this value requires additional steps to take effect: 312 313 $ sudo service docker stop 314 $ sudo rm -rf /var/lib/docker 315 $ sudo service docker start 316 317 Example use: 318 319 $ dockerd --storage-opt dm.basesize=20G 320 321 * `dm.loopdatasize` 322 323 > **Note**: 324 > This option configures devicemapper loopback, which should not 325 > be used in production. 326 327 Specifies the size to use when creating the loopback file for the 328 "data" device which is used for the thin pool. The default size is 329 100G. The file is sparse, so it will not initially take up this 330 much space. 331 332 Example use: 333 334 $ dockerd --storage-opt dm.loopdatasize=200G 335 336 * `dm.loopmetadatasize` 337 338 > **Note**: 339 > This option configures devicemapper loopback, which should not 340 > be used in production. 341 342 Specifies the size to use when creating the loopback file for the 343 "metadata" device which is used for the thin pool. The default size 344 is 2G. The file is sparse, so it will not initially take up 345 this much space. 346 347 Example use: 348 349 $ dockerd --storage-opt dm.loopmetadatasize=4G 350 351 * `dm.fs` 352 353 Specifies the filesystem type to use for the base device. The supported 354 options are "ext4" and "xfs". The default is "xfs" 355 356 Example use: 357 358 $ dockerd --storage-opt dm.fs=ext4 359 360 * `dm.mkfsarg` 361 362 Specifies extra mkfs arguments to be used when creating the base device. 363 364 Example use: 365 366 $ dockerd --storage-opt "dm.mkfsarg=-O ^has_journal" 367 368 * `dm.mountopt` 369 370 Specifies extra mount options used when mounting the thin devices. 371 372 Example use: 373 374 $ dockerd --storage-opt dm.mountopt=nodiscard 375 376 * `dm.datadev` 377 378 (Deprecated, use `dm.thinpooldev`) 379 380 Specifies a custom blockdevice to use for data for the thin pool. 381 382 If using a block device for device mapper storage, ideally both datadev and 383 metadatadev should be specified to completely avoid using the loopback 384 device. 385 386 Example use: 387 388 $ dockerd \ 389 --storage-opt dm.datadev=/dev/sdb1 \ 390 --storage-opt dm.metadatadev=/dev/sdc1 391 392 * `dm.metadatadev` 393 394 (Deprecated, use `dm.thinpooldev`) 395 396 Specifies a custom blockdevice to use for metadata for the thin pool. 397 398 For best performance the metadata should be on a different spindle than the 399 data, or even better on an SSD. 400 401 If setting up a new metadata pool it is required to be valid. This can be 402 achieved by zeroing the first 4k to indicate empty metadata, like this: 403 404 $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1 405 406 Example use: 407 408 $ dockerd \ 409 --storage-opt dm.datadev=/dev/sdb1 \ 410 --storage-opt dm.metadatadev=/dev/sdc1 411 412 * `dm.blocksize` 413 414 Specifies a custom blocksize to use for the thin pool. The default 415 blocksize is 64K. 416 417 Example use: 418 419 $ dockerd --storage-opt dm.blocksize=512K 420 421 * `dm.blkdiscard` 422 423 Enables or disables the use of blkdiscard when removing devicemapper 424 devices. This is enabled by default (only) if using loopback devices and is 425 required to resparsify the loopback file on image/container removal. 426 427 Disabling this on loopback can lead to *much* faster container removal 428 times, but will make the space used in `/var/lib/docker` directory not be 429 returned to the system for other use when containers are removed. 430 431 Example use: 432 433 $ dockerd --storage-opt dm.blkdiscard=false 434 435 * `dm.override_udev_sync_check` 436 437 Overrides the `udev` synchronization checks between `devicemapper` and `udev`. 438 `udev` is the device manager for the Linux kernel. 439 440 To view the `udev` sync support of a Docker daemon that is using the 441 `devicemapper` driver, run: 442 443 $ docker info 444 [...] 445 Udev Sync Supported: true 446 [...] 447 448 When `udev` sync support is `true`, then `devicemapper` and udev can 449 coordinate the activation and deactivation of devices for containers. 450 451 When `udev` sync support is `false`, a race condition occurs between 452 the`devicemapper` and `udev` during create and cleanup. The race condition 453 results in errors and failures. (For information on these failures, see 454 [docker#4036](https://github.com/docker/docker/issues/4036)) 455 456 To allow the `docker` daemon to start, regardless of `udev` sync not being 457 supported, set `dm.override_udev_sync_check` to true: 458 459 $ dockerd --storage-opt dm.override_udev_sync_check=true 460 461 When this value is `true`, the `devicemapper` continues and simply warns 462 you the errors are happening. 463 464 > **Note:** 465 > The ideal is to pursue a `docker` daemon and environment that does 466 > support synchronizing with `udev`. For further discussion on this 467 > topic, see [docker#4036](https://github.com/docker/docker/issues/4036). 468 > Otherwise, set this flag for migrating existing Docker daemons to 469 > a daemon with a supported environment. 470 471 * `dm.use_deferred_removal` 472 473 Enables use of deferred device removal if `libdm` and the kernel driver 474 support the mechanism. 475 476 Deferred device removal means that if device is busy when devices are 477 being removed/deactivated, then a deferred removal is scheduled on 478 device. And devices automatically go away when last user of the device 479 exits. 480 481 For example, when a container exits, its associated thin device is removed. 482 If that device has leaked into some other mount namespace and can't be 483 removed, the container exit still succeeds and this option causes the 484 system to schedule the device for deferred removal. It does not wait in a 485 loop trying to remove a busy device. 486 487 Example use: 488 489 $ dockerd --storage-opt dm.use_deferred_removal=true 490 491 * `dm.use_deferred_deletion` 492 493 Enables use of deferred device deletion for thin pool devices. By default, 494 thin pool device deletion is synchronous. Before a container is deleted, 495 the Docker daemon removes any associated devices. If the storage driver 496 can not remove a device, the container deletion fails and daemon returns. 497 498 Error deleting container: Error response from daemon: Cannot destroy container 499 500 To avoid this failure, enable both deferred device deletion and deferred 501 device removal on the daemon. 502 503 $ dockerd \ 504 --storage-opt dm.use_deferred_deletion=true \ 505 --storage-opt dm.use_deferred_removal=true 506 507 With these two options enabled, if a device is busy when the driver is 508 deleting a container, the driver marks the device as deleted. Later, when 509 the device isn't in use, the driver deletes it. 510 511 In general it should be safe to enable this option by default. It will help 512 when unintentional leaking of mount point happens across multiple mount 513 namespaces. 514 515 * `dm.min_free_space` 516 517 Specifies the min free space percent in a thin pool require for new device 518 creation to succeed. This check applies to both free data space as well 519 as free metadata space. Valid values are from 0% - 99%. Value 0% disables 520 free space checking logic. If user does not specify a value for this option, 521 the Engine uses a default value of 10%. 522 523 Whenever a new a thin pool device is created (during `docker pull` or during 524 container creation), the Engine checks if the minimum free space is 525 available. If sufficient space is unavailable, then device creation fails 526 and any relevant `docker` operation fails. 527 528 To recover from this error, you must create more free space in the thin pool 529 to recover from the error. You can create free space by deleting some images 530 and containers from the thin pool. You can also add more storage to the thin 531 pool. 532 533 To add more space to a LVM (logical volume management) thin pool, just add 534 more storage to the volume group container thin pool; this should automatically 535 resolve any errors. If your configuration uses loop devices, then stop the 536 Engine daemon, grow the size of loop files and restart the daemon to resolve 537 the issue. 538 539 Example use: 540 541 ```bash 542 $ dockerd --storage-opt dm.min_free_space=10% 543 ``` 544 545 #### ZFS options 546 547 * `zfs.fsname` 548 549 Set zfs filesystem under which docker will create its own datasets. 550 By default docker will pick up the zfs filesystem where docker graph 551 (`/var/lib/docker`) is located. 552 553 Example use: 554 555 $ dockerd -s zfs --storage-opt zfs.fsname=zroot/docker 556 557 #### Btrfs options 558 559 * `btrfs.min_space` 560 561 Specifies the mininum size to use when creating the subvolume which is used 562 for containers. If user uses disk quota for btrfs when creating or running 563 a container with **--storage-opt size** option, docker should ensure the 564 **size** cannot be smaller than **btrfs.min_space**. 565 566 Example use: 567 $ docker daemon -s btrfs --storage-opt btrfs.min_space=10G 568 569 ## Docker runtime execution options 570 571 The Docker daemon relies on a 572 [OCI](https://github.com/opencontainers/specs) compliant runtime 573 (invoked via the `containerd` daemon) as its interface to the Linux 574 kernel `namespaces`, `cgroups`, and `SELinux`. 575 576 Runtimes can be registered with the daemon either via the 577 configuration file or using the `--add-runtime` command line argument. 578 579 The following is an example adding 2 runtimes via the configuration: 580 ```json 581 "default-runtime": "runc", 582 "runtimes": { 583 "runc": { 584 "path": "runc" 585 }, 586 "custom": { 587 "path": "/usr/local/bin/my-runc-replacement", 588 "runtimeArgs": [ 589 "--debug" 590 ] 591 } 592 } 593 ``` 594 595 This is the same example via the command line: 596 597 $ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-runc-replacement 598 599 **Note**: defining runtime arguments via the command line is not supported. 600 601 ## Options for the runtime 602 603 You can configure the runtime using options specified 604 with the `--exec-opt` flag. All the flag's options have the `native` prefix. A 605 single `native.cgroupdriver` option is available. 606 607 The `native.cgroupdriver` option specifies the management of the container's 608 cgroups. You can specify only specify `cgroupfs` or `systemd`. If you specify 609 `systemd` and it is not available, the system errors out. If you omit the 610 `native.cgroupdriver` option,` cgroupfs` is used. 611 612 This example sets the `cgroupdriver` to `systemd`: 613 614 $ sudo dockerd --exec-opt native.cgroupdriver=systemd 615 616 Setting this option applies to all containers the daemon launches. 617 618 Also Windows Container makes use of `--exec-opt` for special purpose. Docker user 619 can specify default container isolation technology with this, for example: 620 621 $ dockerd --exec-opt isolation=hyperv 622 623 Will make `hyperv` the default isolation technology on Windows. If no isolation 624 value is specified on daemon start, on Windows client, the default is 625 `hyperv`, and on Windows server, the default is `process`. 626 627 ## Daemon DNS options 628 629 To set the DNS server for all Docker containers, use 630 `dockerd --dns 8.8.8.8`. 631 632 To set the DNS search domain for all Docker containers, use 633 `dockerd --dns-search example.com`. 634 635 ## Insecure registries 636 637 Docker considers a private registry either secure or insecure. In the rest of 638 this section, *registry* is used for *private registry*, and `myregistry:5000` 639 is a placeholder example for a private registry. 640 641 A secure registry uses TLS and a copy of its CA certificate is placed on the 642 Docker host at `/etc/docker/certs.d/myregistry:5000/ca.crt`. An insecure 643 registry is either not using TLS (i.e., listening on plain text HTTP), or is 644 using TLS with a CA certificate not known by the Docker daemon. The latter can 645 happen when the certificate was not found under 646 `/etc/docker/certs.d/myregistry:5000/`, or if the certificate verification 647 failed (i.e., wrong CA). 648 649 By default, Docker assumes all, but local (see local registries below), 650 registries are secure. Communicating with an insecure registry is not possible 651 if Docker assumes that registry is secure. In order to communicate with an 652 insecure registry, the Docker daemon requires `--insecure-registry` in one of 653 the following two forms: 654 655 * `--insecure-registry myregistry:5000` tells the Docker daemon that 656 myregistry:5000 should be considered insecure. 657 * `--insecure-registry 10.1.0.0/16` tells the Docker daemon that all registries 658 whose domain resolve to an IP address is part of the subnet described by the 659 CIDR syntax, should be considered insecure. 660 661 The flag can be used multiple times to allow multiple registries to be marked 662 as insecure. 663 664 If an insecure registry is not marked as insecure, `docker pull`, 665 `docker push`, and `docker search` will result in an error message prompting 666 the user to either secure or pass the `--insecure-registry` flag to the Docker 667 daemon as described above. 668 669 Local registries, whose IP address falls in the 127.0.0.0/8 range, are 670 automatically marked as insecure as of Docker 1.3.2. It is not recommended to 671 rely on this, as it may change in the future. 672 673 Enabling `--insecure-registry`, i.e., allowing un-encrypted and/or untrusted 674 communication, can be useful when running a local registry. However, 675 because its use creates security vulnerabilities it should ONLY be enabled for 676 testing purposes. For increased security, users should add their CA to their 677 system's list of trusted CAs instead of enabling `--insecure-registry`. 678 679 ## Legacy Registries 680 681 Enabling `--disable-legacy-registry` forces a docker daemon to only interact with registries which support the V2 protocol. Specifically, the daemon will not attempt `push`, `pull` and `login` to v1 registries. The exception to this is `search` which can still be performed on v1 registries. 682 683 ## Running a Docker daemon behind an HTTPS_PROXY 684 685 When running inside a LAN that uses an `HTTPS` proxy, the Docker Hub 686 certificates will be replaced by the proxy's certificates. These certificates 687 need to be added to your Docker host's configuration: 688 689 1. Install the `ca-certificates` package for your distribution 690 2. Ask your network admin for the proxy's CA certificate and append them to 691 `/etc/pki/tls/certs/ca-bundle.crt` 692 3. Then start your Docker daemon with `HTTPS_PROXY=http://username:password@proxy:port/ dockerd`. 693 The `username:` and `password@` are optional - and are only needed if your 694 proxy is set up to require authentication. 695 696 This will only add the proxy and authentication to the Docker daemon's requests - 697 your `docker build`s and running containers will need extra configuration to 698 use the proxy 699 700 ## Default Ulimits 701 702 `--default-ulimit` allows you to set the default `ulimit` options to use for 703 all containers. It takes the same options as `--ulimit` for `docker run`. If 704 these defaults are not set, `ulimit` settings will be inherited, if not set on 705 `docker run`, from the Docker daemon. Any `--ulimit` options passed to 706 `docker run` will overwrite these defaults. 707 708 Be careful setting `nproc` with the `ulimit` flag as `nproc` is designed by Linux to 709 set the maximum number of processes available to a user, not to a container. For details 710 please check the [run](run.md) reference. 711 712 ## Nodes discovery 713 714 The `--cluster-advertise` option specifies the `host:port` or `interface:port` 715 combination that this particular daemon instance should use when advertising 716 itself to the cluster. The daemon is reached by remote hosts through this value. 717 If you specify an interface, make sure it includes the IP address of the actual 718 Docker host. For Engine installation created through `docker-machine`, the 719 interface is typically `eth1`. 720 721 The daemon uses [libkv](https://github.com/docker/libkv/) to advertise 722 the node within the cluster. Some key-value backends support mutual 723 TLS. To configure the client TLS settings used by the daemon can be configured 724 using the `--cluster-store-opt` flag, specifying the paths to PEM encoded 725 files. For example: 726 727 ```bash 728 dockerd \ 729 --cluster-advertise 192.168.1.2:2376 \ 730 --cluster-store etcd://192.168.1.2:2379 \ 731 --cluster-store-opt kv.cacertfile=/path/to/ca.pem \ 732 --cluster-store-opt kv.certfile=/path/to/cert.pem \ 733 --cluster-store-opt kv.keyfile=/path/to/key.pem 734 ``` 735 736 The currently supported cluster store options are: 737 738 * `discovery.heartbeat` 739 740 Specifies the heartbeat timer in seconds which is used by the daemon as a 741 keepalive mechanism to make sure discovery module treats the node as alive 742 in the cluster. If not configured, the default value is 20 seconds. 743 744 * `discovery.ttl` 745 746 Specifies the ttl (time-to-live) in seconds which is used by the discovery 747 module to timeout a node if a valid heartbeat is not received within the 748 configured ttl value. If not configured, the default value is 60 seconds. 749 750 * `kv.cacertfile` 751 752 Specifies the path to a local file with PEM encoded CA certificates to trust 753 754 * `kv.certfile` 755 756 Specifies the path to a local file with a PEM encoded certificate. This 757 certificate is used as the client cert for communication with the 758 Key/Value store. 759 760 * `kv.keyfile` 761 762 Specifies the path to a local file with a PEM encoded private key. This 763 private key is used as the client key for communication with the 764 Key/Value store. 765 766 * `kv.path` 767 768 Specifies the path in the Key/Value store. If not configured, the default value is 'docker/nodes'. 769 770 ## Access authorization 771 772 Docker's access authorization can be extended by authorization plugins that your 773 organization can purchase or build themselves. You can install one or more 774 authorization plugins when you start the Docker `daemon` using the 775 `--authorization-plugin=PLUGIN_ID` option. 776 777 ```bash 778 dockerd --authorization-plugin=plugin1 --authorization-plugin=plugin2,... 779 ``` 780 781 The `PLUGIN_ID` value is either the plugin's name or a path to its specification 782 file. The plugin's implementation determines whether you can specify a name or 783 path. Consult with your Docker administrator to get information about the 784 plugins available to you. 785 786 Once a plugin is installed, requests made to the `daemon` through the command 787 line or Docker's remote API are allowed or denied by the plugin. If you have 788 multiple plugins installed, at least one must allow the request for it to 789 complete. 790 791 For information about how to create an authorization plugin, see [authorization 792 plugin](../../extend/plugins_authorization.md) section in the Docker extend section of this documentation. 793 794 795 ## Daemon user namespace options 796 797 The Linux kernel [user namespace support](http://man7.org/linux/man-pages/man7/user_namespaces.7.html) provides additional security by enabling 798 a process, and therefore a container, to have a unique range of user and 799 group IDs which are outside the traditional user and group range utilized by 800 the host system. Potentially the most important security improvement is that, 801 by default, container processes running as the `root` user will have expected 802 administrative privilege (with some restrictions) inside the container but will 803 effectively be mapped to an unprivileged `uid` on the host. 804 805 When user namespace support is enabled, Docker creates a single daemon-wide mapping 806 for all containers running on the same engine instance. The mappings will 807 utilize the existing subordinate user and group ID feature available on all modern 808 Linux distributions. 809 The [`/etc/subuid`](http://man7.org/linux/man-pages/man5/subuid.5.html) and 810 [`/etc/subgid`](http://man7.org/linux/man-pages/man5/subgid.5.html) files will be 811 read for the user, and optional group, specified to the `--userns-remap` 812 parameter. If you do not wish to specify your own user and/or group, you can 813 provide `default` as the value to this flag, and a user will be created on your behalf 814 and provided subordinate uid and gid ranges. This default user will be named 815 `dockremap`, and entries will be created for it in `/etc/passwd` and 816 `/etc/group` using your distro's standard user and group creation tools. 817 818 > **Note**: The single mapping per-daemon restriction is in place for now 819 > because Docker shares image layers from its local cache across all 820 > containers running on the engine instance. Since file ownership must be 821 > the same for all containers sharing the same layer content, the decision 822 > was made to map the file ownership on `docker pull` to the daemon's user and 823 > group mappings so that there is no delay for running containers once the 824 > content is downloaded. This design preserves the same performance for `docker 825 > pull`, `docker push`, and container startup as users expect with 826 > user namespaces disabled. 827 828 ### Starting the daemon with user namespaces enabled 829 830 To enable user namespace support, start the daemon with the 831 `--userns-remap` flag, which accepts values in the following formats: 832 833 - uid 834 - uid:gid 835 - username 836 - username:groupname 837 838 If numeric IDs are provided, translation back to valid user or group names 839 will occur so that the subordinate uid and gid information can be read, given 840 these resources are name-based, not id-based. If the numeric ID information 841 provided does not exist as entries in `/etc/passwd` or `/etc/group`, daemon 842 startup will fail with an error message. 843 844 > **Note:** On Fedora 22, you have to `touch` the `/etc/subuid` and `/etc/subgid` 845 > files to have ranges assigned when users are created. This must be done 846 > *before* the `--userns-remap` option is enabled. Once these files exist, the 847 > daemon can be (re)started and range assignment on user creation works properly. 848 849 *Example: starting with default Docker user management:* 850 851 ```bash 852 $ dockerd --userns-remap=default 853 ``` 854 855 When `default` is provided, Docker will create - or find the existing - user and group 856 named `dockremap`. If the user is created, and the Linux distribution has 857 appropriate support, the `/etc/subuid` and `/etc/subgid` files will be populated 858 with a contiguous 65536 length range of subordinate user and group IDs, starting 859 at an offset based on prior entries in those files. For example, Ubuntu will 860 create the following range, based on an existing user named `user1` already owning 861 the first 65536 range: 862 863 ```bash 864 $ cat /etc/subuid 865 user1:100000:65536 866 dockremap:165536:65536 867 ``` 868 869 If you have a preferred/self-managed user with subordinate ID mappings already 870 configured, you can provide that username or uid to the `--userns-remap` flag. 871 If you have a group that doesn't match the username, you may provide the `gid` 872 or group name as well; otherwise the username will be used as the group name 873 when querying the system for the subordinate group ID range. 874 875 ### Detailed information on `subuid`/`subgid` ranges 876 877 Given potential advanced use of the subordinate ID ranges by power users, the 878 following paragraphs define how the Docker daemon currently uses the range entries 879 found within the subordinate range files. 880 881 The simplest case is that only one contiguous range is defined for the 882 provided user or group. In this case, Docker will use that entire contiguous 883 range for the mapping of host uids and gids to the container process. This 884 means that the first ID in the range will be the remapped root user, and the 885 IDs above that initial ID will map host ID 1 through the end of the range. 886 887 From the example `/etc/subuid` content shown above, the remapped root 888 user would be uid 165536. 889 890 If the system administrator has set up multiple ranges for a single user or 891 group, the Docker daemon will read all the available ranges and use the 892 following algorithm to create the mapping ranges: 893 894 1. The range segments found for the particular user will be sorted by *start ID* ascending. 895 2. Map segments will be created from each range in increasing value with a length matching the length of each segment. Therefore the range segment with the lowest numeric starting value will be equal to the remapped root, and continue up through host uid/gid equal to the range segment length. As an example, if the lowest segment starts at ID 1000 and has a length of 100, then a map of 1000 -> 0 (the remapped root) up through 1100 -> 100 will be created from this segment. If the next segment starts at ID 10000, then the next map will start with mapping 10000 -> 101 up to the length of this second segment. This will continue until no more segments are found in the subordinate files for this user. 896 3. If more than five range segments exist for a single user, only the first five will be utilized, matching the kernel's limitation of only five entries in `/proc/self/uid_map` and `proc/self/gid_map`. 897 898 ### Disable user namespace for a container 899 900 If you enable user namespaces on the daemon, all containers are started 901 with user namespaces enabled. In some situations you might want to disable 902 this feature for a container, for example, to start a privileged container (see 903 [user namespace known restrictions](#user-namespace-known-restrictions)). 904 To enable those advanced features for a specific container use `--userns=host` 905 in the `run/exec/create` command. 906 This option will completely disable user namespace mapping for the container's user. 907 908 ### User namespace known restrictions 909 910 The following standard Docker features are currently incompatible when 911 running a Docker daemon with user namespaces enabled: 912 913 - sharing PID or NET namespaces with the host (`--pid=host` or `--net=host`) 914 - A `--readonly` container filesystem (this is a Linux kernel restriction against remounting with modified flags of a currently mounted filesystem when inside a user namespace) 915 - external (volume or graph) drivers which are unaware/incapable of using daemon user mappings 916 - Using `--privileged` mode flag on `docker run` (unless also specifying `--userns=host`) 917 918 In general, user namespaces are an advanced feature and will require 919 coordination with other capabilities. For example, if volumes are mounted from 920 the host, file ownership will have to be pre-arranged if the user or 921 administrator wishes the containers to have expected access to the volume 922 contents. 923 924 Finally, while the `root` user inside a user namespaced container process has 925 many of the expected admin privileges that go along with being the superuser, the 926 Linux kernel has restrictions based on internal knowledge that this is a user namespaced 927 process. The most notable restriction that we are aware of at this time is the 928 inability to use `mknod`. Permission will be denied for device creation even as 929 container `root` inside a user namespace. 930 931 ## Miscellaneous options 932 933 IP masquerading uses address translation to allow containers without a public 934 IP to talk to other machines on the Internet. This may interfere with some 935 network topologies and can be disabled with `--ip-masq=false`. 936 937 Docker supports softlinks for the Docker data directory (`/var/lib/docker`) and 938 for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be 939 set like this: 940 941 DOCKER_TMPDIR=/mnt/disk2/tmp /usr/local/bin/dockerd -D -g /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1 942 # or 943 export DOCKER_TMPDIR=/mnt/disk2/tmp 944 /usr/local/bin/dockerd -D -g /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1 945 946 ## Default cgroup parent 947 948 The `--cgroup-parent` option allows you to set the default cgroup parent 949 to use for containers. If this option is not set, it defaults to `/docker` for 950 fs cgroup driver and `system.slice` for systemd cgroup driver. 951 952 If the cgroup has a leading forward slash (`/`), the cgroup is created 953 under the root cgroup, otherwise the cgroup is created under the daemon 954 cgroup. 955 956 Assuming the daemon is running in cgroup `daemoncgroup`, 957 `--cgroup-parent=/foobar` creates a cgroup in 958 `/sys/fs/cgroup/memory/foobar`, whereas using `--cgroup-parent=foobar` 959 creates the cgroup in `/sys/fs/cgroup/memory/daemoncgroup/foobar` 960 961 The systemd cgroup driver has different rules for `--cgroup-parent`. Systemd 962 represents hierarchy by slice and the name of the slice encodes the location in 963 the tree. So `--cgroup-parent` for systemd cgroups should be a slice name. A 964 name can consist of a dash-separated series of names, which describes the path 965 to the slice from the root slice. For example, `--cgroup-parent=user-a-b.slice` 966 means the memory cgroup for the container is created in 967 `/sys/fs/cgroup/memory/user.slice/user-a.slice/user-a-b.slice/docker-<id>.scope`. 968 969 This setting can also be set per container, using the `--cgroup-parent` 970 option on `docker create` and `docker run`, and takes precedence over 971 the `--cgroup-parent` option on the daemon. 972 973 ## Daemon configuration file 974 975 The `--config-file` option allows you to set any configuration option 976 for the daemon in a JSON format. This file uses the same flag names as keys, 977 except for flags that allow several entries, where it uses the plural 978 of the flag name, e.g., `labels` for the `label` flag. By default, 979 docker tries to load a configuration file from `/etc/docker/daemon.json` 980 on Linux and `%programdata%\docker\config\daemon.json` on Windows. 981 982 The options set in the configuration file must not conflict with options set 983 via flags. The docker daemon fails to start if an option is duplicated between 984 the file and the flags, regardless their value. We do this to avoid 985 silently ignore changes introduced in configuration reloads. 986 For example, the daemon fails to start if you set daemon labels 987 in the configuration file and also set daemon labels via the `--label` flag. 988 989 Options that are not present in the file are ignored when the daemon starts. 990 This is a full example of the allowed configuration options in the file: 991 992 ```json 993 { 994 "authorization-plugins": [], 995 "dns": [], 996 "dns-opts": [], 997 "dns-search": [], 998 "exec-opts": [], 999 "exec-root": "", 1000 "storage-driver": "", 1001 "storage-opts": [], 1002 "labels": [], 1003 "log-driver": "", 1004 "log-opts": [], 1005 "mtu": 0, 1006 "pidfile": "", 1007 "graph": "", 1008 "cluster-store": "", 1009 "cluster-store-opts": {}, 1010 "cluster-advertise": "", 1011 "max-concurrent-downloads": 3, 1012 "max-concurrent-uploads": 5, 1013 "debug": true, 1014 "hosts": [], 1015 "log-level": "", 1016 "tls": true, 1017 "tlsverify": true, 1018 "tlscacert": "", 1019 "tlscert": "", 1020 "tlskey": "", 1021 "api-cors-header": "", 1022 "selinux-enabled": false, 1023 "userns-remap": "", 1024 "group": "", 1025 "cgroup-parent": "", 1026 "default-ulimits": {}, 1027 "ipv6": false, 1028 "iptables": false, 1029 "ip-forward": false, 1030 "ip-masq": false, 1031 "userland-proxy": false, 1032 "ip": "0.0.0.0", 1033 "bridge": "", 1034 "bip": "", 1035 "fixed-cidr": "", 1036 "fixed-cidr-v6": "", 1037 "default-gateway": "", 1038 "default-gateway-v6": "", 1039 "icc": false, 1040 "raw-logs": false, 1041 "registry-mirrors": [], 1042 "insecure-registries": [], 1043 "disable-legacy-registry": false, 1044 "default-runtime": "runc", 1045 "runtimes": { 1046 "runc": { 1047 "path": "runc" 1048 }, 1049 "custom": { 1050 "path": "/usr/local/bin/my-runc-replacement", 1051 "runtimeArgs": [ 1052 "--debug" 1053 ] 1054 } 1055 } 1056 } 1057 ``` 1058 1059 ### Configuration reloading 1060 1061 Some options can be reconfigured when the daemon is running without requiring 1062 to restart the process. We use the `SIGHUP` signal in Linux to reload, and a global event 1063 in Windows with the key `Global\docker-daemon-config-$PID`. The options can 1064 be modified in the configuration file but still will check for conflicts with 1065 the provided flags. The daemon fails to reconfigure itself 1066 if there are conflicts, but it won't stop execution. 1067 1068 The list of currently supported options that can be reconfigured is this: 1069 1070 - `debug`: it changes the daemon to debug mode when set to true. 1071 - `cluster-store`: it reloads the discovery store with the new address. 1072 - `cluster-store-opts`: it uses the new options to reload the discovery store. 1073 - `cluster-advertise`: it modifies the address advertised after reloading. 1074 - `labels`: it replaces the daemon labels with a new set of labels. 1075 - `max-concurrent-downloads`: it updates the max concurrent downloads for each pull. 1076 - `max-concurrent-uploads`: it updates the max concurrent uploads for each push. 1077 - `default-runtime`: it updates the runtime to be used if not is 1078 specified at container creation. It defaults to "default" which is 1079 the runtime shipped with the official docker packages. 1080 - `runtimes`: it updates the list of available OCI runtimes that can 1081 be used to run containers 1082 1083 Updating and reloading the cluster configurations such as `--cluster-store`, 1084 `--cluster-advertise` and `--cluster-store-opts` will take effect only if 1085 these configurations were not previously configured. If `--cluster-store` 1086 has been provided in flags and `cluster-advertise` not, `cluster-advertise` 1087 can be added in the configuration file without accompanied by `--cluster-store` 1088 Configuration reload will log a warning message if it detects a change in 1089 previously configured cluster configurations. 1090 1091 1092 ## Running multiple daemons 1093 1094 > **Note:** Running multiple daemons on a single host is considered as "experimental". The user should be aware of 1095 > unsolved problems. This solution may not work properly in some cases. Solutions are currently under development 1096 > and will be delivered in the near future. 1097 1098 This section describes how to run multiple Docker daemons on a single host. To 1099 run multiple daemons, you must configure each daemon so that it does not 1100 conflict with other daemons on the same host. You can set these options either 1101 by providing them as flags, or by using a [daemon configuration file](#daemon-configuration-file). 1102 1103 The following daemon options must be configured for each daemon: 1104 1105 ```bash 1106 -b, --bridge= Attach containers to a network bridge 1107 --exec-root=/var/run/docker Root of the Docker execdriver 1108 -g, --graph=/var/lib/docker Root of the Docker runtime 1109 -p, --pidfile=/var/run/docker.pid Path to use for daemon PID file 1110 -H, --host=[] Daemon socket(s) to connect to 1111 --config-file=/etc/docker/daemon.json Daemon configuration file 1112 --tlscacert="~/.docker/ca.pem" Trust certs signed only by this CA 1113 --tlscert="~/.docker/cert.pem" Path to TLS certificate file 1114 --tlskey="~/.docker/key.pem" Path to TLS key file 1115 ``` 1116 1117 When your daemons use different values for these flags, you can run them on the same host without any problems. 1118 It is very important to properly understand the meaning of those options and to use them correctly. 1119 1120 - The `-b, --bridge=` flag is set to `docker0` as default bridge network. It is created automatically when you install Docker. 1121 If you are not using the default, you must create and configure the bridge manually or just set it to 'none': `--bridge=none` 1122 - `--exec-root` is the path where the container state is stored. The default value is `/var/run/docker`. Specify the path for 1123 your running daemon here. 1124 - `--graph` is the path where images are stored. The default value is `/var/lib/docker`. To avoid any conflict with other daemons 1125 set this parameter separately for each daemon. 1126 - `-p, --pidfile=/var/run/docker.pid` is the path where the process ID of the daemon is stored. Specify the path for your 1127 pid file here. 1128 - `--host=[]` specifies where the Docker daemon will listen for client connections. If unspecified, it defaults to `/var/run/docker.sock`. 1129 - `--config-file=/etc/docker/daemon.json` is the path where configuration file is stored. You can use it instead of 1130 daemon flags. Specify the path for each daemon. 1131 - `--tls*` Docker daemon supports `--tlsverify` mode that enforces encrypted and authenticated remote connections. 1132 The `--tls*` options enable use of specific certificates for individual daemons. 1133 1134 Example script for a separate “bootstrap” instance of the Docker daemon without network: 1135 1136 ```bash 1137 $ docker daemon \ 1138 -H unix:///var/run/docker-bootstrap.sock \ 1139 -p /var/run/docker-bootstrap.pid \ 1140 --iptables=false \ 1141 --ip-masq=false \ 1142 --bridge=none \ 1143 --graph=/var/lib/docker-bootstrap \ 1144 --exec-root=/var/run/docker-bootstrap 1145 ```