github.com/ld86/docker@v1.7.1-rc3/docs/reference/commandline/cli.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Command Line Interface"
     4  description = "Docker's CLI command description and usage"
     5  keywords = ["Docker, Docker documentation, CLI,  command line"]
     6  [menu.main]
     7  parent = "mn_reference"
     8  +++
     9  <![end-metadata]-->
    10  
    11  # Docker Command Line
    12  
    13  > **Note:** if you are using a remote Docker daemon, such as Boot2Docker, 
    14  > then _do not_ type the `sudo` before the `docker` commands shown in the
    15  > documentation's examples.
    16  
    17  To list available commands, either run `docker` with no parameters
    18  or execute `docker help`:
    19  
    20      $ docker
    21        Usage: docker [OPTIONS] COMMAND [arg...]
    22          -H, --host=[]: The socket(s) to bind to in daemon mode, specified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.
    23  
    24        A self-sufficient runtime for Linux containers.
    25  
    26        ...
    27  Depending on your Docker system configuration, you may be required
    28  to preface each `docker` command with `sudo`. To avoid having to use `sudo` with
    29  the `docker` command, your system administrator can create a Unix group called
    30  `docker` and add users to it.
    31  
    32  For more information about installing Docker or `sudo` configuration, refer to
    33  the [installation](/installation) instructions for your operating system.
    34  
    35  ## Environment variables
    36  
    37  For easy reference, the following list of environment variables are supported
    38  by the `docker` command line:
    39  
    40  * `DOCKER_CERT_PATH` The location of your authentication keys.
    41  * `DOCKER_DRIVER` The graph driver to use.
    42  * `DOCKER_HOST` Daemon socket to connect to.
    43  * `DOCKER_NOWARN_KERNEL_VERSION` Prevent warnings that your Linux kernel is unsuitable for Docker.
    44  * `DOCKER_RAMDISK` If set this will disable 'pivot_root'.
    45  * `DOCKER_TLS_VERIFY` When set Docker uses TLS and verifies the remote.
    46  * `DOCKER_TMPDIR` Location for temporary Docker files.
    47  
    48  Because Docker is developed using 'Go', you can also use any environment
    49  variables used by the 'Go' runtime. In particular, you may find these useful:
    50  
    51  * `HTTP_PROXY`
    52  * `HTTPS_PROXY`
    53  * `NO_PROXY`
    54  
    55  These Go environment variables are case-insensitive. See the
    56  [Go specification](http://golang.org/pkg/net/http/) for details on these
    57  variables.
    58  
    59  ## Configuration files
    60  
    61  The Docker command line stores its configuration files in a directory called
    62  `.docker` within your `HOME` directory. Docker manages most of the files in
    63  `.docker` and you should not modify them. However, you *can modify* the
    64  `.docker/config.json` file to control certain aspects of how the `docker`
    65  command behaves.
    66  
    67  Currently, you can modify the `docker` command behavior using environment 
    68  variables or command-line options. You can also use options within 
    69  `config.json` to modify some of the same behavior.  When using these 
    70  mechanisms, you must keep in mind the order of precedence among them. Command 
    71  line options override environment variables and environment variables override 
    72  properties you specify in a `config.json` file.
    73  
    74  The `config.json` file stores a JSON encoding of a single `HttpHeaders`
    75  property. The property specifies a set of headers to include in all
    76  messages sent from the Docker client to the daemon. Docker does not try to
    77  interpret or understand these header; it simply puts them into the messages.
    78  Docker does not allow these headers to change any headers it sets for itself.
    79  
    80  Following is a sample `config.json` file:
    81  
    82      {
    83        "HttpHeaders: {
    84          "MyHeader": "MyValue"
    85        }
    86      }
    87  
    88  ## Help
    89  To list the help on any command just execute the command, followed by the `--help` option.
    90  
    91      $ docker run --help
    92  
    93      Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
    94  
    95      Run a command in a new container
    96  
    97        -a, --attach=[]            Attach to STDIN, STDOUT or STDERR
    98        -c, --cpu-shares=0         CPU shares (relative weight)
    99      ...
   100  
   101  ## Option types
   102  
   103  Single character command line options can be combined, so rather than
   104  typing `docker run -i -t --name test busybox sh`,
   105  you can write `docker run -it --name test busybox sh`.
   106  
   107  ### Boolean
   108  
   109  Boolean options take the form `-d=false`. The value you see in the help text is the
   110  default value which is set if you do **not** specify that flag. If you specify
   111  a Boolean flag without a value, this will set the flag to `true`, irrespective
   112  of the default value.
   113  
   114  For example, running `docker run -d` will set the value to `true`, so
   115  your container **will** run in "detached" mode, in the background.
   116  
   117  Options which default to `true` (e.g., `docker build --rm=true`) can only
   118  be set to the non-default value by explicitly setting them to `false`:
   119  
   120      $ docker build --rm=false .
   121  
   122  ### Multi
   123  
   124  You can specify options like `-a=[]` multiple times in a single command line,
   125  for example in these commands:
   126  
   127      $ docker run -a stdin -a stdout -i -t ubuntu /bin/bash
   128      $ docker run -a stdin -a stdout -a stderr ubuntu /bin/ls
   129  
   130  Sometimes, multiple options can call for a more complex value string as for `-v`:
   131  
   132      $ docker run -v /host:/container example/mysql
   133  
   134  > **Note**:
   135  > Do not use the `-t` and `-a stderr` options together due to limitations
   136  > in the `pty` implementation. All `stderr` in `pty` mode simply goes to `stdout`.
   137  
   138  ### Strings and Integers
   139  
   140  Options like `--name=""` expect a string, and they
   141  can only be specified once. Options like `-c=0`
   142  expect an integer, and they can only be specified once.
   143  
   144  ## daemon
   145  
   146      Usage: docker [OPTIONS] COMMAND [arg...]
   147  
   148      A self-sufficient runtime for linux containers.
   149  
   150      Options:
   151        --api-cors-header=""                   Set CORS headers in the remote API
   152        -b, --bridge=""                        Attach containers to a network bridge
   153        --bip=""                               Specify network bridge IP
   154        -D, --debug=false                      Enable debug mode
   155        -d, --daemon=false                     Enable daemon mode
   156        --default-gateway=""                   Container default gateway IPv4 address
   157        --default-gateway-v6=""                Container default gateway IPv6 address
   158        --dns=[]                               DNS server to use
   159        --dns-search=[]                        DNS search domains to use
   160        --default-ulimit=[]                    Set default ulimit settings for containers
   161        -e, --exec-driver="native"             Exec driver to use
   162        --exec-opt=[]                          Set exec driver options
   163        --exec-root="/var/run/docker"          Root of the Docker execdriver
   164        --fixed-cidr=""                        IPv4 subnet for fixed IPs
   165        --fixed-cidr-v6=""                     IPv6 subnet for fixed IPs
   166        -G, --group="docker"                   Group for the unix socket
   167        -g, --graph="/var/lib/docker"          Root of the Docker runtime
   168        -H, --host=[]                          Daemon socket(s) to connect to
   169        -h, --help=false                       Print usage
   170        --icc=true                             Enable inter-container communication
   171        --insecure-registry=[]                 Enable insecure registry communication
   172        --ip=0.0.0.0                           Default IP when binding container ports
   173        --ip-forward=true                      Enable net.ipv4.ip_forward
   174        --ip-masq=true                         Enable IP masquerading
   175        --iptables=true                        Enable addition of iptables rules
   176        --ipv6=false                           Enable IPv6 networking
   177        -l, --log-level="info"                 Set the logging level
   178        --label=[]                             Set key=value labels to the daemon
   179        --log-driver="json-file"               Default driver for container logs
   180        --log-opt=[]                           Log driver specific options
   181        --mtu=0                                Set the containers network MTU
   182        -p, --pidfile="/var/run/docker.pid"    Path to use for daemon PID file
   183        --registry-mirror=[]                   Preferred Docker registry mirror
   184        -s, --storage-driver=""                Storage driver to use
   185        --selinux-enabled=false                Enable selinux support
   186        --storage-opt=[]                       Set storage driver options
   187        --tls=false                            Use TLS; implied by --tlsverify
   188        --tlscacert="~/.docker/ca.pem"         Trust certs signed only by this CA
   189        --tlscert="~/.docker/cert.pem"         Path to TLS certificate file
   190        --tlskey="~/.docker/key.pem"           Path to TLS key file
   191        --tlsverify=false                      Use TLS and verify the remote
   192        --userland-proxy=true                  Use userland proxy for loopback traffic
   193        -v, --version=false                    Print version information and quit
   194  
   195  Options with [] may be specified multiple times.
   196  
   197  The Docker daemon is the persistent process that manages containers.
   198  Docker uses the same binary for both the daemon and client. To run the
   199  daemon you provide the `-d` flag.
   200  
   201  
   202  To run the daemon with debug output, use `docker -d -D`.
   203  
   204  ### Daemon socket option
   205  
   206  The Docker daemon can listen for [Docker Remote API](/reference/api/docker_remote_api/)
   207  requests via three different types of Socket: `unix`, `tcp`, and `fd`.
   208  
   209  By default, a `unix` domain socket (or IPC socket) is created at `/var/run/docker.sock`,
   210  requiring either `root` permission, or `docker` group membership.
   211  
   212  If you need to access the Docker daemon remotely, you need to enable the `tcp`
   213  Socket. Beware that the default setup provides un-encrypted and un-authenticated
   214  direct access to the Docker daemon - and should be secured either using the
   215  [built in HTTPS encrypted socket](/articles/https/), or by putting a secure web
   216  proxy in front of it. You can listen on port `2375` on all network interfaces
   217  with `-H tcp://0.0.0.0:2375`, or on a particular network interface using its IP
   218  address: `-H tcp://192.168.59.103:2375`. It is conventional to use port `2375`
   219  for un-encrypted, and port `2376` for encrypted communication with the daemon.
   220  
   221  > **Note** If you're using an HTTPS encrypted socket, keep in mind that only TLS1.0
   222  > and greater are supported. Protocols SSLv3 and under are not supported anymore
   223  > for security reasons.
   224  
   225  On Systemd based systems, you can communicate with the daemon via
   226  [Systemd socket activation](http://0pointer.de/blog/projects/socket-activation.html), use
   227  `docker -d -H fd://`. Using `fd://` will work perfectly for most setups but
   228  you can also specify individual sockets: `docker -d -H fd://3`. If the
   229  specified socket activated files aren't found, then Docker will exit. You
   230  can find examples of using Systemd socket activation with Docker and
   231  Systemd in the [Docker source tree](
   232  https://github.com/docker/docker/tree/master/contrib/init/systemd/).
   233  
   234  You can configure the Docker daemon to listen to multiple sockets at the same
   235  time using multiple `-H` options:
   236  
   237      # listen using the default unix socket, and on 2 specific IP addresses on this host.
   238      docker -d -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2
   239  
   240  The Docker client will honor the `DOCKER_HOST` environment variable to set
   241  the `-H` flag for the client.
   242  
   243      $ docker -H tcp://0.0.0.0:2375 ps
   244      # or
   245      $ export DOCKER_HOST="tcp://0.0.0.0:2375"
   246      $ docker ps
   247      # both are equal
   248  
   249  Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than the empty
   250  string is equivalent to setting the `--tlsverify` flag. The following are equivalent:
   251  
   252      $ docker --tlsverify ps
   253      # or
   254      $ export DOCKER_TLS_VERIFY=1
   255      $ docker ps
   256  
   257  The Docker client will honor the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`
   258  environment variables (or the lowercase versions thereof). `HTTPS_PROXY` takes
   259  precedence over `HTTP_PROXY`.
   260  
   261  ### Daemon storage-driver option
   262  
   263  The Docker daemon has support for several different image layer storage drivers: `aufs`,
   264  `devicemapper`, `btrfs`, `zfs` and `overlay`.
   265  
   266  The `aufs` driver is the oldest, but is based on a Linux kernel patch-set that
   267  is unlikely to be merged into the main kernel. These are also known to cause some
   268  serious kernel crashes. However, `aufs` is also the only storage driver that allows
   269  containers to share executable and shared library memory, so is a useful choice
   270  when running thousands of containers with the same program or libraries.
   271  
   272  The `devicemapper` driver uses thin provisioning and Copy on Write (CoW)
   273  snapshots. For each devicemapper graph location – typically
   274  `/var/lib/docker/devicemapper` – a thin pool is created based on two block
   275  devices, one for data and one for metadata.  By default, these block devices
   276  are created automatically by using loopback mounts of automatically created
   277  sparse files. Refer to [Storage driver options](#storage-driver-options) below
   278  for a way how to customize this setup.
   279  [~jpetazzo/Resizing Docker containers with the Device Mapper plugin](
   280  http://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/) article
   281  explains how to tune your existing setup without the use of options.
   282  
   283  The `btrfs` driver is very fast for `docker build` - but like `devicemapper` does not
   284  share executable memory between devices. Use `docker -d -s btrfs -g /mnt/btrfs_partition`.
   285  
   286  The `zfs` driver is probably not fast as `btrfs` but has a longer track record
   287  on stability. Thanks to `Single Copy ARC` shared blocks between clones will be
   288  cached only once. Use `docker -d -s zfs`. To select a different zfs filesystem
   289  set `zfs.fsname` option as described in [Storage driver options](#storage-driver-options):
   290  
   291  The `overlay` is a very fast union filesystem. It is now merged in the main
   292  Linux kernel as of [3.18.0](https://lkml.org/lkml/2014/10/26/137).
   293  Call `docker -d -s overlay` to use it.
   294  > **Note:**
   295  > As promising as `overlay` is, the feature is still quite young and should not
   296  > be used in production. Most notably, using `overlay` can cause excessive
   297  > inode consumption (especially as the number of images grows), as well as
   298  > being incompatible with the use of RPMs.
   299  
   300  > **Note:**
   301  > As promising as `overlay` is, the feature is still quite young and should not
   302  > be used in production. Most notably, using `overlay` can cause excessive
   303  > inode consumption (especially as the number of images grows), as well as
   304  > being incompatible with the use of RPMs.
   305  
   306  > **Note:**
   307  > It is currently unsupported on `btrfs` or any Copy on Write filesystem
   308  > and should only be used over `ext4` partitions.
   309  
   310  #### Storage driver options
   311  
   312  Particular storage-driver can be configured with options specified with
   313  `--storage-opt` flags. Options for `devicemapper` are prefixed with `dm` and
   314  options for `zfs` start with `zfs`.
   315  
   316  Currently supported options of `devicemapper`:
   317  
   318   *  `dm.basesize`
   319  
   320      Specifies the size to use when creating the base device, which limits the
   321      size of images and containers. The default value is 10G. Note, thin devices
   322      are inherently "sparse", so a 10G device which is mostly empty doesn't use
   323      10 GB of space on the pool. However, the filesystem will use more space for
   324      the empty case the larger the device is.
   325  
   326       **Warning**: This value affects the system-wide "base" empty filesystem
   327       that may already be initialized and inherited by pulled images. Typically,
   328       a change to this value will require additional steps to take effect:
   329  
   330          $ sudo service docker stop
   331          $ sudo rm -rf /var/lib/docker
   332          $ sudo service docker start
   333  
   334      Example use:
   335  
   336          $ docker -d --storage-opt dm.basesize=20G
   337  
   338   *  `dm.loopdatasize`
   339  
   340      Specifies the size to use when creating the loopback file for the "data"
   341      device which is used for the thin pool. The default size is 100G. Note that
   342      the file is sparse, so it will not initially take up this much space.
   343  
   344      Example use:
   345  
   346          $ docker -d --storage-opt dm.loopdatasize=200G
   347  
   348   *  `dm.loopmetadatasize`
   349  
   350      Specifies the size to use when creating the loopback file for the
   351      "metadata" device which is used for the thin pool. The default size is 2G.
   352      Note that the file is sparse, so it will not initially take up this much
   353      space.
   354  
   355      Example use:
   356  
   357          $ docker -d --storage-opt dm.loopmetadatasize=4G
   358  
   359   *  `dm.fs`
   360  
   361      Specifies the filesystem type to use for the base device. The supported
   362      options are "ext4" and "xfs". The default is "ext4"
   363  
   364      Example use:
   365  
   366          $ docker -d --storage-opt dm.fs=xfs
   367  
   368   *  `dm.mkfsarg`
   369  
   370      Specifies extra mkfs arguments to be used when creating the base device.
   371  
   372      Example use:
   373  
   374          $ docker -d --storage-opt "dm.mkfsarg=-O ^has_journal"
   375  
   376   *  `dm.mountopt`
   377  
   378      Specifies extra mount options used when mounting the thin devices.
   379  
   380      Example use:
   381  
   382          $ docker -d --storage-opt dm.mountopt=nodiscard
   383  
   384   *  `dm.datadev`
   385  
   386      Specifies a custom blockdevice to use for data for the thin pool.
   387  
   388      If using a block device for device mapper storage, ideally both datadev and
   389      metadatadev should be specified to completely avoid using the loopback
   390      device.
   391  
   392      Example use:
   393  
   394          $ docker -d \
   395              --storage-opt dm.datadev=/dev/sdb1 \
   396              --storage-opt dm.metadatadev=/dev/sdc1
   397  
   398   *  `dm.metadatadev`
   399  
   400      Specifies a custom blockdevice to use for metadata for the thin pool.
   401  
   402      For best performance the metadata should be on a different spindle than the
   403      data, or even better on an SSD.
   404  
   405      If setting up a new metadata pool it is required to be valid. This can be
   406      achieved by zeroing the first 4k to indicate empty metadata, like this:
   407  
   408          $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1
   409  
   410      Example use:
   411  
   412          $ docker -d \
   413              --storage-opt dm.datadev=/dev/sdb1 \
   414              --storage-opt dm.metadatadev=/dev/sdc1
   415  
   416   *  `dm.blocksize`
   417  
   418      Specifies a custom blocksize to use for the thin pool. The default
   419      blocksize is 64K.
   420  
   421      Example use:
   422  
   423          $ docker -d --storage-opt dm.blocksize=512K
   424  
   425   *  `dm.blkdiscard`
   426  
   427      Enables or disables the use of blkdiscard when removing devicemapper
   428      devices. This is enabled by default (only) if using loopback devices and is
   429      required to resparsify the loopback file on image/container removal.
   430  
   431      Disabling this on loopback can lead to *much* faster container removal
   432      times, but will make the space used in `/var/lib/docker` directory not be
   433      returned to the system for other use when containers are removed.
   434  
   435      Example use:
   436  
   437          $ docker -d --storage-opt dm.blkdiscard=false
   438  
   439   *  `dm.override_udev_sync_check`
   440  
   441      Overrides the `udev` synchronization checks between `devicemapper` and `udev`.
   442      `udev` is the device manager for the Linux kernel.
   443  
   444      To view the `udev` sync support of a Docker daemon that is using the
   445      `devicemapper` driver, run:
   446  
   447          $ docker info
   448  	[...]
   449  	 Udev Sync Supported: true
   450  	[...]
   451  
   452      When `udev` sync support is `true`, then `devicemapper` and udev can
   453      coordinate the activation and deactivation of devices for containers.
   454  
   455      When `udev` sync support is `false`, a race condition occurs between
   456      the`devicemapper` and `udev` during create and cleanup. The race condition
   457      results in errors and failures. (For information on these failures, see
   458      [docker#4036](https://github.com/docker/docker/issues/4036))
   459  
   460      To allow the `docker` daemon to start, regardless of `udev` sync not being
   461      supported, set `dm.override_udev_sync_check` to true:
   462  
   463          $ docker -d --storage-opt dm.override_udev_sync_check=true
   464  
   465      When this value is `true`, the  `devicemapper` continues and simply warns
   466      you the errors are happening.
   467  
   468      > **Note**: The ideal is to pursue a `docker` daemon and environment that
   469      > does support synchronizing with `udev`. For further discussion on this
   470      > topic, see [docker#4036](https://github.com/docker/docker/issues/4036).
   471      > Otherwise, set this flag for migrating existing Docker daemons to a
   472      > daemon with a supported environment.
   473  
   474  ### Docker execdriver option
   475  Currently supported options of `zfs`:
   476  
   477   * `zfs.fsname`
   478  
   479      Set zfs filesystem under which docker will create its own datasets.
   480      By default docker will pick up the zfs filesystem where docker graph
   481      (`/var/lib/docker`) is located.
   482  
   483      Example use:
   484  
   485         $ docker -d -s zfs --storage-opt zfs.fsname=zroot/docker
   486  
   487  The Docker daemon uses a specifically built `libcontainer` execution driver as its
   488  interface to the Linux kernel `namespaces`, `cgroups`, and `SELinux`.
   489  
   490  There is still legacy support for the original [LXC userspace tools](
   491  https://linuxcontainers.org/) via the `lxc` execution driver, however, this is
   492  not where the primary development of new functionality is taking place.
   493  Add `-e lxc` to the daemon flags to use the `lxc` execution driver.
   494  
   495  #### Options for the native execdriver
   496  
   497  You can configure the `native` (libcontainer) execdriver using options specified
   498  with the `--exec-opt` flag. All the flag's options have the `native` prefix. A
   499  single `native.cgroupdriver` option is available.
   500  
   501  The `native.cgroupdriver` option specifies the management of the container's 
   502  cgroups. You can specify `cgroupfs` or `systemd`. If you specify `systemd` and 
   503  it is not available, the system uses `cgroupfs`. By default, if no option is 
   504  specified, the execdriver first tries `systemd` and falls back to `cgroupfs`. 
   505  This example sets the execdriver to `cgroupfs`:
   506  
   507      $ sudo docker -d --exec-opt native.cgroupdriver=cgroupfs
   508       
   509  Setting this option applies to all containers the daemon launches.
   510  
   511  ### Daemon DNS options
   512  
   513  To set the DNS server for all Docker containers, use
   514  `docker -d --dns 8.8.8.8`.
   515  
   516  To set the DNS search domain for all Docker containers, use
   517  `docker -d --dns-search example.com`.
   518  
   519  ### Insecure registries
   520  
   521  Docker considers a private registry either secure or insecure.
   522  In the rest of this section, *registry* is used for *private registry*, and `myregistry:5000`
   523  is a placeholder example for a private registry.
   524  
   525  A secure registry uses TLS and a copy of its CA certificate is placed on the Docker host at
   526  `/etc/docker/certs.d/myregistry:5000/ca.crt`.
   527  An insecure registry is either not using TLS (i.e., listening on plain text HTTP), or is using
   528  TLS with a CA certificate not known by the Docker daemon. The latter can happen when the
   529  certificate was not found under `/etc/docker/certs.d/myregistry:5000/`, or if the certificate
   530  verification failed (i.e., wrong CA).
   531  
   532  By default, Docker assumes all, but local (see local registries below), registries are secure.
   533  Communicating with an insecure registry is not possible if Docker assumes that registry is secure.
   534  In order to communicate with an insecure registry, the Docker daemon requires `--insecure-registry`
   535  in one of the following two forms:
   536  
   537  * `--insecure-registry myregistry:5000` tells the Docker daemon that myregistry:5000 should be considered insecure.
   538  * `--insecure-registry 10.1.0.0/16` tells the Docker daemon that all registries whose domain resolve to an IP address is part
   539  of the subnet described by the CIDR syntax, should be considered insecure.
   540  
   541  The flag can be used multiple times to allow multiple registries to be marked as insecure.
   542  
   543  If an insecure registry is not marked as insecure, `docker pull`, `docker push`, and `docker search`
   544  will result in an error message prompting the user to either secure or pass the `--insecure-registry`
   545  flag to the Docker daemon as described above.
   546  
   547  Local registries, whose IP address falls in the 127.0.0.0/8 range, are automatically marked as insecure
   548  as of Docker 1.3.2. It is not recommended to rely on this, as it may change in the future.
   549  
   550  ### Running a Docker daemon behind a HTTPS_PROXY
   551  
   552  When running inside a LAN that uses a `HTTPS` proxy, the Docker Hub certificates
   553  will be replaced by the proxy's certificates. These certificates need to be added
   554  to your Docker host's configuration:
   555  
   556  1. Install the `ca-certificates` package for your distribution
   557  2. Ask your network admin for the proxy's CA certificate and append them to
   558     `/etc/pki/tls/certs/ca-bundle.crt`
   559  3. Then start your Docker daemon with `HTTPS_PROXY=http://username:password@proxy:port/ docker -d`.
   560     The `username:` and `password@` are optional - and are only needed if your proxy
   561     is set up to require authentication.
   562  
   563  This will only add the proxy and authentication to the Docker daemon's requests -
   564  your `docker build`s and running containers will need extra configuration to use
   565  the proxy
   566  
   567  ### Default Ulimits
   568  
   569  `--default-ulimit` allows you to set the default `ulimit` options to use for all
   570  containers. It takes the same options as `--ulimit` for `docker run`. If these
   571  defaults are not set, `ulimit` settings will be inherited, if not set on
   572  `docker run`, from the Docker daemon. Any `--ulimit` options passed to
   573  `docker run` will overwrite these defaults.
   574  
   575  ### Miscellaneous options
   576  
   577  IP masquerading uses address translation to allow containers without a public IP to talk
   578  to other machines on the Internet. This may interfere with some network topologies and
   579  can be disabled with --ip-masq=false.
   580  
   581  Docker supports softlinks for the Docker data directory
   582  (`/var/lib/docker`) and for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be set like this:
   583  
   584      DOCKER_TMPDIR=/mnt/disk2/tmp /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1
   585      # or
   586      export DOCKER_TMPDIR=/mnt/disk2/tmp
   587      /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1
   588  
   589  
   590  ## attach
   591  
   592      Usage: docker attach [OPTIONS] CONTAINER
   593  
   594      Attach to a running container
   595  
   596        --no-stdin=false    Do not attach STDIN
   597        --sig-proxy=true    Proxy all received signals to the process
   598  
   599  The `docker attach` command allows you to attach to a running container using
   600  the container's ID or name, either to view its ongoing output or to control it
   601  interactively.  You can attach to the same contained process multiple times
   602  simultaneously, screen sharing style, or quickly view the progress of your
   603  daemonized process.
   604  
   605  You can detach from the container and leave it running with `CTRL-p
   606  CTRL-q` (for a quiet exit) or with `CTRL-c` if `--sig-proxy` is false.
   607  
   608  If `--sig-proxy` is true (the default),`CTRL-c` sends a `SIGINT`
   609  to the container.
   610  
   611  >**Note**: A process running as PID 1 inside a container is treated
   612  >specially by Linux: it ignores any signal with the default action.
   613  >So, the process will not terminate on `SIGINT` or `SIGTERM` unless it is
   614  >coded to do so.
   615  
   616  It is forbidden to redirect the standard input of a `docker attach` command while
   617  attaching to a tty-enabled container (i.e.: launched with `-t`).
   618  
   619  #### Examples
   620  
   621      $ docker run -d --name topdemo ubuntu /usr/bin/top -b
   622      $ docker attach topdemo
   623      top - 02:05:52 up  3:05,  0 users,  load average: 0.01, 0.02, 0.05
   624      Tasks:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
   625      Cpu(s):  0.1%us,  0.2%sy,  0.0%ni, 99.7%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
   626      Mem:    373572k total,   355560k used,    18012k free,    27872k buffers
   627      Swap:   786428k total,        0k used,   786428k free,   221740k cached
   628  
   629      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
   630       1 root      20   0 17200 1116  912 R    0  0.3   0:00.03 top
   631  
   632       top - 02:05:55 up  3:05,  0 users,  load average: 0.01, 0.02, 0.05
   633       Tasks:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
   634       Cpu(s):  0.0%us,  0.2%sy,  0.0%ni, 99.8%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
   635       Mem:    373572k total,   355244k used,    18328k free,    27872k buffers
   636       Swap:   786428k total,        0k used,   786428k free,   221776k cached
   637  
   638         PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
   639             1 root      20   0 17208 1144  932 R    0  0.3   0:00.03 top
   640  
   641  
   642       top - 02:05:58 up  3:06,  0 users,  load average: 0.01, 0.02, 0.05
   643       Tasks:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
   644       Cpu(s):  0.2%us,  0.3%sy,  0.0%ni, 99.5%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
   645       Mem:    373572k total,   355780k used,    17792k free,    27880k buffers
   646       Swap:   786428k total,        0k used,   786428k free,   221776k cached
   647  
   648       PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
   649            1 root      20   0 17208 1144  932 R    0  0.3   0:00.03 top
   650      ^C$
   651      $ echo $?
   652      0
   653      $ docker ps -a | grep topdemo
   654      7998ac8581f9        ubuntu:14.04        "/usr/bin/top -b"   38 seconds ago      Exited (0) 21 seconds ago                          topdemo
   655  
   656  And in this second example, you can see the exit code returned by the `bash` process
   657  is returned by the `docker attach` command to its caller too:
   658  
   659      $ docker run --name test -d -it debian
   660      275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab
   661      $ docker attach test
   662      $$ exit 13
   663      exit
   664      $ echo $?
   665      13
   666      $ docker ps -a | grep test
   667      275c44472aeb        debian:7            "/bin/bash"         26 seconds ago      Exited (13) 17 seconds ago                         test
   668  
   669  ## build
   670  
   671      Usage: docker build [OPTIONS] PATH | URL | -
   672  
   673      Build a new image from the source code at PATH
   674  
   675        -f, --file=""            Name of the Dockerfile (Default is 'PATH/Dockerfile')
   676        --force-rm=false         Always remove intermediate containers
   677        --no-cache=false         Do not use cache when building the image
   678        --pull=false             Always attempt to pull a newer version of the image
   679        -q, --quiet=false        Suppress the verbose output generated by the containers
   680        --rm=true                Remove intermediate containers after a successful build
   681        -t, --tag=""             Repository name (and optionally a tag) for the image
   682        -m, --memory=""          Memory limit for all build containers
   683        --memory-swap=""         Total memory (memory + swap), `-1` to disable swap
   684        -c, --cpu-shares         CPU Shares (relative weight)
   685        --cpuset-mems=""         MEMs in which to allow execution, e.g. `0-3`, `0,1`
   686        --cpuset-cpus=""         CPUs in which to allow exection, e.g. `0-3`, `0,1`
   687        --cgroup-parent=""       Optional parent cgroup for the container
   688  
   689  Builds Docker images from a Dockerfile and a "context". A build's context is
   690  the files located in the specified `PATH` or `URL`.  The build process can
   691  refer to any of the files in the context. For example, your build can use
   692  an [*ADD*](/reference/builder/#add) instruction to reference a file in the
   693  context.
   694  
   695  The `URL` parameter can specify the location of a Git repository;
   696  the repository acts as the build context. The system recursively clones the repository
   697  and its submodules using a `git clone --depth 1 --recursive` command.
   698  This command runs in a temporary directory on your local host.
   699  After the command succeeds, the directory is sent to the Docker daemon as the context.
   700  Local clones give you the ability to access private repositories using
   701  local user credentials, VPN's, and so forth.
   702  
   703  Git URLs accept context configuration in their fragment section, separated by a colon `:`.
   704  The first part represents the reference that Git will check out, this can be either
   705  a branch, a tag, or a commit SHA. The second part represents a subdirectory
   706  inside the repository that will be used as a build context.
   707  
   708  For example, run this command to use a directory called `docker` in the branch `container`:
   709  
   710        $ docker build https://github.com/docker/rootfs.git#container:docker
   711  
   712  The following table represents all the valid suffixes with their build contexts:
   713  
   714  Build Syntax Suffix | Commit Used | Build Context Used
   715  --------------------|-------------|-------------------
   716  `myrepo.git` | `refs/heads/master` | `/`
   717  `myrepo.git#mytag` | `refs/tags/mytag` | `/`
   718  `myrepo.git#mybranch` | `refs/heads/mybranch` | `/`
   719  `myrepo.git#abcdef` | `sha1 = abcdef` | `/`
   720  `myrepo.git#:myfolder` | `refs/heads/master` | `/myfolder`
   721  `myrepo.git#master:myfolder` | `refs/heads/master` | `/myfolder`
   722  `myrepo.git#mytag:myfolder` | `refs/tags/mytag` | `/myfolder`
   723  `myrepo.git#mybranch:myfolder` | `refs/heads/mybranch` | `/myfolder`
   724  `myrepo.git#abcdef:myfolder` | `sha1 = abcdef` | `/myfolder`
   725  
   726  Instead of specifying a context, you can pass a single Dockerfile in the
   727  `URL` or pipe the file in via `STDIN`.  To pipe a Dockerfile from `STDIN`:
   728  
   729  	docker build - < Dockerfile
   730  
   731  If you use STDIN or specify a `URL`, the system places the contents into a
   732  file called `Dockerfile`, and any `-f`, `--file` option is ignored. In this
   733  scenario, there is no context.
   734  
   735  By default the `docker build` command will look for a `Dockerfile` at the
   736  root of the build context. The `-f`, `--file`, option lets you specify
   737  the path to an alternative file to use instead.  This is useful
   738  in cases where the same set of files are used for multiple builds. The path
   739  must be to a file within the build context. If a relative path is specified
   740  then it must to be relative to the current directory.
   741  
   742  In most cases, it's best to put each Dockerfile in an empty directory. Then, add
   743  to that directory only the files needed for building the Dockerfile. To increase
   744  the build's performance, you can exclude files and directories by adding a
   745  `.dockerignore` file to that directory as well. For information on creating one,
   746  see the [.dockerignore file](../../reference/builder/#dockerignore-file).
   747  
   748  If the Docker client loses connection to the daemon, the build is canceled.
   749  This happens if you interrupt the Docker client with `ctrl-c` or if the Docker
   750  client is killed for any reason.
   751  
   752  > **Note:** Currently only the "run" phase of the build can be canceled until
   753  > pull cancelation is implemented).
   754  
   755  ### Return code
   756  
   757  On a successful build, a return code of success `0` will be returned.
   758  When the build fails, a non-zero failure code will be returned.
   759  
   760  There should be informational output of the reason for failure output
   761  to `STDERR`:
   762  
   763  ```
   764  $ docker build -t fail .
   765  Sending build context to Docker daemon 2.048 kB
   766  Sending build context to Docker daemon
   767  Step 0 : FROM busybox
   768   ---> 4986bf8c1536
   769  Step 1 : RUN exit 13
   770   ---> Running in e26670ec7a0a
   771  INFO[0000] The command [/bin/sh -c exit 13] returned a non-zero code: 13
   772  $ echo $?
   773  1
   774  ```
   775  See also:
   776  
   777  [*Dockerfile Reference*](/reference/builder).
   778  
   779  ### Examples
   780  
   781      $ docker build .
   782      Uploading context 10240 bytes
   783      Step 1 : FROM busybox
   784      Pulling repository busybox
   785       ---> e9aa60c60128MB/2.284 MB (100%) endpoint: https://cdn-registry-1.docker.io/v1/
   786      Step 2 : RUN ls -lh /
   787       ---> Running in 9c9e81692ae9
   788      total 24
   789      drwxr-xr-x    2 root     root        4.0K Mar 12  2013 bin
   790      drwxr-xr-x    5 root     root        4.0K Oct 19 00:19 dev
   791      drwxr-xr-x    2 root     root        4.0K Oct 19 00:19 etc
   792      drwxr-xr-x    2 root     root        4.0K Nov 15 23:34 lib
   793      lrwxrwxrwx    1 root     root           3 Mar 12  2013 lib64 -> lib
   794      dr-xr-xr-x  116 root     root           0 Nov 15 23:34 proc
   795      lrwxrwxrwx    1 root     root           3 Mar 12  2013 sbin -> bin
   796      dr-xr-xr-x   13 root     root           0 Nov 15 23:34 sys
   797      drwxr-xr-x    2 root     root        4.0K Mar 12  2013 tmp
   798      drwxr-xr-x    2 root     root        4.0K Nov 15 23:34 usr
   799       ---> b35f4035db3f
   800      Step 3 : CMD echo Hello world
   801       ---> Running in 02071fceb21b
   802       ---> f52f38b7823e
   803      Successfully built f52f38b7823e
   804      Removing intermediate container 9c9e81692ae9
   805      Removing intermediate container 02071fceb21b
   806  
   807  This example specifies that the `PATH` is
   808  `.`, and so all the files in the local directory get
   809  `tar`d and sent to the Docker daemon. The `PATH`
   810  specifies where to find the files for the "context" of the build on the
   811  Docker daemon. Remember that the daemon could be running on a remote
   812  machine and that no parsing of the Dockerfile
   813  happens at the client side (where you're running
   814  `docker build`). That means that *all* the files at
   815  `PATH` get sent, not just the ones listed to
   816  [*ADD*](/reference/builder/#add) in the Dockerfile.
   817  
   818  The transfer of context from the local machine to the Docker daemon is
   819  what the `docker` client means when you see the
   820  "Sending build context" message.
   821  
   822  If you wish to keep the intermediate containers after the build is
   823  complete, you must use `--rm=false`. This does not
   824  affect the build cache.
   825  
   826      $ docker build .
   827      Uploading context 18.829 MB
   828      Uploading context
   829      Step 0 : FROM busybox
   830       ---> 769b9341d937
   831      Step 1 : CMD echo Hello world
   832       ---> Using cache
   833       ---> 99cc1ad10469
   834      Successfully built 99cc1ad10469
   835      $ echo ".git" > .dockerignore
   836      $ docker build .
   837      Uploading context  6.76 MB
   838      Uploading context
   839      Step 0 : FROM busybox
   840       ---> 769b9341d937
   841      Step 1 : CMD echo Hello world
   842       ---> Using cache
   843       ---> 99cc1ad10469
   844      Successfully built 99cc1ad10469
   845  
   846  This example shows the use of the `.dockerignore` file to exclude the `.git`
   847  directory from the context. Its effect can be seen in the changed size of the
   848  uploaded context. The builder reference contains detailed information on
   849  [creating a .dockerignore file](../../builder/#dockerignore-file)
   850  
   851      $ docker build -t vieux/apache:2.0 .
   852  
   853  This will build like the previous example, but it will then tag the
   854  resulting image. The repository name will be `vieux/apache`
   855  and the tag will be `2.0`
   856  
   857      $ docker build - < Dockerfile
   858  
   859  This will read a Dockerfile from `STDIN` without context. Due to the
   860  lack of a context, no contents of any local directory will be sent to
   861  the Docker daemon. Since there is no context, a Dockerfile `ADD` only
   862  works if it refers to a remote URL.
   863  
   864      $ docker build - < context.tar.gz
   865  
   866  This will build an image for a compressed context read from `STDIN`.
   867  Supported formats are: bzip2, gzip and xz.
   868  
   869      $ docker build github.com/creack/docker-firefox
   870  
   871  This will clone the GitHub repository and use the cloned repository as
   872  context. The Dockerfile at the root of the
   873  repository is used as Dockerfile. Note that you
   874  can specify an arbitrary Git repository by using the `git://` or `git@`
   875  schema.
   876  
   877      $ docker build -f Dockerfile.debug .
   878  
   879  This will use a file called `Dockerfile.debug` for the build
   880  instructions instead of `Dockerfile`.
   881  
   882      $ docker build -f dockerfiles/Dockerfile.debug -t myapp_debug .
   883      $ docker build -f dockerfiles/Dockerfile.prod  -t myapp_prod .
   884  
   885  The above commands will build the current build context (as specified by
   886  the `.`) twice, once using a debug version of a `Dockerfile` and once using
   887  a production version.
   888  
   889      $ cd /home/me/myapp/some/dir/really/deep
   890      $ docker build -f /home/me/myapp/dockerfiles/debug /home/me/myapp
   891      $ docker build -f ../../../../dockerfiles/debug /home/me/myapp
   892  
   893  These two `docker build` commands do the exact same thing. They both
   894  use the contents of the `debug` file instead of looking for a `Dockerfile`
   895  and will use `/home/me/myapp` as the root of the build context. Note that
   896  `debug` is in the directory structure of the build context, regardless of how
   897  you refer to it on the command line.
   898  
   899  > **Note:** `docker build` will return a `no such file or directory` error
   900  > if the file or directory does not exist in the uploaded context. This may
   901  > happen if there is no context, or if you specify a file that is elsewhere
   902  > on the Host system. The context is limited to the current directory (and its
   903  > children) for security reasons, and to ensure repeatable builds on remote
   904  > Docker hosts. This is also the reason why `ADD ../file` will not work.
   905  
   906  When `docker build` is run with the `--cgroup-parent` option the containers used
   907  in the build will be run with the [corresponding `docker run`
   908  flag](/reference/run/#specifying-custom-cgroups). 
   909  
   910  
   911  ## commit
   912  
   913      Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
   914  
   915      Create a new image from a container's changes
   916  
   917        -a, --author=""     Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
   918        -c, --change=[]     Apply specified Dockerfile instructions while committing the image
   919        -m, --message=""    Commit message
   920        -p, --pause=true    Pause container during commit
   921  
   922  It can be useful to commit a container's file changes or settings into a
   923  new image. This allows you debug a container by running an interactive
   924  shell, or to export a working dataset to another server. Generally, it
   925  is better to use Dockerfiles to manage your images in a documented and
   926  maintainable way.
   927  
   928  By default, the container being committed and its processes will be paused
   929  while the image is committed. This reduces the likelihood of
   930  encountering data corruption during the process of creating the commit.
   931  If this behavior is undesired, set the 'p' option to false.
   932  
   933  The `--change` option will apply `Dockerfile` instructions to the image
   934  that is created.
   935  Supported `Dockerfile` instructions:
   936  `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
   937  
   938  #### Commit a container
   939  
   940      $ docker ps
   941      ID                  IMAGE               COMMAND             CREATED             STATUS              PORTS
   942      c3f279d17e0a        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
   943      197387f1b436        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
   944      $ docker commit c3f279d17e0a  SvenDowideit/testimage:version3
   945      f5283438590d
   946      $ docker images
   947      REPOSITORY                        TAG                 ID                  CREATED             VIRTUAL SIZE
   948      SvenDowideit/testimage            version3            f5283438590d        16 seconds ago      335.7 MB
   949  
   950  #### Commit a container with new configurations
   951  
   952      $ docker ps
   953      ID                  IMAGE               COMMAND             CREATED             STATUS              PORTS
   954      c3f279d17e0a        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
   955      197387f1b436        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
   956      $ docker inspect -f "{{ .Config.Env }}" c3f279d17e0a
   957      [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin]
   958      $ docker commit --change "ENV DEBUG true" c3f279d17e0a  SvenDowideit/testimage:version3
   959      f5283438590d
   960      $ docker inspect -f "{{ .Config.Env }}" f5283438590d
   961      [HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true]
   962  
   963  ## cp
   964  
   965  Copy files or folders from a container's filesystem to the directory on the
   966  host.  Use '-' to write the data as a tar file to `STDOUT`. `CONTAINER:PATH` is
   967  relative to the root of the container's filesystem.
   968  
   969      Usage: docker cp CONTAINER:PATH HOSTDIR|-
   970  
   971      Copy files/folders from the PATH to the HOSTDIR.
   972  
   973  
   974  ## create
   975  
   976  Creates a new container.
   977  
   978      Usage: docker create [OPTIONS] IMAGE [COMMAND] [ARG...]
   979  
   980      Create a new container
   981  
   982        -a, --attach=[]            Attach to STDIN, STDOUT or STDERR
   983        --add-host=[]              Add a custom host-to-IP mapping (host:ip)
   984        --blkio-weight=0           Block IO weight (relative weight)
   985        -c, --cpu-shares=0         CPU shares (relative weight)
   986        --cap-add=[]               Add Linux capabilities
   987        --cap-drop=[]              Drop Linux capabilities
   988        --cgroup-parent=""         Optional parent cgroup for the container
   989        --cidfile=""               Write the container ID to the file
   990        --cpuset-cpus=""           CPUs in which to allow execution (0-3, 0,1)
   991        --cpuset-mems=""           Memory nodes (MEMs) in which to allow execution (0-3, 0,1)
   992        --cpu-period=0             Limit the CPU CFS (Completely Fair Scheduler) period
   993        --cpu-quota=0              Limit the CPU CFS (Completely Fair Scheduler) quota
   994        --device=[]                Add a host device to the container
   995        --dns=[]                   Set custom DNS servers
   996        --dns-search=[]            Set custom DNS search domains
   997        -e, --env=[]               Set environment variables
   998        --entrypoint=""            Overwrite the default ENTRYPOINT of the image
   999        --env-file=[]              Read in a file of environment variables
  1000        --expose=[]                Expose a port or a range of ports
  1001        -h, --hostname=""          Container host name
  1002        -i, --interactive=false    Keep STDIN open even if not attached
  1003        --ipc=""                   IPC namespace to use
  1004        -l, --label=[]             Set metadata on the container (e.g., --label=com.example.key=value)
  1005        --label-file=[]            Read in a line delimited file of labels
  1006        --link=[]                  Add link to another container
  1007        --log-driver=""            Logging driver for container
  1008        --log-opt=[]               Log driver specific options
  1009        --lxc-conf=[]              Add custom lxc options
  1010        -m, --memory=""            Memory limit
  1011        --mac-address=""           Container MAC address (e.g. 92:d0:c6:0a:29:33)
  1012        --name=""                  Assign a name to the container
  1013        --net="bridge"             Set the Network mode for the container
  1014        --oom-kill-disable=false   Whether to disable OOM Killer for the container or not
  1015        -P, --publish-all=false    Publish all exposed ports to random ports
  1016        -p, --publish=[]           Publish a container's port(s) to the host
  1017        --pid=""                   PID namespace to use
  1018        --uts=""                   UTS namespace to use
  1019        --privileged=false         Give extended privileges to this container
  1020        --read-only=false          Mount the container's root filesystem as read only
  1021        --restart="no"             Restart policy (no, on-failure[:max-retry], always)
  1022        --security-opt=[]          Security options
  1023        -t, --tty=false            Allocate a pseudo-TTY
  1024        -u, --user=""              Username or UID
  1025        -v, --volume=[]            Bind mount a volume
  1026        --volumes-from=[]          Mount volumes from the specified container(s)
  1027        -w, --workdir=""           Working directory inside the container
  1028  
  1029  The `docker create` command creates a writeable container layer over
  1030  the specified image and prepares it for running the specified command.
  1031  The container ID is then printed to `STDOUT`.
  1032  This is similar to `docker run -d` except the container is never started.
  1033  You can then use the `docker start <container_id>` command to start the
  1034  container at any point.
  1035  
  1036  This is useful when you want to set up a container configuration ahead
  1037  of time so that it is ready to start when you need it.
  1038  
  1039  Please see the [run command](#run) section and the [Docker run reference](
  1040  /reference/run/) for more details.
  1041  
  1042  #### Examples
  1043  
  1044      $ docker create -t -i fedora bash
  1045      6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752
  1046      $ docker start -a -i 6d8af538ec5
  1047      bash-4.2#
  1048  
  1049  As of v1.4.0 container volumes are initialized during the `docker create`
  1050  phase (i.e., `docker run` too). For example, this allows you to `create` the
  1051  `data` volume container, and then use it from another container:
  1052  
  1053      $ docker create -v /data --name data ubuntu
  1054      240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57
  1055      $ docker run --rm --volumes-from data ubuntu ls -la /data
  1056      total 8
  1057      drwxr-xr-x  2 root root 4096 Dec  5 04:10 .
  1058      drwxr-xr-x 48 root root 4096 Dec  5 04:11 ..
  1059  
  1060  Similarly, `create` a host directory bind mounted volume container, which
  1061  can then be used from the subsequent container:
  1062  
  1063      $ docker create -v /home/docker:/docker --name docker ubuntu
  1064      9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03
  1065      $ docker run --rm --volumes-from docker ubuntu ls -la /docker
  1066      total 20
  1067      drwxr-sr-x  5 1000 staff  180 Dec  5 04:00 .
  1068      drwxr-xr-x 48 root root  4096 Dec  5 04:13 ..
  1069      -rw-rw-r--  1 1000 staff 3833 Dec  5 04:01 .ash_history
  1070      -rw-r--r--  1 1000 staff  446 Nov 28 11:51 .ashrc
  1071      -rw-r--r--  1 1000 staff   25 Dec  5 04:00 .gitconfig
  1072      drwxr-sr-x  3 1000 staff   60 Dec  1 03:28 .local
  1073      -rw-r--r--  1 1000 staff  920 Nov 28 11:51 .profile
  1074      drwx--S---  2 1000 staff  460 Dec  5 00:51 .ssh
  1075      drwxr-xr-x 32 1000 staff 1140 Dec  5 04:01 docker
  1076  
  1077  
  1078  ## diff
  1079  
  1080  List the changed files and directories in a container᾿s filesystem
  1081  
  1082      Usage: docker diff CONTAINER
  1083  
  1084      Inspect changes on a container's filesystem
  1085  
  1086  There are 3 events that are listed in the `diff`:
  1087  
  1088  1.  `A` - Add
  1089  2.  `D` - Delete
  1090  3.  `C` - Change
  1091  
  1092  For example:
  1093  
  1094      $ docker diff 7bb0e258aefe
  1095  
  1096      C /dev
  1097      A /dev/kmsg
  1098      C /etc
  1099      A /etc/mtab
  1100      A /go
  1101      A /go/src
  1102      A /go/src/github.com
  1103      A /go/src/github.com/docker
  1104      A /go/src/github.com/docker/docker
  1105      A /go/src/github.com/docker/docker/.git
  1106      ....
  1107  
  1108  ## events
  1109  
  1110      Usage: docker events [OPTIONS]
  1111  
  1112      Get real time events from the server
  1113  
  1114        -f, --filter=[]    Filter output based on conditions provided
  1115        --since=""         Show all events created since timestamp
  1116        --until=""         Stream events until this timestamp
  1117  
  1118  Docker containers will report the following events:
  1119  
  1120      create, destroy, die, export, kill, oom, pause, restart, start, stop, unpause
  1121  
  1122  and Docker images will report:
  1123  
  1124      untag, delete
  1125  
  1126  If you do not provide the --since option, the command
  1127  returns only new and/or live events.
  1128  
  1129  #### Filtering
  1130  
  1131  The filtering flag (`-f` or `--filter`) format is of "key=value". If you would like to use
  1132  multiple filters, pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
  1133  
  1134  Using the same filter multiple times will be handled as a *OR*; for example
  1135  `--filter container=588a23dac085 --filter container=a8f7720b8c22` will display events for
  1136  container 588a23dac085 *OR* container a8f7720b8c22
  1137  
  1138  Using multiple filters will be handled as a *AND*; for example
  1139  `--filter container=588a23dac085 --filter event=start` will display events for container
  1140  container 588a23dac085 *AND* the event type is *start*
  1141  
  1142  The currently supported filters are:
  1143  
  1144  * container
  1145  * event
  1146  * image
  1147  
  1148  #### Examples
  1149  
  1150  You'll need two shells for this example.
  1151  
  1152  **Shell 1: Listening for events:**
  1153  
  1154      $ docker events
  1155  
  1156  **Shell 2: Start and Stop containers:**
  1157  
  1158      $ docker start 4386fb97867d
  1159      $ docker stop 4386fb97867d
  1160      $ docker stop 7805c1d35632
  1161  
  1162  **Shell 1: (Again .. now showing events):**
  1163  
  1164      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start
  1165      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
  1166      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
  1167      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
  1168      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
  1169  
  1170  **Show events in the past from a specified time:**
  1171  
  1172      $ docker events --since 1378216169
  1173      2014-03-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
  1174      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
  1175      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
  1176      2014-03-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
  1177  
  1178      $ docker events --since '2013-09-03'
  1179      2014-09-03T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start
  1180      2014-09-03T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
  1181      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
  1182      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
  1183      2014-09-03T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
  1184  
  1185      $ docker events --since '2013-09-03T15:49:29'
  1186      2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
  1187      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
  1188      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
  1189      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
  1190  
  1191  **Filter events:**
  1192  
  1193      $ docker events --filter 'event=stop'
  1194      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
  1195      2014-09-03T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
  1196  
  1197      $ docker events --filter 'image=ubuntu-1:14.04'
  1198      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start
  1199      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
  1200      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
  1201  
  1202      $ docker events --filter 'container=7805c1d35632'
  1203      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
  1204      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
  1205  
  1206      $ docker events --filter 'container=7805c1d35632' --filter 'container=4386fb97867d'
  1207      2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
  1208      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
  1209      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
  1210      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
  1211  
  1212      $ docker events --filter 'container=7805c1d35632' --filter 'event=stop'
  1213      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
  1214  
  1215      $ docker events --filter 'container=container_1' --filter 'container=container_2'
  1216      2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
  1217      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
  1218      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
  1219      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
  1220  
  1221  ## exec
  1222  
  1223      Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
  1224  
  1225      Run a command in a running container
  1226  
  1227        -d, --detach=false         Detached mode: run command in the background
  1228        -i, --interactive=false    Keep STDIN open even if not attached
  1229        -t, --tty=false            Allocate a pseudo-TTY
  1230        -u, --user=                Username or UID (format: <name|uid>[:<group|gid>])
  1231  
  1232  The `docker exec` command runs a new command in a running container.
  1233  
  1234  The command started using `docker exec` only runs while the container's primary
  1235  process (`PID 1`) is running, and it is not restarted if the container is restarted.
  1236  
  1237  If the container is paused, then the `docker exec` command will fail with an error:
  1238  
  1239      $ docker pause test
  1240      test
  1241      $ docker ps
  1242      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                   PORTS               NAMES
  1243      1ae3b36715d2        ubuntu:latest       "bash"              17 seconds ago      Up 16 seconds (Paused)                       test
  1244      $ docker exec test ls
  1245      FATA[0000] Error response from daemon: Container test is paused, unpause the container before exec
  1246      $ echo $?
  1247      1
  1248  
  1249  #### Examples
  1250  
  1251      $ docker run --name ubuntu_bash --rm -i -t ubuntu bash
  1252  
  1253  This will create a container named `ubuntu_bash` and start a Bash session.
  1254  
  1255      $ docker exec -d ubuntu_bash touch /tmp/execWorks
  1256  
  1257  This will create a new file `/tmp/execWorks` inside the running container
  1258  `ubuntu_bash`, in the background.
  1259  
  1260      $ docker exec -it ubuntu_bash bash
  1261  
  1262  This will create a new Bash session in the container `ubuntu_bash`.
  1263  
  1264  ## export
  1265  
  1266      Usage: docker export [OPTIONS] CONTAINER
  1267  
  1268      Export the contents of a filesystem to a tar archive (streamed to STDOUT by default)
  1269  
  1270        -o, --output=""    Write to a file, instead of STDOUT
  1271  
  1272        Produces a tarred repository to the standard output stream.
  1273  
  1274     For example:
  1275  
  1276      $ docker export red_panda > latest.tar
  1277  
  1278     Or
  1279  
  1280      $ docker export --output="latest.tar" red_panda
  1281  
  1282  > **Note:**
  1283  > `docker export` does not export the contents of volumes associated with the
  1284  > container. If a volume is mounted on top of an existing directory in the
  1285  > container, `docker export` will export the contents of the *underlying*
  1286  > directory, not the contents of the volume.
  1287  >
  1288  > Refer to [Backup, restore, or migrate data volumes](/userguide/dockervolumes/#backup-restore-or-migrate-data-volumes)
  1289  > in the user guide for examples on exporting data in a volume.
  1290  
  1291  ## history
  1292  
  1293      Usage: docker history [OPTIONS] IMAGE
  1294  
  1295      Show the history of an image
  1296  
  1297        -H, --human=true     Print sizes and dates in human readable format
  1298        --no-trunc=false     Don't truncate output
  1299        -q, --quiet=false    Only show numeric IDs
  1300  
  1301  To see how the `docker:latest` image was built:
  1302  
  1303      $ docker history docker
  1304      IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
  1305      3e23a5875458        8 days ago          /bin/sh -c #(nop) ENV LC_ALL=C.UTF-8            0 B
  1306      8578938dd170        8 days ago          /bin/sh -c dpkg-reconfigure locales &&    loc   1.245 MB
  1307      be51b77efb42        8 days ago          /bin/sh -c apt-get update && apt-get install    338.3 MB
  1308      4b137612be55        6 weeks ago         /bin/sh -c #(nop) ADD jessie.tar.xz in /        121 MB
  1309      750d58736b4b        6 weeks ago         /bin/sh -c #(nop) MAINTAINER Tianon Gravi <ad   0 B
  1310      511136ea3c5a        9 months ago                                                        0 B                 Imported from -
  1311  
  1312  To see how the `docker:apache` image was added to a container's base image:
  1313  
  1314      $ docker history docker:scm
  1315      IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
  1316      2ac9d1098bf1        3 months ago        /bin/bash                                       241.4 MB            Added Apache to Fedora base image
  1317      88b42ffd1f7c        5 months ago        /bin/sh -c #(nop) ADD file:1fd8d7f9f6557cafc7   373.7 MB            
  1318      c69cab00d6ef        5 months ago        /bin/sh -c #(nop) MAINTAINER Lokesh Mandvekar   0 B                 
  1319      511136ea3c5a        19 months ago                                                       0 B                 Imported from -
  1320  
  1321  
  1322  ## images
  1323  
  1324      Usage: docker images [OPTIONS] [REPOSITORY]
  1325  
  1326      List images
  1327  
  1328        -a, --all=false      Show all images (default hides intermediate images)
  1329        --digests=false      Show digests
  1330        -f, --filter=[]      Filter output based on conditions provided
  1331        --help=false         Print usage
  1332        --no-trunc=false     Don't truncate output
  1333        -q, --quiet=false    Only show numeric IDs
  1334  
  1335  The default `docker images` will show all top level
  1336  images, their repository and tags, and their virtual size.
  1337  
  1338  Docker images have intermediate layers that increase reusability,
  1339  decrease disk usage, and speed up `docker build` by
  1340  allowing each step to be cached. These intermediate layers are not shown
  1341  by default.
  1342  
  1343  The `VIRTUAL SIZE` is the cumulative space taken up by the image and all
  1344  its parent images. This is also the disk space used by the contents of the
  1345  Tar file created when you `docker save` an image.
  1346  
  1347  An image will be listed more than once if it has multiple repository names
  1348  or tags. This single image (identifiable by its matching `IMAGE ID`)
  1349  uses up the `VIRTUAL SIZE` listed only once.
  1350  
  1351  #### Listing the most recently created images
  1352  
  1353      $ docker images
  1354      REPOSITORY                TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
  1355      <none>                    <none>              77af4d6b9913        19 hours ago        1.089 GB
  1356      committ                   latest              b6fa739cedf5        19 hours ago        1.089 GB
  1357      <none>                    <none>              78a85c484f71        19 hours ago        1.089 GB
  1358      docker                    latest              30557a29d5ab        20 hours ago        1.089 GB
  1359      <none>                    <none>              5ed6274db6ce        24 hours ago        1.089 GB
  1360      postgres                  9                   746b819f315e        4 days ago          213.4 MB
  1361      postgres                  9.3                 746b819f315e        4 days ago          213.4 MB
  1362      postgres                  9.3.5               746b819f315e        4 days ago          213.4 MB
  1363      postgres                  latest              746b819f315e        4 days ago          213.4 MB
  1364  
  1365  
  1366  #### Listing the full length image IDs
  1367  
  1368      $ docker images --no-trunc
  1369      REPOSITORY                    TAG                 IMAGE ID                                                           CREATED             VIRTUAL SIZE
  1370      <none>                        <none>              77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182   19 hours ago        1.089 GB
  1371      committest                    latest              b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f   19 hours ago        1.089 GB
  1372      <none>                        <none>              78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921   19 hours ago        1.089 GB
  1373      docker                        latest              30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4   20 hours ago        1.089 GB
  1374      <none>                        <none>              0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5   20 hours ago        1.089 GB
  1375      <none>                        <none>              18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b   22 hours ago        1.082 GB
  1376      <none>                        <none>              f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a   23 hours ago        1.089 GB
  1377      tryout                        latest              2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074   23 hours ago        131.5 MB
  1378      <none>                        <none>              5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df   24 hours ago        1.089 GB
  1379  
  1380  #### Listing image digests
  1381  
  1382  Images that use the v2 or later format have a content-addressable identifier
  1383  called a `digest`. As long as the input used to generate the image is
  1384  unchanged, the digest value is predictable. To list image digest values, use
  1385  the `--digests` flag:
  1386  
  1387      $ docker images --digests
  1388      REPOSITORY                         TAG                 DIGEST                                                                    IMAGE ID            CREATED             VIRTUAL SIZE
  1389      localhost:5000/test/busybox        <none>              sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf   4986bf8c1536        9 weeks ago         2.43 MB
  1390  
  1391  When pushing or pulling to a 2.0 registry, the `push` or `pull` command
  1392  output includes the image digest. You can `pull` using a digest value. You can
  1393  also reference by digest in `create`, `run`, and `rmi` commands, as well as the
  1394  `FROM` image reference in a Dockerfile.
  1395  
  1396  #### Filtering
  1397  
  1398  The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
  1399  than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
  1400  
  1401  The currently supported filters are:
  1402  
  1403  * dangling (boolean - true or false)
  1404  * label (`label=<key>` or `label=<key>=<value>`)
  1405  
  1406  ##### Untagged images
  1407  
  1408      $ docker images --filter "dangling=true"
  1409  
  1410      REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
  1411      <none>              <none>              8abc22fbb042        4 weeks ago         0 B
  1412      <none>              <none>              48e5f45168b9        4 weeks ago         2.489 MB
  1413      <none>              <none>              bf747efa0e2f        4 weeks ago         0 B
  1414      <none>              <none>              980fe10e5736        12 weeks ago        101.4 MB
  1415      <none>              <none>              dea752e4e117        12 weeks ago        101.4 MB
  1416      <none>              <none>              511136ea3c5a        8 months ago        0 B
  1417  
  1418  This will display untagged images, that are the leaves of the images tree (not
  1419  intermediary layers). These images occur when a new build of an image takes the
  1420  `repo:tag` away from the image ID, leaving it untagged. A warning will be issued
  1421  if trying to remove an image when a container is presently using it.
  1422  By having this flag it allows for batch cleanup.
  1423  
  1424  Ready for use by `docker rmi ...`, like:
  1425  
  1426      $ docker rmi $(docker images -f "dangling=true" -q)
  1427  
  1428      8abc22fbb042
  1429      48e5f45168b9
  1430      bf747efa0e2f
  1431      980fe10e5736
  1432      dea752e4e117
  1433      511136ea3c5a
  1434  
  1435  NOTE: Docker will warn you if any containers exist that are using these untagged images.
  1436  
  1437  ## import
  1438  
  1439      Usage: docker import URL|- [REPOSITORY[:TAG]]
  1440  
  1441      Create an empty filesystem image and import the contents of the
  1442  	tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then
  1443  	optionally tag it.
  1444  
  1445        -c, --change=[]     Apply specified Dockerfile instructions while importing the image
  1446  
  1447  URLs must start with `http` and point to a single file archive (.tar,
  1448  .tar.gz, .tgz, .bzip, .tar.xz, or .txz) containing a root filesystem. If
  1449  you would like to import from a local directory or archive, you can use
  1450  the `-` parameter to take the data from `STDIN`.
  1451  
  1452  The `--change` option will apply `Dockerfile` instructions to the image
  1453  that is created.
  1454  Supported `Dockerfile` instructions:
  1455  `CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
  1456  
  1457  #### Examples
  1458  
  1459  **Import from a remote location:**
  1460  
  1461  This will create a new untagged image.
  1462  
  1463      $ docker import http://example.com/exampleimage.tgz
  1464  
  1465  **Import from a local file:**
  1466  
  1467  Import to docker via pipe and `STDIN`.
  1468  
  1469      $ cat exampleimage.tgz | docker import - exampleimagelocal:new
  1470  
  1471  **Import from a local directory:**
  1472  
  1473      $ sudo tar -c . | docker import - exampleimagedir
  1474  
  1475  **Import from a local directory with new configurations:**
  1476  
  1477      $ sudo tar -c . | docker import --change "ENV DEBUG true" - exampleimagedir
  1478  
  1479  Note the `sudo` in this example – you must preserve
  1480  the ownership of the files (especially root ownership) during the
  1481  archiving with tar. If you are not root (or the sudo command) when you
  1482  tar, then the ownerships might not get preserved.
  1483  
  1484  ## info
  1485  
  1486  
  1487      Usage: docker info
  1488  
  1489      Display system-wide information
  1490  
  1491  For example:
  1492  
  1493      $ docker -D info
  1494      Containers: 14
  1495      Images: 52
  1496      Storage Driver: aufs
  1497       Root Dir: /var/lib/docker/aufs
  1498       Backing Filesystem: extfs
  1499       Dirs: 545
  1500      Execution Driver: native-0.2
  1501      Logging Driver: json-file
  1502      Kernel Version: 3.13.0-24-generic
  1503      Operating System: Ubuntu 14.04 LTS
  1504      CPUs: 1
  1505      Name: prod-server-42
  1506      ID: 7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS
  1507      Total Memory: 2 GiB
  1508      Debug mode (server): false
  1509      Debug mode (client): true
  1510      File Descriptors: 10
  1511      Goroutines: 9
  1512      System Time: Tue Mar 10 18:38:57 UTC 2015
  1513      EventsListeners: 0
  1514      Init Path: /usr/bin/docker
  1515      Docker Root Dir: /var/lib/docker
  1516      Http Proxy: http://test:test@localhost:8080
  1517      Https Proxy: https://test:test@localhost:8080
  1518      No Proxy: 9.81.1.160
  1519      Username: svendowideit
  1520      Registry: [https://index.docker.io/v1/]
  1521      Labels:
  1522       storage=ssd
  1523  
  1524  The global `-D` option tells all `docker` commands to output debug information.
  1525  
  1526  When sending issue reports, please use `docker version` and `docker -D info` to
  1527  ensure we know how your setup is configured.
  1528  
  1529  ## inspect
  1530  
  1531      Usage: docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]
  1532  
  1533      Return low-level information on a container or image
  1534  
  1535        -f, --format=""    Format the output using the given go template
  1536  
  1537  By default, this will render all results in a JSON array. If a format is
  1538  specified, the given template will be executed for each result.
  1539  
  1540  Go's [text/template](http://golang.org/pkg/text/template/) package
  1541  describes all the details of the format.
  1542  
  1543  #### Examples
  1544  
  1545  **Get an instance's IP address:**
  1546  
  1547  For the most part, you can pick out any field from the JSON in a fairly
  1548  straightforward manner.
  1549  
  1550      $ docker inspect --format='{{.NetworkSettings.IPAddress}}' $INSTANCE_ID
  1551  
  1552  **Get an instance's MAC Address:**
  1553  
  1554  For the most part, you can pick out any field from the JSON in a fairly
  1555  straightforward manner.
  1556  
  1557      $ docker inspect --format='{{.NetworkSettings.MacAddress}}' $INSTANCE_ID
  1558  
  1559  **Get an instance's log path:**
  1560  
  1561      $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
  1562  
  1563  **List All Port Bindings:**
  1564  
  1565  One can loop over arrays and maps in the results to produce simple text
  1566  output:
  1567  
  1568      $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
  1569  
  1570  **Find a Specific Port Mapping:**
  1571  
  1572  The `.Field` syntax doesn't work when the field name begins with a
  1573  number, but the template language's `index` function does. The
  1574  `.NetworkSettings.Ports` section contains a map of the internal port
  1575  mappings to a list of external address/port objects, so to grab just the
  1576  numeric public port, you use `index` to find the specific port map, and
  1577  then `index` 0 contains the first object inside of that. Then we ask for
  1578  the `HostPort` field to get the public address.
  1579  
  1580      $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
  1581  
  1582  **Get config:**
  1583  
  1584  The `.Field` syntax doesn't work when the field contains JSON data, but
  1585  the template language's custom `json` function does. The `.config`
  1586  section contains complex JSON object, so to grab it as JSON, you use
  1587  `json` to convert the configuration object into JSON.
  1588  
  1589      $ docker inspect --format='{{json .config}}' $INSTANCE_ID
  1590  
  1591  ## kill
  1592  
  1593      Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...]
  1594  
  1595      Kill a running container using SIGKILL or a specified signal
  1596  
  1597        -s, --signal="KILL"    Signal to send to the container
  1598  
  1599  The main process inside the container will be sent `SIGKILL`, or any
  1600  signal specified with option `--signal`.
  1601  
  1602  ## load
  1603  
  1604      Usage: docker load [OPTIONS]
  1605  
  1606      Load an image from a tar archive on STDIN
  1607  
  1608        -i, --input=""     Read from a tar archive file, instead of STDIN
  1609  
  1610  Loads a tarred repository from a file or the standard input stream.
  1611  Restores both images and tags.
  1612  
  1613      $ docker images
  1614      REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
  1615      $ docker load < busybox.tar
  1616      $ docker images
  1617      REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
  1618      busybox             latest              769b9341d937        7 weeks ago         2.489 MB
  1619      $ docker load --input fedora.tar
  1620      $ docker images
  1621      REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
  1622      busybox             latest              769b9341d937        7 weeks ago         2.489 MB
  1623      fedora              rawhide             0d20aec6529d        7 weeks ago         387 MB
  1624      fedora              20                  58394af37342        7 weeks ago         385.5 MB
  1625      fedora              heisenbug           58394af37342        7 weeks ago         385.5 MB
  1626      fedora              latest              58394af37342        7 weeks ago         385.5 MB
  1627  
  1628  ## login
  1629  
  1630      Usage: docker login [OPTIONS] [SERVER]
  1631  
  1632      Register or log in to a Docker registry server, if no server is
  1633  	specified "https://index.docker.io/v1/" is the default.
  1634  
  1635        -e, --email=""       Email
  1636        -p, --password=""    Password
  1637        -u, --username=""    Username
  1638  
  1639  If you want to login to a self-hosted registry you can specify this by
  1640  adding the server name.
  1641  
  1642      example:
  1643      $ docker login localhost:8080
  1644  
  1645  ## logout
  1646  
  1647      Usage: docker logout [SERVER]
  1648  
  1649      Log out from a Docker registry, if no server is
  1650  	specified "https://index.docker.io/v1/" is the default.
  1651  
  1652  For example:
  1653  
  1654      $ docker logout localhost:8080
  1655  
  1656  ## logs
  1657  
  1658      Usage: docker logs [OPTIONS] CONTAINER
  1659  
  1660      Fetch the logs of a container
  1661  
  1662        -f, --follow=false        Follow log output
  1663        --since=""                Show logs since timestamp
  1664        -t, --timestamps=false    Show timestamps
  1665        --tail="all"              Number of lines to show from the end of the logs
  1666  
  1667  NOTE: this command is available only for containers with `json-file` logging
  1668  driver.
  1669  
  1670  The `docker logs` command batch-retrieves logs present at the time of execution.
  1671  
  1672  The `docker logs --follow` command will continue streaming the new output from
  1673  the container's `STDOUT` and `STDERR`.
  1674  
  1675  Passing a negative number or a non-integer to `--tail` is invalid and the
  1676  value is set to `all` in that case. This behavior may change in the future.
  1677  
  1678  The `docker logs --timestamp` commands will add an RFC3339Nano
  1679  timestamp, for example `2014-09-16T06:17:46.000000000Z`, to each
  1680  log entry. To ensure that the timestamps for are aligned the
  1681  nano-second part of the timestamp will be padded with zero when necessary.
  1682  
  1683  The `--since` option shows logs of a container generated only after
  1684  the given date, specified as RFC 3339 or UNIX timestamp. The `--since` option
  1685  can be combined with the `--follow` and `--tail` options.
  1686  
  1687  ## pause
  1688  
  1689      Usage: docker pause CONTAINER [CONTAINER...]
  1690  
  1691      Pause all processes within a container
  1692  
  1693  The `docker pause` command uses the cgroups freezer to suspend all processes in
  1694  a container.  Traditionally, when suspending a process the `SIGSTOP` signal is
  1695  used, which is observable by the process being suspended. With the cgroups freezer
  1696  the process is unaware, and unable to capture, that it is being suspended,
  1697  and subsequently resumed.
  1698  
  1699  See the
  1700  [cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt)
  1701  for further details.
  1702  
  1703  ## port
  1704  
  1705      Usage: docker port CONTAINER [PRIVATE_PORT[/PROTO]]
  1706  
  1707      List port mappings for the CONTAINER, or lookup the public-facing port that is
  1708  	NAT-ed to the PRIVATE_PORT
  1709  
  1710  You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or
  1711  just a specific mapping:
  1712  
  1713      $ docker ps test
  1714      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                                            NAMES
  1715      b650456536c7        busybox:latest      top                 54 minutes ago      Up 54 minutes       0.0.0.0:1234->9876/tcp, 0.0.0.0:4321->7890/tcp   test
  1716      $ docker port test
  1717      7890/tcp -> 0.0.0.0:4321
  1718      9876/tcp -> 0.0.0.0:1234
  1719      $ docker port test 7890/tcp
  1720      0.0.0.0:4321
  1721      $ docker port test 7890/udp
  1722      2014/06/24 11:53:36 Error: No public port '7890/udp' published for test
  1723      $ docker port test 7890
  1724      0.0.0.0:4321
  1725  
  1726  ## ps
  1727  
  1728      Usage: docker ps [OPTIONS]
  1729  
  1730      List containers
  1731  
  1732        -a, --all=false       Show all containers (default shows just running)
  1733        --before=""           Show only container created before Id or Name
  1734        -f, --filter=[]       Filter output based on conditions provided
  1735        -l, --latest=false    Show the latest created container, include non-running
  1736        -n=-1                 Show n last created containers, include non-running
  1737        --no-trunc=false      Don't truncate output
  1738        -q, --quiet=false     Only display numeric IDs
  1739        -s, --size=false      Display total file sizes
  1740        --since=""            Show created since Id or Name, include non-running
  1741  
  1742  Running `docker ps --no-trunc` showing 2 linked containers.
  1743  
  1744      $ docker ps
  1745      CONTAINER ID        IMAGE                        COMMAND                CREATED              STATUS              PORTS               NAMES
  1746      4c01db0b339c        ubuntu:12.04                 bash                   17 seconds ago       Up 16 seconds       3300-3310/tcp       webapp
  1747      d7886598dbe2        crosbymichael/redis:latest   /redis-server --dir    33 minutes ago       Up 33 minutes       6379/tcp            redis,webapp/db
  1748  
  1749  `docker ps` will show only running containers by default. To see all containers:
  1750  `docker ps -a`
  1751  
  1752  `docker ps` will group exposed ports into a single range if possible. E.g., a container that exposes TCP ports `100, 101, 102` will display `100-102/tcp` in the `PORTS` column.
  1753  
  1754  #### Filtering
  1755  
  1756  The filtering flag (`-f` or `--filter)` format is a `key=value` pair. If there is more
  1757  than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`)
  1758  
  1759  The currently supported filters are:
  1760  
  1761  * id (container's id)
  1762  * label (`label=<key>` or `label=<key>=<value>`)
  1763  * name (container's name)
  1764  * exited (int - the code of exited containers. Only useful with `--all`)
  1765  * status (restarting|running|paused|exited)
  1766  
  1767  ##### Successfully exited containers
  1768  
  1769      $ docker ps -a --filter 'exited=0'
  1770      CONTAINER ID        IMAGE             COMMAND                CREATED             STATUS                   PORTS                      NAMES
  1771      ea09c3c82f6e        registry:latest   /srv/run.sh            2 weeks ago         Exited (0) 2 weeks ago   127.0.0.1:5000->5000/tcp   desperate_leakey
  1772      106ea823fe4e        fedora:latest     /bin/sh -c 'bash -l'   2 weeks ago         Exited (0) 2 weeks ago                              determined_albattani
  1773      48ee228c9464        fedora:20         bash                   2 weeks ago         Exited (0) 2 weeks ago                              tender_torvalds
  1774  
  1775  This shows all the containers that have exited with status of '0'
  1776  
  1777  ## pull
  1778  
  1779      Usage: docker pull [OPTIONS] NAME[:TAG] | [REGISTRY_HOST[:REGISTRY_PORT]/]NAME[:TAG]
  1780  
  1781      Pull an image or a repository from the registry
  1782  
  1783        -a, --all-tags=false    Download all tagged images in the repository
  1784  
  1785  Most of your images will be created on top of a base image from the
  1786  [Docker Hub](https://hub.docker.com) registry.
  1787  
  1788  [Docker Hub](https://hub.docker.com) contains many pre-built images that you
  1789  can `pull` and try without needing to define and configure your own.
  1790  
  1791  It is also possible to manually specify the path of a registry to pull from.
  1792  For example, if you have set up a local registry, you can specify its path to
  1793  pull from it. A repository path is similar to a URL, but does not contain
  1794  a protocol specifier (`https://`, for example).
  1795  
  1796  To download a particular image, or set of images (i.e., a repository),
  1797  use `docker pull`:
  1798  
  1799      $ docker pull debian
  1800      # will pull the debian:latest image and its intermediate layers
  1801      $ docker pull debian:testing
  1802      # will pull the image named debian:testing and any intermediate
  1803      # layers it is based on.
  1804      $ docker pull debian@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
  1805      # will pull the image from the debian repository with the digest
  1806      # sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
  1807      # and any intermediate layers it is based on.
  1808      # (Typically the empty `scratch` image, a MAINTAINER layer,
  1809      # and the un-tarred base).
  1810      $ docker pull --all-tags centos
  1811      # will pull all the images from the centos repository
  1812      $ docker pull registry.hub.docker.com/debian
  1813      # manually specifies the path to the default Docker registry. This could
  1814      # be replaced with the path to a local registry to pull from another source.
  1815      # sudo docker pull myhub.com:8080/test-image
  1816  
  1817  ## push
  1818  
  1819      Usage: docker push NAME[:TAG]
  1820  
  1821      Push an image or a repository to the registry
  1822  
  1823  Use `docker push` to share your images to the [Docker Hub](https://hub.docker.com)
  1824  registry or to a self-hosted one.
  1825  
  1826  ## rename
  1827  
  1828      Usage: docker rename OLD_NAME NEW_NAME
  1829  
  1830      rename a existing container to a NEW_NAME
  1831  
  1832  The `docker rename` command allows the container to be renamed to a different name.
  1833  
  1834  ## restart
  1835  
  1836      Usage: docker restart [OPTIONS] CONTAINER [CONTAINER...]
  1837  
  1838      Restart a running container
  1839  
  1840        -t, --time=10      Seconds to wait for stop before killing the container
  1841  
  1842  ## rm
  1843  
  1844      Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
  1845  
  1846      Remove one or more containers
  1847  
  1848        -f, --force=false      Force the removal of a running container (uses SIGKILL)
  1849        -l, --link=false       Remove the specified link
  1850        -v, --volumes=false    Remove the volumes associated with the container
  1851  
  1852  #### Examples
  1853  
  1854      $ docker rm /redis
  1855      /redis
  1856  
  1857  This will remove the container referenced under the link
  1858  `/redis`.
  1859  
  1860      $ docker rm --link /webapp/redis
  1861      /webapp/redis
  1862  
  1863  This will remove the underlying link between `/webapp` and the `/redis`
  1864  containers removing all network communication.
  1865  
  1866      $ docker rm --force redis
  1867      redis
  1868  
  1869  The main process inside the container referenced under the link `/redis` will receive
  1870  `SIGKILL`, then the container will be removed.
  1871  
  1872      $ docker rm $(docker ps -a -q)
  1873  
  1874  This command will delete all stopped containers. The command `docker ps
  1875  -a -q` will return all existing container IDs and pass them to the `rm`
  1876  command which will delete them. Any running containers will not be
  1877  deleted.
  1878  
  1879  ## rmi
  1880  
  1881      Usage: docker rmi [OPTIONS] IMAGE [IMAGE...]
  1882  
  1883      Remove one or more images
  1884  
  1885        -f, --force=false    Force removal of the image
  1886        --no-prune=false     Do not delete untagged parents
  1887  
  1888  #### Removing tagged images
  1889  
  1890  You can remove an image using its short or long ID, its tag, or its digest. If
  1891  an image has one or more tag or digest reference, you must remove all of them
  1892  before the image is removed.
  1893  
  1894      $ docker images
  1895      REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
  1896      test1                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1897      test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1898      test2                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1899  
  1900      $ docker rmi fd484f19954f
  1901      Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force
  1902      2013/12/11 05:47:16 Error: failed to remove one or more images
  1903  
  1904      $ docker rmi test1
  1905      Untagged: test1:latest
  1906      $ docker rmi test2
  1907      Untagged: test2:latest
  1908  
  1909      $ docker images
  1910      REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
  1911      test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1912      $ docker rmi test
  1913      Untagged: test:latest
  1914      Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
  1915  
  1916  If you use the `-f` flag and specify the image's short or long ID, then this
  1917  command untags and removes all images that match the specified ID.
  1918  
  1919      $ docker images
  1920      REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
  1921      test1                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1922      test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1923      test2                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1924  
  1925      $ docker rmi -f fd484f19954f
  1926      Untagged: test1:latest
  1927      Untagged: test:latest
  1928      Untagged: test2:latest
  1929      Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
  1930  
  1931  An image pulled by digest has no tag associated with it:
  1932  
  1933      $ docker images --digests
  1934      REPOSITORY                     TAG       DIGEST                                                                    IMAGE ID        CREATED         VIRTUAL SIZE
  1935      localhost:5000/test/busybox    <none>    sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf   4986bf8c1536    9 weeks ago     2.43 MB
  1936  
  1937  To remove an image using its digest:
  1938  
  1939      $ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
  1940      Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
  1941      Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
  1942      Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2
  1943      Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b
  1944  
  1945  ## run
  1946  
  1947      Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
  1948  
  1949      Run a command in a new container
  1950  
  1951        -a, --attach=[]            Attach to STDIN, STDOUT or STDERR
  1952        --add-host=[]              Add a custom host-to-IP mapping (host:ip)
  1953        --blkio-weight=0           Block IO weight (relative weight)
  1954        -c, --cpu-shares=0         CPU shares (relative weight)
  1955        --cap-add=[]               Add Linux capabilities
  1956        --cap-drop=[]              Drop Linux capabilities
  1957        --cidfile=""               Write the container ID to the file
  1958        --cpuset-cpus=""           CPUs in which to allow execution (0-3, 0,1)
  1959        --cpuset-mems=""           Memory nodes (MEMs) in which to allow execution (0-3, 0,1)
  1960        --cpu-period=0             Limit the CPU CFS (Completely Fair Scheduler) period
  1961        --cpu-quota=0              Limit the CPU CFS (Completely Fair Scheduler) quota
  1962        -d, --detach=false         Run container in background and print container ID
  1963        --device=[]                Add a host device to the container
  1964        --dns=[]                   Set custom DNS servers
  1965        --dns-search=[]            Set custom DNS search domains
  1966        -e, --env=[]               Set environment variables
  1967        --entrypoint=""            Overwrite the default ENTRYPOINT of the image
  1968        --env-file=[]              Read in a file of environment variables
  1969        --expose=[]                Expose a port or a range of ports
  1970        -h, --hostname=""          Container host name
  1971        --help=false               Print usage
  1972        -i, --interactive=false    Keep STDIN open even if not attached
  1973        --ipc=""                   IPC namespace to use
  1974        --link=[]                  Add link to another container
  1975        --log-driver=""            Logging driver for container
  1976        --log-opt=[]               Log driver specific options
  1977        --lxc-conf=[]              Add custom lxc options
  1978        -m, --memory=""            Memory limit
  1979        -l, --label=[]             Set metadata on the container (e.g., --label=com.example.key=value)
  1980        --label-file=[]            Read in a file of labels (EOL delimited)
  1981        --mac-address=""           Container MAC address (e.g. 92:d0:c6:0a:29:33)
  1982        --memory-swap=""           Total memory (memory + swap), '-1' to disable swap
  1983        --name=""                  Assign a name to the container
  1984        --net="bridge"             Set the Network mode for the container
  1985        --oom-kill-disable=false   Whether to disable OOM Killer for the container or not
  1986        -P, --publish-all=false    Publish all exposed ports to random ports
  1987        -p, --publish=[]           Publish a container's port(s) to the host
  1988        --pid=""                   PID namespace to use
  1989        --uts=""                   UTS namespace to use
  1990        --privileged=false         Give extended privileges to this container
  1991        --read-only=false          Mount the container's root filesystem as read only
  1992        --restart="no"             Restart policy (no, on-failure[:max-retry], always)
  1993        --rm=false                 Automatically remove the container when it exits
  1994        --security-opt=[]          Security Options
  1995        --sig-proxy=true           Proxy received signals to the process
  1996        -t, --tty=false            Allocate a pseudo-TTY
  1997        -u, --user=""              Username or UID (format: <name|uid>[:<group|gid>])
  1998        -v, --volume=[]            Bind mount a volume
  1999        --volumes-from=[]          Mount volumes from the specified container(s)
  2000        -w, --workdir=""           Working directory inside the container
  2001  
  2002  The `docker run` command first `creates` a writeable container layer over the
  2003  specified image, and then `starts` it using the specified command. That is,
  2004  `docker run` is equivalent to the API `/containers/create` then
  2005  `/containers/(id)/start`. A stopped container can be restarted with all its
  2006  previous changes intact using `docker start`. See `docker ps -a` to view a list
  2007  of all containers.
  2008  
  2009  There is detailed information about `docker run` in the [Docker run reference](
  2010  /reference/run/).
  2011  
  2012  The `docker run` command can be used in combination with `docker commit` to
  2013  [*change the command that a container runs*](#commit-an-existing-container).
  2014  
  2015  See the [Docker User Guide](/userguide/dockerlinks/) for more detailed
  2016  information about the `--expose`, `-p`, `-P` and `--link` parameters,
  2017  and linking containers.
  2018  
  2019  #### Examples
  2020  
  2021      $ docker run --name test -it debian
  2022      $$ exit 13
  2023      exit
  2024      $ echo $?
  2025      13
  2026      $ docker ps -a | grep test
  2027      275c44472aeb        debian:7            "/bin/bash"         26 seconds ago      Exited (13) 17 seconds ago                         test
  2028  
  2029  In this example, we are running `bash` interactively in the `debian:latest` image, and giving
  2030  the container the name `test`. We then quit `bash` by running `exit 13`, which means `bash`
  2031  will have an exit code of `13`. This is then passed on to the caller of `docker run`, and
  2032  is recorded in the `test` container metadata.
  2033  
  2034      $ docker run --cidfile /tmp/docker_test.cid ubuntu echo "test"
  2035  
  2036  This will create a container and print `test` to the console. The `cidfile`
  2037  flag makes Docker attempt to create a new file and write the container ID to it.
  2038  If the file exists already, Docker will return an error. Docker will close this
  2039  file when `docker run` exits.
  2040  
  2041      $ docker run -t -i --rm ubuntu bash
  2042      root@bc338942ef20:/# mount -t tmpfs none /mnt
  2043      mount: permission denied
  2044  
  2045  This will *not* work, because by default, most potentially dangerous kernel
  2046  capabilities are dropped; including `cap_sys_admin` (which is required to mount
  2047  filesystems). However, the `--privileged` flag will allow it to run:
  2048  
  2049      $ docker run --privileged ubuntu bash
  2050      root@50e3f57e16e6:/# mount -t tmpfs none /mnt
  2051      root@50e3f57e16e6:/# df -h
  2052      Filesystem      Size  Used Avail Use% Mounted on
  2053      none            1.9G     0  1.9G   0% /mnt
  2054  
  2055  The `--privileged` flag gives *all* capabilities to the container, and it also
  2056  lifts all the limitations enforced by the `device` cgroup controller. In other
  2057  words, the container can then do almost everything that the host can do. This
  2058  flag exists to allow special use-cases, like running Docker within Docker.
  2059  
  2060      $ docker  run -w /path/to/dir/ -i -t  ubuntu pwd
  2061  
  2062  The `-w` lets the command being executed inside directory given, here
  2063  `/path/to/dir/`. If the path does not exists it is created inside the container.
  2064  
  2065      $ docker  run  -v `pwd`:`pwd` -w `pwd` -i -t  ubuntu pwd
  2066  
  2067  The `-v` flag mounts the current working directory into the container. The `-w`
  2068  lets the command being executed inside the current working directory, by
  2069  changing into the directory to the value returned by `pwd`. So this
  2070  combination executes the command using the container, but inside the
  2071  current working directory.
  2072  
  2073      $ docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash
  2074  
  2075  When the host directory of a bind-mounted volume doesn't exist, Docker
  2076  will automatically create this directory on the host for you. In the
  2077  example above, Docker will create the `/doesnt/exist`
  2078  folder before starting your container.
  2079  
  2080      $ docker run --read-only -v /icanwrite busybox touch /icanwrite here
  2081  
  2082  Volumes can be used in combination with `--read-only` to control where
  2083  a container writes files.  The `--read-only` flag mounts the container's root
  2084  filesystem as read only prohibiting writes to locations other than the
  2085  specified volumes for the container.
  2086  
  2087      $ docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v ./static-docker:/usr/bin/docker busybox sh
  2088  
  2089  By bind-mounting the docker unix socket and statically linked docker
  2090  binary (such as that provided by [https://get.docker.com](
  2091  https://get.docker.com)), you give the container the full access to create and
  2092  manipulate the host's Docker daemon.
  2093  
  2094      $ docker run -p 127.0.0.1:80:8080 ubuntu bash
  2095  
  2096  This binds port `8080` of the container to port `80` on `127.0.0.1` of
  2097  the host machine. The [Docker User Guide](/userguide/dockerlinks/)
  2098  explains in detail how to manipulate ports in Docker.
  2099  
  2100      $ docker run --expose 80 ubuntu bash
  2101  
  2102  This exposes port `80` of the container for use within a link without
  2103  publishing the port to the host system's interfaces. The [Docker User
  2104  Guide](/userguide/dockerlinks) explains in detail how to manipulate
  2105  ports in Docker.
  2106  
  2107      $ docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash
  2108  
  2109  This sets environmental variables in the container. For illustration all three
  2110  flags are shown here. Where `-e`, `--env` take an environment variable and
  2111  value, or if no `=` is provided, then that variable's current value is passed
  2112  through (i.e. `$MYVAR1` from the host is set to `$MYVAR1` in the container).
  2113  When no `=` is provided and that variable is not defined in the client's
  2114  environment then that variable will be removed from the container's list of
  2115  environment variables.
  2116  All three flags, `-e`, `--env` and `--env-file` can be repeated.
  2117  
  2118  Regardless of the order of these three flags, the `--env-file` are processed
  2119  first, and then `-e`, `--env` flags. This way, the `-e` or `--env` will
  2120  override variables as needed.
  2121  
  2122      $ cat ./env.list
  2123      TEST_FOO=BAR
  2124      $ docker run --env TEST_FOO="This is a test" --env-file ./env.list busybox env | grep TEST_FOO
  2125      TEST_FOO=This is a test
  2126  
  2127  The `--env-file` flag takes a filename as an argument and expects each line
  2128  to be in the `VAR=VAL` format, mimicking the argument passed to `--env`. Comment
  2129  lines need only be prefixed with `#`
  2130  
  2131  An example of a file passed with `--env-file`
  2132  
  2133      $ cat ./env.list
  2134      TEST_FOO=BAR
  2135  
  2136      # this is a comment
  2137      TEST_APP_DEST_HOST=10.10.0.127
  2138      TEST_APP_DEST_PORT=8888
  2139  
  2140      # pass through this variable from the caller
  2141      TEST_PASSTHROUGH
  2142      $ sudo TEST_PASSTHROUGH=howdy docker run --env-file ./env.list busybox env
  2143      HOME=/
  2144      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  2145      HOSTNAME=5198e0745561
  2146      TEST_FOO=BAR
  2147      TEST_APP_DEST_HOST=10.10.0.127
  2148      TEST_APP_DEST_PORT=8888
  2149      TEST_PASSTHROUGH=howdy
  2150  
  2151      $ docker run --name console -t -i ubuntu bash
  2152  
  2153  A label is a a `key=value` pair that applies metadata to a container. To label a container with two labels:
  2154  
  2155      $ docker run -l my-label --label com.example.foo=bar ubuntu bash
  2156  
  2157  The `my-label` key doesn't specify a value so the label defaults to an empty
  2158  string(`""`). To add multiple labels, repeat the label flag (`-l` or `--label`).
  2159  
  2160  The `key=value` must be unique to avoid overwriting the label value. If you
  2161  specify labels with identical keys but different values, each subsequent value
  2162  overwrites the previous. Docker uses the last `key=value` you supply.
  2163  
  2164  Use the `--label-file` flag to load multiple labels from a file. Delimit each
  2165  label in the file with an EOL mark. The example below loads labels from a
  2166  labels file in the current directory:
  2167  
  2168      $ docker run --label-file ./labels ubuntu bash
  2169  
  2170  The label-file format is similar to the format for loading environment
  2171  variables. (Unlike environment variables, labels are not visible to processes
  2172  running inside a container.) The following example illustrates a label-file
  2173  format:
  2174  
  2175      com.example.label1="a label"
  2176  
  2177      # this is a comment
  2178      com.example.label2=another\ label
  2179      com.example.label3
  2180  
  2181  You can load multiple label-files by supplying multiple  `--label-file` flags.
  2182  
  2183  For additional information on working with labels, see [*Labels - custom
  2184  metadata in Docker*](/userguide/labels-custom-metadata/) in the Docker User
  2185  Guide.
  2186  
  2187      $ docker run --link /redis:redis --name console ubuntu bash
  2188  
  2189  The `--link` flag will link the container named `/redis` into the newly
  2190  created container with the alias `redis`. The new container can access the
  2191  network and environment of the `redis` container via environment variables.
  2192  The `--link` flag will also just accept the form `<name or id>` in which case
  2193  the alias will match the name. For instance, you could have written the previous
  2194  example as:
  2195  
  2196      $ docker run --link redis --name console ubuntu bash
  2197  
  2198  The `--name` flag will assign the name `console` to the newly created
  2199  container.
  2200  
  2201      $ docker run --volumes-from 777f7dc92da7 --volumes-from ba8c0c54f0f2:ro -i -t ubuntu pwd
  2202  
  2203  The `--volumes-from` flag mounts all the defined volumes from the referenced
  2204  containers. Containers can be specified by repetitions of the `--volumes-from`
  2205  argument. The container ID may be optionally suffixed with `:ro` or `:rw` to
  2206  mount the volumes in read-only or read-write mode, respectively. By default,
  2207  the volumes are mounted in the same mode (read write or read only) as
  2208  the reference container.
  2209  
  2210  Labeling systems like SELinux require proper labels be placed on volume content
  2211  mounted into a container, otherwise the security system might prevent the
  2212  processes running inside the container from using the content. By default,
  2213  volumes are not relabeled.
  2214  
  2215  Two suffixes :z or :Z can be added to the volume mount. These suffixes tell
  2216  Docker to relabel file objects on the shared volumes. The 'z' option tells
  2217  Docker that the volume content will be shared between containers. Docker will
  2218  label the content with a shared content label. Shared volumes labels allow all
  2219  containers to read/write content. The 'Z' option tells Docker to label the
  2220  content with a private unshared label. Private volumes can only be used by the
  2221  current container.
  2222  
  2223  The `-a` flag tells `docker run` to bind to the container's `STDIN`, `STDOUT` or
  2224  `STDERR`. This makes it possible to manipulate the output and input as needed.
  2225  
  2226      $ echo "test" | docker run -i -a stdin ubuntu cat -
  2227  
  2228  This pipes data into a container and prints the container's ID by attaching
  2229  only to the container's `STDIN`.
  2230  
  2231      $ docker run -a stderr ubuntu echo test
  2232  
  2233  This isn't going to print anything unless there's an error because we've
  2234  only attached to the `STDERR` of the container. The container's logs
  2235  still store what's been written to `STDERR` and `STDOUT`.
  2236  
  2237      $ cat somefile | docker run -i -a stdin mybuilder dobuild
  2238  
  2239  This is how piping a file into a container could be done for a build.
  2240  The container's ID will be printed after the build is done and the build
  2241  logs could be retrieved using `docker logs`. This is
  2242  useful if you need to pipe a file or something else into a container and
  2243  retrieve the container's ID once the container has finished running.
  2244  
  2245      $ docker run --device=/dev/sdc:/dev/xvdc --device=/dev/sdd --device=/dev/zero:/dev/nulo -i -t ubuntu ls -l /dev/{xvdc,sdd,nulo}
  2246      brw-rw---- 1 root disk 8, 2 Feb  9 16:05 /dev/xvdc
  2247      brw-rw---- 1 root disk 8, 3 Feb  9 16:05 /dev/sdd
  2248      crw-rw-rw- 1 root root 1, 5 Feb  9 16:05 /dev/nulo
  2249  
  2250  It is often necessary to directly expose devices to a container. The `--device`
  2251  option enables that.  For example, a specific block storage device or loop
  2252  device or audio device can be added to an otherwise unprivileged container
  2253  (without the `--privileged` flag) and have the application directly access it.
  2254  
  2255  By default, the container will be able to `read`, `write` and `mknod` these devices.
  2256  This can be overridden using a third `:rwm` set of options to each `--device`
  2257  flag:
  2258  
  2259  
  2260  ```
  2261  	$ docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk  /dev/xvdc
  2262  
  2263  	Command (m for help): q
  2264  	$ docker run --device=/dev/sda:/dev/xvdc:ro --rm -it ubuntu fdisk  /dev/xvdc
  2265  	You will not be able to write the partition table.
  2266  
  2267  	Command (m for help): q
  2268  
  2269  	$ docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk  /dev/xvdc
  2270  
  2271  	Command (m for help): q
  2272  
  2273  	$ docker run --device=/dev/sda:/dev/xvdc:m --rm -it ubuntu fdisk  /dev/xvdc
  2274  	fdisk: unable to open /dev/xvdc: Operation not permitted
  2275  ```
  2276  
  2277  > **Note:**
  2278  > `--device` cannot be safely used with ephemeral devices. Block devices that
  2279  > may be removed should not be added to untrusted containers with `--device`.
  2280  
  2281  **A complete example:**
  2282  
  2283      $ docker run -d --name static static-web-files sh
  2284      $ docker run -d --expose=8098 --name riak riakserver
  2285      $ docker run -d -m 100m -e DEVELOPMENT=1 -e BRANCH=example-code -v $(pwd):/app/bin:ro --name app appserver
  2286      $ docker run -d -p 1443:443 --dns=10.0.0.1 --dns-search=dev.org -v /var/log/httpd --volumes-from static --link riak --link app -h www.sven.dev.org --name web webserver
  2287      $ docker run -t -i --rm --volumes-from web -w /var/log/httpd busybox tail -f access.log
  2288  
  2289  This example shows five containers that might be set up to test a web
  2290  application change:
  2291  
  2292  1. Start a pre-prepared volume image `static-web-files` (in the background)
  2293     that has CSS, image and static HTML in it, (with a `VOLUME` instruction in
  2294     the Dockerfile to allow the web server to use those files);
  2295  2. Start a pre-prepared `riakserver` image, give the container name `riak` and
  2296     expose port `8098` to any containers that link to it;
  2297  3. Start the `appserver` image, restricting its memory usage to 100MB, setting
  2298     two environment variables `DEVELOPMENT` and `BRANCH` and bind-mounting the
  2299     current directory (`$(pwd)`) in the container in read-only mode as `/app/bin`;
  2300  4. Start the `webserver`, mapping port `443` in the container to port `1443` on
  2301     the Docker server, setting the DNS server to `10.0.0.1` and DNS search
  2302     domain to `dev.org`, creating a volume to put the log files into (so we can
  2303     access it from another container), then importing the files from the volume
  2304     exposed by the `static` container, and linking to all exposed ports from
  2305     `riak` and `app`. Lastly, we set the hostname to `web.sven.dev.org` so its
  2306     consistent with the pre-generated SSL certificate;
  2307  5. Finally, we create a container that runs `tail -f access.log` using the logs
  2308     volume from the `web` container, setting the workdir to `/var/log/httpd`. The
  2309     `--rm` option means that when the container exits, the container's layer is
  2310     removed.
  2311  
  2312  #### Restart policies
  2313  
  2314  Use Docker's `--restart` to specify a container's *restart policy*. A restart
  2315  policy controls whether the Docker daemon restarts a container after exit.
  2316  Docker supports the following restart policies:
  2317  
  2318  <table>
  2319    <thead>
  2320      <tr>
  2321        <th>Policy</th>
  2322        <th>Result</th>
  2323      </tr>
  2324    </thead>
  2325    <tbody>
  2326      <tr>
  2327        <td><strong>no</strong></td>
  2328        <td>
  2329          Do not automatically restart the container when it exits. This is the
  2330          default.
  2331        </td>
  2332      </tr>
  2333      <tr>
  2334        <td>
  2335          <span style="white-space: nowrap">
  2336            <strong>on-failure</strong>[:max-retries]
  2337          </span>
  2338        </td>
  2339        <td>
  2340          Restart only if the container exits with a non-zero exit status.
  2341          Optionally, limit the number of restart retries the Docker
  2342          daemon attempts.
  2343        </td>
  2344      </tr>
  2345      <tr>
  2346        <td><strong>always</strong></td>
  2347        <td>
  2348          Always restart the container regardless of the exit status.
  2349          When you specify always, the Docker daemon will try to restart
  2350          the container indefinitely.
  2351        </td>
  2352      </tr>
  2353    </tbody>
  2354  </table>
  2355  
  2356      $ docker run --restart=always redis
  2357  
  2358  This will run the `redis` container with a restart policy of **always**
  2359  so that if the container exits, Docker will restart it.
  2360  
  2361  More detailed information on restart policies can be found in the
  2362  [Restart Policies (--restart)](/reference/run/#restart-policies-restart) section
  2363  of the Docker run reference page.
  2364  
  2365  ### Adding entries to a container hosts file
  2366  
  2367  You can add other hosts into a container's `/etc/hosts` file by using one or more
  2368  `--add-host` flags. This example adds a static address for a host named `docker`:
  2369  
  2370  ```
  2371      $ docker run --add-host=docker:10.180.0.1 --rm -it debian
  2372      $$ ping docker
  2373      PING docker (10.180.0.1): 48 data bytes
  2374      56 bytes from 10.180.0.1: icmp_seq=0 ttl=254 time=7.600 ms
  2375      56 bytes from 10.180.0.1: icmp_seq=1 ttl=254 time=30.705 ms
  2376      ^C--- docker ping statistics ---
  2377      2 packets transmitted, 2 packets received, 0% packet loss
  2378      round-trip min/avg/max/stddev = 7.600/19.152/30.705/11.553 ms
  2379  ```
  2380  
  2381  Sometimes you need to connect to the Docker host from within your
  2382  container.  To enable this, pass the Docker host's IP address to
  2383  the container using the `--add-host` flag. To find the host's address,
  2384  use the `ip addr show` command.
  2385  
  2386  The flags you pass to `ip addr show` depend on whether you are
  2387  using IPv4 or IPv6 networking in your containers. Use the following
  2388  flags for IPv4 address retrieval for a network device named `eth0`:
  2389  
  2390      $ HOSTIP=`ip -4 addr show scope global dev eth0 | grep inet | awk '{print \$2}' | cut -d / -f 1`
  2391      $ docker run  --add-host=docker:${HOSTIP} --rm -it debian
  2392  
  2393  For IPv6 use the `-6` flag instead of the `-4` flag. For other network
  2394  devices, replace `eth0` with the correct device name (for example `docker0`
  2395  for the bridge device).
  2396  
  2397  ### Setting ulimits in a container
  2398  
  2399  Since setting `ulimit` settings in a container requires extra privileges not
  2400  available in the default container, you can set these using the `--ulimit` flag.
  2401  `--ulimit` is specified with a soft and hard limit as such:
  2402  `<type>=<soft limit>[:<hard limit>]`, for example:
  2403  
  2404  ```
  2405      $ docker run --ulimit nofile=1024:1024 --rm debian ulimit -n
  2406      1024
  2407  ```
  2408  
  2409  >**Note:**
  2410  > If you do not provide a `hard limit`, the `soft limit` will be used for both
  2411  values. If no `ulimits` are set, they will be inherited from the default `ulimits`
  2412  set on the daemon.
  2413  > `as` option is disabled now. In other words, the following script is not supported:
  2414  >   `$ docker run -it --ulimit as=1024 fedora /bin/bash`
  2415  
  2416  ## save
  2417  
  2418      Usage: docker save [OPTIONS] IMAGE [IMAGE...]
  2419  
  2420      Save an image(s) to a tar archive (streamed to STDOUT by default)
  2421  
  2422        -o, --output=""    Write to a file, instead of STDOUT
  2423  
  2424  Produces a tarred repository to the standard output stream.
  2425  Contains all parent layers, and all tags + versions, or specified `repo:tag`, for
  2426  each argument provided.
  2427  
  2428  It is used to create a backup that can then be used with `docker load`
  2429  
  2430      $ docker save busybox > busybox.tar
  2431      $ ls -sh busybox.tar
  2432      2.7M busybox.tar
  2433      $ docker save --output busybox.tar busybox
  2434      $ ls -sh busybox.tar
  2435      2.7M busybox.tar
  2436      $ docker save -o fedora-all.tar fedora
  2437      $ docker save -o fedora-latest.tar fedora:latest
  2438  
  2439  It is even useful to cherry-pick particular tags of an image repository
  2440  
  2441      $ docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy
  2442  
  2443  ## search
  2444  
  2445  Search [Docker Hub](https://hub.docker.com) for images
  2446  
  2447      Usage: docker search [OPTIONS] TERM
  2448  
  2449      Search the Docker Hub for images
  2450  
  2451        --automated=false    Only show automated builds
  2452        --no-trunc=false     Don't truncate output
  2453        -s, --stars=0        Only displays with at least x stars
  2454  
  2455  See [*Find Public Images on Docker Hub*](
  2456  /userguide/dockerrepos/#searching-for-images) for
  2457  more details on finding shared images from the command line.
  2458  
  2459  > **Note:**
  2460  > Search queries will only return up to 25 results
  2461  
  2462  ## start
  2463  
  2464      Usage: docker start [OPTIONS] CONTAINER [CONTAINER...]
  2465  
  2466      Start one or more stopped containers
  2467  
  2468        -a, --attach=false         Attach STDOUT/STDERR and forward signals
  2469        -i, --interactive=false    Attach container's STDIN
  2470  
  2471  ## stats
  2472  
  2473      Usage: docker stats CONTAINER [CONTAINER...]
  2474  
  2475      Display a live stream of one or more containers' resource usage statistics
  2476  
  2477        --help=false       Print usage
  2478        --no-stream=false  Disable streaming stats and only pull the first result
  2479  
  2480  Running `docker stats` on multiple containers
  2481  
  2482      $ docker stats redis1 redis2
  2483      CONTAINER           CPU %               MEM USAGE/LIMIT     MEM %               NET I/O
  2484      redis1              0.07%               796 KB/64 MB        1.21%               788 B/648 B
  2485      redis2              0.07%               2.746 MB/64 MB      4.29%               1.266 KB/648 B
  2486  
  2487  
  2488  The `docker stats` command will only return a live stream of data for running
  2489  containers. Stopped containers will not return any data.
  2490  
  2491  > **Note:**
  2492  > If you want more detailed information about a container's resource usage, use the API endpoint.
  2493  
  2494  ## stop
  2495  
  2496      Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
  2497  
  2498      Stop a running container by sending SIGTERM and then SIGKILL after a
  2499  	grace period
  2500  
  2501        -t, --time=10      Seconds to wait for stop before killing it
  2502  
  2503  The main process inside the container will receive `SIGTERM`, and after a
  2504  grace period, `SIGKILL`.
  2505  
  2506  ## tag
  2507  
  2508      Usage: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
  2509  
  2510      Tag an image into a repository
  2511  
  2512        -f, --force=false    Force
  2513  
  2514  You can group your images together using names and tags, and then upload
  2515  them to [*Share Images via Repositories*](
  2516  /userguide/dockerrepos/#contributing-to-docker-hub).
  2517  
  2518  ## top
  2519  
  2520      Usage: docker top CONTAINER [ps OPTIONS]
  2521  
  2522      Display the running processes of a container
  2523  
  2524  ## unpause
  2525  
  2526      Usage: docker unpause CONTAINER [CONTAINER...]
  2527  
  2528      Unpause all processes within a container
  2529  
  2530  The `docker unpause` command uses the cgroups freezer to un-suspend all
  2531  processes in a container.
  2532  
  2533  See the
  2534  [cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt)
  2535  for further details.
  2536  
  2537  ## version
  2538  
  2539      Usage: docker version
  2540  
  2541      Show the Docker version information.
  2542  
  2543  Show the Docker version, API version, Git commit, Go version and OS/architecture
  2544  of both Docker client and daemon. Example use:
  2545  
  2546      $ docker version
  2547      Client version: 1.5.0
  2548      Client API version: 1.17
  2549      Go version (client): go1.4.1
  2550      Git commit (client): a8a31ef
  2551      OS/Arch (client): darwin/amd64
  2552      Server version: 1.5.0
  2553      Server API version: 1.17
  2554      Go version (server): go1.4.1
  2555      Git commit (server): a8a31ef
  2556      OS/Arch (server): linux/amd64
  2557  
  2558  
  2559  ## wait
  2560  
  2561      Usage: docker wait CONTAINER [CONTAINER...]
  2562  
  2563      Block until a container stops, then print its exit code.
  2564