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