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