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