github.com/stchris/docker@v1.4.2-0.20150106053530-1510a324dbd5/docs/sources/reference/commandline/cli.md (about)

     1  page_title: Command Line Interface
     2  page_description: Docker's CLI command description and usage
     3  page_keywords: Docker, Docker documentation, CLI, command line
     4  
     5  # Command Line
     6  
     7  To list available commands, either run `docker` with no parameters
     8  or execute `docker help`:
     9  
    10      $ sudo docker
    11        Usage: docker [OPTIONS] COMMAND [arg...]
    12          -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.
    13  
    14        A self-sufficient runtime for Linux containers.
    15  
    16        ...
    17  
    18  ## Option types
    19  
    20  Single character commandline options can be combined, so rather than
    21  typing `docker run -t -i --name test busybox sh`,
    22  you can write `docker run -ti --name test busybox sh`.
    23  
    24  ### Boolean
    25  
    26  Boolean options look like `-d=false`. The value you
    27  see is the default value which gets set if you do **not** use the
    28  boolean flag. If you do call `run -d`, that sets the
    29  opposite boolean value, so in this case, `true`, and
    30  so `docker run -d` **will** run in "detached" mode,
    31  in the background. Other boolean options are similar – specifying them
    32  will set the value to the opposite of the default value.
    33  
    34  ### Multi
    35  
    36  Options like `-a=[]` indicate they can be specified multiple times:
    37  
    38      $ sudo docker run -a stdin -a stdout -a stderr -i -t ubuntu /bin/bash
    39  
    40  Sometimes this can use a more complex value string, as for `-v`:
    41  
    42      $ sudo docker run -v /host:/container example/mysql
    43  
    44  ### Strings and Integers
    45  
    46  Options like `--name=""` expect a string, and they
    47  can only be specified once. Options like `-c=0`
    48  expect an integer, and they can only be specified once.
    49  
    50  ## daemon
    51  
    52      Usage: docker [OPTIONS] COMMAND [arg...]
    53  
    54      A self-sufficient runtime for linux containers.
    55  
    56      Options:
    57        --api-enable-cors=false                    Enable CORS headers in the remote API
    58        -b, --bridge=""                            Attach containers to a pre-existing network bridge
    59                                                     use 'none' to disable container networking
    60        --bip=""                                   Use this CIDR notation address for the network bridge's IP, not compatible with -b
    61        -D, --debug=false                          Enable debug mode
    62        -d, --daemon=false                         Enable daemon mode
    63        --dns=[]                                   Force Docker to use specific DNS servers
    64        --dns-search=[]                            Force Docker to use specific DNS search domains
    65        -e, --exec-driver="native"                 Force the Docker runtime to use a specific exec driver
    66        --fixed-cidr=""                            IPv4 subnet for fixed IPs (ex: 10.20.0.0/16)
    67                                                     this subnet must be nested in the bridge subnet (which is defined by -b or --bip)
    68        -G, --group="docker"                       Group to assign the unix socket specified by -H when running in daemon mode
    69                                                     use '' (the empty string) to disable setting of a group
    70        -g, --graph="/var/lib/docker"              Path to use as the root of the Docker runtime
    71        -H, --host=[]                              The socket(s) to bind to in daemon mode or connect to in client mode, specified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.
    72        --icc=true                                 Allow unrestricted inter-container and Docker daemon host communication
    73        --insecure-registry=[]                     Enable insecure communication with specified registries (disables certificate verification for HTTPS and enables HTTP fallback) (e.g., localhost:5000 or 10.20.0.0/16)
    74        --ip=0.0.0.0                               Default IP address to use when binding container ports
    75        --ip-forward=true                          Enable net.ipv4.ip_forward
    76        --ip-masq=true                             Enable IP masquerading for bridge's IP range
    77        --iptables=true                            Enable Docker's addition of iptables rules
    78         -l, --log-level="info"                    Set the logging level
    79        --label=[]                                 Set key=value labels to the daemon (displayed in `docker info`)
    80        --mtu=0                                    Set the containers network MTU
    81                                                     if no value is provided: default to the default route MTU or 1500 if no default route is available
    82        -p, --pidfile="/var/run/docker.pid"        Path to use for daemon PID file
    83        --registry-mirror=[]                       Specify a preferred Docker registry mirror
    84        -s, --storage-driver=""                    Force the Docker runtime to use a specific storage driver
    85        --selinux-enabled=false                    Enable selinux support. SELinux does not presently support the BTRFS storage driver
    86        --storage-opt=[]                           Set storage driver options
    87        --tls=false                                Use TLS; implied by --tlsverify flag
    88        --tlscacert="/home/sven/.docker/ca.pem"    Trust only remotes providing a certificate signed by the CA given here
    89        --tlscert="/home/sven/.docker/cert.pem"    Path to TLS certificate file
    90        --tlskey="/home/sven/.docker/key.pem"      Path to TLS key file
    91        --tlsverify=false                          Use TLS and verify the remote (daemon: verify client, client: verify daemon)
    92        -v, --version=false                        Print version information and quit
    93  
    94  Options with [] may be specified multiple times.
    95  
    96  The Docker daemon is the persistent process that manages containers.
    97  Docker uses the same binary for both the daemon and client. To run the
    98  daemon you provide the `-d` flag.
    99  
   100  
   101  To run the daemon with debug output, use `docker -d -D`.
   102  
   103  ### Daemon socket option
   104  
   105  The Docker daemon can listen for [Docker Remote API](/reference/api/docker_remote_api/)
   106  requests via three different types of Socket: `unix`, `tcp`, and `fd`.
   107  
   108  By default, a `unix` domain socket (or IPC socket) is created at `/var/run/docker.sock`,
   109  requiring either `root` permission, or `docker` group membership.
   110  
   111  If you need to access the Docker daemon remotely, you need to enable the `tcp`
   112  Socket. Beware that the default setup provides un-encrypted and un-authenticated
   113  direct access to the Docker daemon - and should be secured either using the
   114  [built in HTTPS encrypted socket](/articles/https/), or by putting a secure web
   115  proxy in front of it. You can listen on port `2375` on all network interfaces
   116  with `-H tcp://0.0.0.0:2375`, or on a particular network interface using its IP
   117  address: `-H tcp://192.168.59.103:2375`. It is conventional to use port `2375`
   118  for un-encrypted, and port `2376` for encrypted communication with the daemon.
   119  
   120  > **Note** If you're using an HTTPS encrypted socket, keep in mind that only TLS1.0
   121  > and greater are supported. Protocols SSLv3 and under are not supported anymore
   122  > for security reasons.
   123  
   124  On Systemd based systems, you can communicate with the daemon via
   125  [systemd socket activation](http://0pointer.de/blog/projects/socket-activation.html), use
   126  `docker -d -H fd://`. Using `fd://` will work perfectly for most setups but
   127  you can also specify individual sockets: `docker -d -H fd://3`. If the
   128  specified socket activated files aren't found, then Docker will exit. You
   129  can find examples of using Systemd socket activation with Docker and
   130  Systemd in the [Docker source tree](
   131  https://github.com/docker/docker/tree/master/contrib/init/systemd/).
   132  
   133  You can configure the Docker daemon to listen to multiple sockets at the same
   134  time using multiple `-H` options:
   135  
   136      # listen using the default unix socket, and on 2 specific IP addresses on this host.
   137      docker -d -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2
   138  
   139  The Docker client will honor the `DOCKER_HOST` environment variable to set
   140  the `-H` flag for the client.
   141  
   142      $ sudo docker -H tcp://0.0.0.0:2375 ps
   143      # or
   144      $ export DOCKER_HOST="tcp://0.0.0.0:2375"
   145      $ sudo docker ps
   146      # both are equal
   147  
   148  Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than the empty
   149  string is equivalent to setting the `--tlsverify` flag. The following are equivalent:
   150  
   151      $ sudo docker --tlsverify ps
   152      # or
   153      $ export DOCKER_TLS_VERIFY=1
   154      $ sudo docker ps
   155  
   156  ### Daemon storage-driver option
   157  
   158  The Docker daemon has support for several different image layer storage drivers: `aufs`,
   159  `devicemapper`, `btrfs` and `overlay`.
   160  
   161  The `aufs` driver is the oldest, but is based on a Linux kernel patch-set that
   162  is unlikely to be merged into the main kernel. These are also known to cause some
   163  serious kernel crashes. However, `aufs` is also the only storage driver that allows
   164  containers to share executable and shared library memory, so is a useful choice
   165  when running thousands of containers with the same program or libraries.
   166  
   167  The `devicemapper` driver uses thin provisioning and Copy on Write (CoW)
   168  snapshots. For each devicemapper graph location – typically
   169  `/var/lib/docker/devicemapper` – a thin pool is created based on two block
   170  devices, one for data and one for metadata.  By default, these block devices
   171  are created automatically by using loopback mounts of automatically created
   172  sparse files. Refer to [Storage driver options](#storage-driver-options) below
   173  for a way how to customize this setup.
   174  [~jpetazzo/Resizing Docker containers with the Device Mapper plugin](
   175  http://jpetazzo.github.io/2014/01/29/docker-device-mapper-resize/) article
   176  explains how to tune your existing setup without the use of options.
   177  
   178  The `btrfs` driver is very fast for `docker build` - but like `devicemapper` does not
   179  share executable memory between devices. Use `docker -d -s btrfs -g /mnt/btrfs_partition`.
   180  
   181  The `overlay` is a very fast union filesystem. It is now merged in the main
   182  Linux kernel as of [3.18.0](https://lkml.org/lkml/2014/10/26/137).
   183  Call `docker -d -s overlay` to use it. 
   184  > **Note:** 
   185  > It is currently unsupported on `btrfs` or any Copy on Write filesystem
   186  > and should only be used over `ext4` partitions.
   187  
   188  #### Storage driver options
   189  
   190  Particular storage-driver can be configured with options specified with
   191  `--storage-opt` flags. The only driver accepting options is `devicemapper` as
   192  of now. All its options are prefixed with `dm`.
   193  
   194  Currently supported options are:
   195  
   196   *  `dm.basesize`
   197  
   198      Specifies the size to use when creating the base device, which limits the
   199      size of images and containers. The default value is 10G. Note, thin devices
   200      are inherently "sparse", so a 10G device which is mostly empty doesn't use
   201      10 GB of space on the pool. However, the filesystem will use more space for
   202      the empty case the larger the device is.
   203      
   204       **Warning**: This value affects the system-wide "base" empty filesystem
   205       that may already be initialized and inherited by pulled images. Typically,
   206       a change to this value will require additional steps to take effect:
   207      
   208          $ sudo service docker stop
   209          $ sudo rm -rf /var/lib/docker
   210          $ sudo service docker start
   211  
   212      Example use:
   213  
   214          $ sudo docker -d --storage-opt dm.basesize=20G
   215  
   216   *  `dm.loopdatasize`
   217  
   218      Specifies the size to use when creating the loopback file for the "data"
   219      device which is used for the thin pool. The default size is 100G. Note that
   220      the file is sparse, so it will not initially take up this much space.
   221  
   222      Example use:
   223  
   224          $ sudo docker -d --storage-opt dm.loopdatasize=200G
   225  
   226   *  `dm.loopmetadatasize`
   227  
   228      Specifies the size to use when creating the loopback file for the
   229      "metadata" device which is used for the thin pool. The default size is 2G.
   230      Note that the file is sparse, so it will not initially take up this much
   231      space.
   232  
   233      Example use:
   234  
   235          $ sudo docker -d --storage-opt dm.loopmetadatasize=4G
   236  
   237   *  `dm.fs`
   238  
   239      Specifies the filesystem type to use for the base device. The supported
   240      options are "ext4" and "xfs". The default is "ext4"
   241  
   242      Example use:
   243  
   244          $ sudo docker -d --storage-opt dm.fs=xfs
   245  
   246   *  `dm.mkfsarg`
   247  
   248      Specifies extra mkfs arguments to be used when creating the base device.
   249  
   250      Example use:
   251  
   252          $ sudo docker -d --storage-opt "dm.mkfsarg=-O ^has_journal"
   253  
   254   *  `dm.mountopt`
   255  
   256      Specifies extra mount options used when mounting the thin devices.
   257  
   258      Example use:
   259  
   260          $ sudo docker -d --storage-opt dm.mountopt=nodiscard
   261  
   262   *  `dm.datadev`
   263  
   264      Specifies a custom blockdevice to use for data for the thin pool.
   265  
   266      If using a block device for device mapper storage, ideally both datadev and
   267      metadatadev should be specified to completely avoid using the loopback
   268      device.
   269  
   270      Example use:
   271  
   272          $ sudo docker -d \
   273              --storage-opt dm.datadev=/dev/sdb1 \
   274              --storage-opt dm.metadatadev=/dev/sdc1
   275  
   276   *  `dm.metadatadev`
   277  
   278      Specifies a custom blockdevice to use for metadata for the thin pool.
   279  
   280      For best performance the metadata should be on a different spindle than the
   281      data, or even better on an SSD.
   282  
   283      If setting up a new metadata pool it is required to be valid. This can be
   284      achieved by zeroing the first 4k to indicate empty metadata, like this:
   285  
   286          $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1
   287  
   288      Example use:
   289  
   290          $ sudo docker -d \
   291              --storage-opt dm.datadev=/dev/sdb1 \
   292              --storage-opt dm.metadatadev=/dev/sdc1
   293  
   294   *  `dm.blocksize`
   295  
   296      Specifies a custom blocksize to use for the thin pool. The default
   297      blocksize is 64K.
   298  
   299      Example use:
   300  
   301          $ sudo docker -d --storage-opt dm.blocksize=512K
   302  
   303   *  `dm.blkdiscard`
   304  
   305      Enables or disables the use of blkdiscard when removing devicemapper
   306      devices. This is enabled by default (only) if using loopback devices and is
   307      required to res-parsify the loopback file on image/container removal.
   308  
   309      Disabling this on loopback can lead to *much* faster container removal
   310      times, but will make the space used in `/var/lib/docker` directory not be
   311      returned to the system for other use when containers are removed.
   312  
   313      Example use:
   314  
   315          $ sudo docker -d --storage-opt dm.blkdiscard=false
   316  
   317  ### Docker exec-driver option
   318  
   319  The Docker daemon uses a specifically built `libcontainer` execution driver as its
   320  interface to the Linux kernel `namespaces`, `cgroups`, and `SELinux`.
   321  
   322  There is still legacy support for the original [LXC userspace tools](
   323  https://linuxcontainers.org/) via the `lxc` execution driver, however, this is
   324  not where the primary development of new functionality is taking place.
   325  Add `-e lxc` to the daemon flags to use the `lxc` execution driver.
   326  
   327  
   328  ### Daemon DNS options
   329  
   330  To set the DNS server for all Docker containers, use
   331  `docker -d --dns 8.8.8.8`.
   332  
   333  To set the DNS search domain for all Docker containers, use
   334  `docker -d --dns-search example.com`.
   335  
   336  ### Insecure registries
   337  
   338  Docker considers a private registry either secure or insecure.
   339  In the rest of this section, *registry* is used for *private registry*, and `myregistry:5000`
   340  is a placeholder example for a private registry.
   341  
   342  A secure registry uses TLS and a copy of its CA certificate is placed on the Docker host at
   343  `/etc/docker/certs.d/myregistry:5000/ca.crt`.
   344  An insecure registry is either not using TLS (i.e., listening on plain text HTTP), or is using
   345  TLS with a CA certificate not known by the Docker daemon. The latter can happen when the
   346  certificate was not found under `/etc/docker/certs.d/myregistry:5000/`, or if the certificate
   347  verification failed (i.e., wrong CA).
   348  
   349  By default, Docker assumes all, but local (see local registries below), registries are secure.
   350  Communicating with an insecure registry is not possible if Docker assumes that registry is secure.
   351  In order to communicate with an insecure registry, the Docker daemon requires `--insecure-registry`
   352  in one of the following two forms: 
   353  
   354  * `--insecure-registry myregistry:5000` tells the Docker daemon that myregistry:5000 should be considered insecure.
   355  * `--insecure-registry 10.1.0.0/16` tells the Docker daemon that all registries whose domain resolve to an IP address is part
   356  of the subnet described by the CIDR syntax, should be considered insecure.
   357  
   358  The flag can be used multiple times to allow multiple registries to be marked as insecure.
   359  
   360  If an insecure registry is not marked as insecure, `docker pull`, `docker push`, and `docker search`
   361  will result in an error message prompting the user to either secure or pass the `--insecure-registry`
   362  flag to the Docker daemon as described above.
   363  
   364  Local registries, whose IP address falls in the 127.0.0.0/8 range, are automatically marked as insecure
   365  as of Docker 1.3.2. It is not recommended to rely on this, as it may change in the future.
   366  
   367  
   368  ### Miscellaneous options
   369  
   370  IP masquerading uses address translation to allow containers without a public IP to talk
   371  to other machines on the Internet. This may interfere with some network topologies and
   372  can be disabled with --ip-masq=false.
   373  
   374  Docker supports softlinks for the Docker data directory
   375  (`/var/lib/docker`) and for `/var/lib/docker/tmp`. The `DOCKER_TMPDIR` and the data directory can be set like this:
   376  
   377      DOCKER_TMPDIR=/mnt/disk2/tmp /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1
   378      # or
   379      export DOCKER_TMPDIR=/mnt/disk2/tmp
   380      /usr/local/bin/docker -d -D -g /var/lib/docker -H unix:// > /var/lib/boot2docker/docker.log 2>&1
   381  
   382  
   383  ## attach
   384  
   385      Usage: docker attach [OPTIONS] CONTAINER
   386  
   387      Attach to a running container
   388  
   389        --no-stdin=false    Do not attach STDIN
   390        --sig-proxy=true    Proxy all received signals to the process (non-TTY mode only). SIGCHLD, SIGKILL, and SIGSTOP are not proxied.
   391  
   392  The `attach` command lets you view or interact with any running container's
   393  primary process (`pid 1`).
   394  
   395  You can attach to the same contained process multiple times simultaneously, screen
   396  sharing style, or quickly view the progress of your daemonized process.
   397  
   398  > **Note:** This command is not for running a new process in a container.
   399  > See: [`docker exec`](#exec).
   400  
   401  You can detach from the container again (and leave it running) with
   402  `CTRL-p CTRL-q` (for a quiet exit), or `CTRL-c`  which will send a
   403  SIGKILL to the container, or `CTRL-\` to get a stacktrace of the
   404  Docker client when it quits. When you detach from the container's
   405  process the exit code will be returned to the client.
   406  
   407  To stop a container, use `docker stop`.
   408  
   409  To kill the container, use `docker kill`.
   410  
   411  #### Examples
   412  
   413      $ ID=$(sudo docker run -d ubuntu /usr/bin/top -b)
   414      $ sudo docker attach $ID
   415      top - 02:05:52 up  3:05,  0 users,  load average: 0.01, 0.02, 0.05
   416      Tasks:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
   417      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
   418      Mem:    373572k total,   355560k used,    18012k free,    27872k buffers
   419      Swap:   786428k total,        0k used,   786428k free,   221740k cached
   420  
   421      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
   422       1 root      20   0 17200 1116  912 R    0  0.3   0:00.03 top
   423  
   424       top - 02:05:55 up  3:05,  0 users,  load average: 0.01, 0.02, 0.05
   425       Tasks:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
   426       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
   427       Mem:    373572k total,   355244k used,    18328k free,    27872k buffers
   428       Swap:   786428k total,        0k used,   786428k free,   221776k cached
   429  
   430         PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
   431             1 root      20   0 17208 1144  932 R    0  0.3   0:00.03 top
   432  
   433  
   434       top - 02:05:58 up  3:06,  0 users,  load average: 0.01, 0.02, 0.05
   435       Tasks:   1 total,   1 running,   0 sleeping,   0 stopped,   0 zombie
   436       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
   437       Mem:    373572k total,   355780k used,    17792k free,    27880k buffers
   438       Swap:   786428k total,        0k used,   786428k free,   221776k cached
   439  
   440       PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
   441            1 root      20   0 17208 1144  932 R    0  0.3   0:00.03 top
   442      ^C$
   443      $ sudo docker stop $ID
   444  
   445  ## build
   446  
   447      Usage: docker build [OPTIONS] PATH | URL | -
   448  
   449      Build a new image from the source code at PATH
   450  
   451        --force-rm=false     Always remove intermediate containers, even after unsuccessful builds
   452        --no-cache=false     Do not use cache when building the image
   453        -q, --quiet=false    Suppress the verbose output generated by the containers
   454        --rm=true            Remove intermediate containers after a successful build
   455        -t, --tag=""         Repository name (and optionally a tag) to be applied to the resulting image in case of success
   456  
   457  Use this command to build Docker images from a Dockerfile and a
   458  "context".
   459  
   460  The files at `PATH` or `URL` are called the "context" of the build. The
   461  build process may refer to any of the files in the context, for example
   462  when using an [*ADD*](/reference/builder/#add) instruction.
   463  When a single Dockerfile is given as `URL` or is piped through `STDIN`
   464  (`docker build - < Dockerfile`), then no context is set.
   465  
   466  When a Git repository is set as `URL`, then the repository is used as
   467  the context. The Git repository is cloned with its submodules
   468  (`git clone -recursive`). A fresh `git clone` occurs in a temporary directory
   469  on your local host, and then this is sent to the Docker daemon as the
   470  context.  This way, your local user credentials and VPN's etc can be
   471  used to access private repositories.
   472  
   473  If a file named `.dockerignore` exists in the root of `PATH` then it
   474  is interpreted as a newline-separated list of exclusion patterns.
   475  Exclusion patterns match files or directories relative to `PATH` that
   476  will be excluded from the context. Globbing is done using Go's
   477  [filepath.Match](http://golang.org/pkg/path/filepath#Match) rules.
   478  
   479  Please note that `.dockerignore` files in other subdirectories are
   480  considered as normal files. Filepaths in .dockerignore are absolute with
   481  the current directory as the root. Wildcards are allowed but the search
   482  is not recursive.
   483  
   484  #### Example .dockerignore file
   485      */temp*
   486      */*/temp*
   487      temp?
   488  
   489  The first line above `*/temp*`, would ignore all files with names starting with
   490  `temp` from any subdirectory below the root directory. For example, a file named
   491  `/somedir/temporary.txt` would be ignored. The second line `*/*/temp*`, will
   492  ignore files starting with name `temp` from any subdirectory that is two levels
   493  below the root directory. For example, the file `/somedir/subdir/temporary.txt`
   494  would get ignored in this case. The last line in the above example `temp?`
   495  will ignore the files that match the pattern from the root directory.
   496  For example, the files `tempa`, `tempb` are ignored from the root directory.
   497  Currently there is no support for regular expressions. Formats
   498  like `[^temp*]` are ignored.
   499  
   500  
   501  See also:
   502  
   503  [*Dockerfile Reference*](/reference/builder).
   504  
   505  #### Examples
   506  
   507      $ sudo docker build .
   508      Uploading context 10240 bytes
   509      Step 1 : FROM busybox
   510      Pulling repository busybox
   511       ---> e9aa60c60128MB/2.284 MB (100%) endpoint: https://cdn-registry-1.docker.io/v1/
   512      Step 2 : RUN ls -lh /
   513       ---> Running in 9c9e81692ae9
   514      total 24
   515      drwxr-xr-x    2 root     root        4.0K Mar 12  2013 bin
   516      drwxr-xr-x    5 root     root        4.0K Oct 19 00:19 dev
   517      drwxr-xr-x    2 root     root        4.0K Oct 19 00:19 etc
   518      drwxr-xr-x    2 root     root        4.0K Nov 15 23:34 lib
   519      lrwxrwxrwx    1 root     root           3 Mar 12  2013 lib64 -> lib
   520      dr-xr-xr-x  116 root     root           0 Nov 15 23:34 proc
   521      lrwxrwxrwx    1 root     root           3 Mar 12  2013 sbin -> bin
   522      dr-xr-xr-x   13 root     root           0 Nov 15 23:34 sys
   523      drwxr-xr-x    2 root     root        4.0K Mar 12  2013 tmp
   524      drwxr-xr-x    2 root     root        4.0K Nov 15 23:34 usr
   525       ---> b35f4035db3f
   526      Step 3 : CMD echo Hello world
   527       ---> Running in 02071fceb21b
   528       ---> f52f38b7823e
   529      Successfully built f52f38b7823e
   530      Removing intermediate container 9c9e81692ae9
   531      Removing intermediate container 02071fceb21b
   532  
   533  This example specifies that the `PATH` is
   534  `.`, and so all the files in the local directory get
   535  `tar`d and sent to the Docker daemon. The `PATH`
   536  specifies where to find the files for the "context" of the build on the
   537  Docker daemon. Remember that the daemon could be running on a remote
   538  machine and that no parsing of the Dockerfile
   539  happens at the client side (where you're running
   540  `docker build`). That means that *all* the files at
   541  `PATH` get sent, not just the ones listed to
   542  [*ADD*](/reference/builder/#add) in the Dockerfile.
   543  
   544  The transfer of context from the local machine to the Docker daemon is
   545  what the `docker` client means when you see the
   546  "Sending build context" message.
   547  
   548  If you wish to keep the intermediate containers after the build is
   549  complete, you must use `--rm=false`. This does not
   550  affect the build cache.
   551  
   552      $ sudo docker build .
   553      Uploading context 18.829 MB
   554      Uploading context
   555      Step 0 : FROM busybox
   556       ---> 769b9341d937
   557      Step 1 : CMD echo Hello world
   558       ---> Using cache
   559       ---> 99cc1ad10469
   560      Successfully built 99cc1ad10469
   561      $ echo ".git" > .dockerignore
   562      $ sudo docker build .
   563      Uploading context  6.76 MB
   564      Uploading context
   565      Step 0 : FROM busybox
   566       ---> 769b9341d937
   567      Step 1 : CMD echo Hello world
   568       ---> Using cache
   569       ---> 99cc1ad10469
   570      Successfully built 99cc1ad10469
   571  
   572  This example shows the use of the `.dockerignore` file to exclude the `.git`
   573  directory from the context. Its effect can be seen in the changed size of the
   574  uploaded context.
   575  
   576      $ sudo docker build -t vieux/apache:2.0 .
   577  
   578  This will build like the previous example, but it will then tag the
   579  resulting image. The repository name will be `vieux/apache`
   580  and the tag will be `2.0`
   581  
   582      $ sudo docker build - < Dockerfile
   583  
   584  This will read a Dockerfile from `STDIN` without context. Due to the
   585  lack of a context, no contents of any local directory will be sent to
   586  the Docker daemon. Since there is no context, a Dockerfile `ADD` only
   587  works if it refers to a remote URL.
   588  
   589      $ sudo docker build - < context.tar.gz
   590  
   591  This will build an image for a compressed context read from `STDIN`.
   592  Supported formats are: bzip2, gzip and xz.
   593  
   594      $ sudo docker build github.com/creack/docker-firefox
   595  
   596  This will clone the GitHub repository and use the cloned repository as
   597  context. The Dockerfile at the root of the
   598  repository is used as Dockerfile. Note that you
   599  can specify an arbitrary Git repository by using the `git://` or `git@`
   600  schema.
   601  
   602  > **Note:** `docker build` will return a `no such file or directory` error
   603  > if the file or directory does not exist in the uploaded context. This may
   604  > happen if there is no context, or if you specify a file that is elsewhere
   605  > on the Host system. The context is limited to the current directory (and its
   606  > children) for security reasons, and to ensure repeatable builds on remote
   607  > Docker hosts. This is also the reason why `ADD ../file` will not work.
   608  
   609  ## commit
   610  
   611      Usage: docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
   612  
   613      Create a new image from a container's changes
   614  
   615        -a, --author=""     Author (e.g., "John Hannibal Smith <hannibal@a-team.com>")
   616        -m, --message=""    Commit message
   617        -p, --pause=true    Pause container during commit
   618  
   619  It can be useful to commit a container's file changes or settings into a
   620  new image. This allows you debug a container by running an interactive
   621  shell, or to export a working dataset to another server. Generally, it
   622  is better to use Dockerfiles to manage your images in a documented and
   623  maintainable way.
   624  
   625  By default, the container being committed and its processes will be paused
   626  while the image is committed. This reduces the likelihood of
   627  encountering data corruption during the process of creating the commit.
   628  If this behavior is undesired, set the 'p' option to false.
   629  
   630  #### Commit an existing container
   631  
   632      $ sudo docker ps
   633      ID                  IMAGE               COMMAND             CREATED             STATUS              PORTS
   634      c3f279d17e0a        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
   635      197387f1b436        ubuntu:12.04        /bin/bash           7 days ago          Up 25 hours
   636      $ sudo docker commit c3f279d17e0a  SvenDowideit/testimage:version3
   637      f5283438590d
   638      $ sudo docker images | head
   639      REPOSITORY                        TAG                 ID                  CREATED             VIRTUAL SIZE
   640      SvenDowideit/testimage            version3            f5283438590d        16 seconds ago      335.7 MB
   641  
   642  ## cp
   643  
   644  Copy files/folders from a container's filesystem to the host
   645  path.  Paths are relative to the root of the filesystem.
   646  
   647      Usage: docker cp CONTAINER:PATH HOSTPATH
   648  
   649      Copy files/folders from the PATH to the HOSTPATH
   650  
   651  ## create
   652  
   653  Creates a new container.
   654  
   655      Usage: docker create [OPTIONS] IMAGE [COMMAND] [ARG...]
   656  
   657      Create a new container
   658  
   659        -a, --attach=[]            Attach to STDIN, STDOUT or STDERR.
   660        --add-host=[]              Add a custom host-to-IP mapping (host:ip)
   661        -c, --cpu-shares=0         CPU shares (relative weight)
   662        --cap-add=[]               Add Linux capabilities
   663        --cap-drop=[]              Drop Linux capabilities
   664        --cidfile=""               Write the container ID to the file
   665        --cpuset=""                CPUs in which to allow execution (0-3, 0,1)
   666        --device=[]                Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm)
   667        --dns=[]                   Set custom DNS servers
   668        --dns-search=[]            Set custom DNS search domains (Use --dns-search=. if you don't wish to set the search domain)
   669        -e, --env=[]               Set environment variables
   670        --entrypoint=""            Overwrite the default ENTRYPOINT of the image
   671        --env-file=[]              Read in a line delimited file of environment variables
   672        --expose=[]                Expose a port or a range of ports (e.g. --expose=3300-3310) from the container without publishing it to your host
   673        -h, --hostname=""          Container host name
   674        -i, --interactive=false    Keep STDIN open even if not attached
   675        --ipc=""                   Default is to create a private IPC namespace (POSIX SysV IPC) for the container
   676                                     'container:<name|id>': reuses another container shared memory, semaphores and message queues
   677                                     'host': use the host shared memory,semaphores and message queues inside the container.  Note: the host mode gives the container full access to local shared memory and is therefore considered insecure.
   678        --link=[]                  Add link to another container in the form of name:alias
   679        --lxc-conf=[]              (lxc exec-driver only) Add custom lxc options --lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"
   680        -m, --memory=""            Memory limit (format: <number><optional unit>, where unit = b, k, m or g)
   681        --mac-address=""           Container MAC address (e.g. 92:d0:c6:0a:29:33)
   682        --name=""                  Assign a name to the container
   683        --net="bridge"             Set the Network mode for the container
   684                                     'bridge': creates a new network stack for the container on the docker bridge
   685                                     'none': no networking for this container
   686                                     'container:<name|id>': reuses another container network stack
   687                                     'host': use the host network stack inside the container.  Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure.
   688        -P, --publish-all=false    Publish all exposed ports to the host interfaces
   689        -p, --publish=[]           Publish a container's port, or a range of ports (e.g., `-p 3300-3310`), to the host
   690                                     format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort
   691                                     Both hostPort and containerPort can be specified as a range of ports. 
   692                                     When specifying ranges for both, the number of container ports in the range must match the number of host ports in the range. (e.g., `-p 1234-1236:1234-1236/tcp`)
   693                                     (use 'docker port' to see the actual mapping)
   694        --privileged=false         Give extended privileges to this container
   695        --restart=""               Restart policy to apply when a container exits (no, on-failure[:max-retry], always)
   696        --security-opt=[]          Security Options
   697        -t, --tty=false            Allocate a pseudo-TTY
   698        -u, --user=""              Username or UID
   699        -v, --volume=[]            Bind mount a volume (e.g., from the host: -v /host:/container, from Docker: -v /container)
   700        --volumes-from=[]          Mount volumes from the specified container(s)
   701        -w, --workdir=""           Working directory inside the container
   702  
   703  The `docker create` command creates a writeable container layer over
   704  the specified image and prepares it for running the specified command.
   705  The container ID is then printed to `STDOUT`.
   706  This is similar to `docker run -d` except the container is never started.
   707  You can then use the `docker start <container_id>` command to start the
   708  container at any point.
   709  
   710  This is useful when you want to set up a container configuration ahead
   711  of time so that it is ready to start when you need it.
   712  
   713  Note that volumes set by `create` may be over-ridden by options set with
   714  `start`.
   715  
   716  Please see the [run command](#run) section for more details.
   717  
   718  #### Examples
   719  
   720      $ sudo docker create -t -i fedora bash
   721      6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752
   722      $ sudo docker start -a -i 6d8af538ec5
   723      bash-4.2#
   724  
   725  As of v1.4.0 container volumes are initialized during the `docker create`
   726  phase (i.e., `docker run` too). For example, this allows you to `create` the
   727  `data` volume container, and then use it from another container:
   728  
   729      $ docker create -v /data --name data ubuntu
   730      240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57
   731      $ docker run --rm --volumes-from data ubuntu ls -la /data
   732      total 8
   733      drwxr-xr-x  2 root root 4096 Dec  5 04:10 .
   734      drwxr-xr-x 48 root root 4096 Dec  5 04:11 ..
   735  
   736  Similarly, `create` a host directory bind mounted volume container, which
   737  can then be used from the subsequent container:
   738  
   739      $ docker create -v /home/docker:/docker --name docker ubuntu
   740      9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03
   741      $ docker run --rm --volumes-from docker ubuntu ls -la /docker
   742      total 20
   743      drwxr-sr-x  5 1000 staff  180 Dec  5 04:00 .
   744      drwxr-xr-x 48 root root  4096 Dec  5 04:13 ..
   745      -rw-rw-r--  1 1000 staff 3833 Dec  5 04:01 .ash_history
   746      -rw-r--r--  1 1000 staff  446 Nov 28 11:51 .ashrc
   747      -rw-r--r--  1 1000 staff   25 Dec  5 04:00 .gitconfig
   748      drwxr-sr-x  3 1000 staff   60 Dec  1 03:28 .local
   749      -rw-r--r--  1 1000 staff  920 Nov 28 11:51 .profile
   750      drwx--S---  2 1000 staff  460 Dec  5 00:51 .ssh
   751      drwxr-xr-x 32 1000 staff 1140 Dec  5 04:01 docker
   752  
   753  
   754  ## diff
   755  
   756  List the changed files and directories in a container᾿s filesystem
   757  
   758      Usage: docker diff CONTAINER
   759  
   760      Inspect changes on a container's filesystem
   761  
   762  There are 3 events that are listed in the `diff`:
   763  
   764  1.  `A` - Add
   765  2.  `D` - Delete
   766  3.  `C` - Change
   767  
   768  For example:
   769  
   770      $ sudo docker diff 7bb0e258aefe
   771  
   772      C /dev
   773      A /dev/kmsg
   774      C /etc
   775      A /etc/mtab
   776      A /go
   777      A /go/src
   778      A /go/src/github.com
   779      A /go/src/github.com/docker
   780      A /go/src/github.com/docker/docker
   781      A /go/src/github.com/docker/docker/.git
   782      ....
   783  
   784  ## events
   785  
   786      Usage: docker events [OPTIONS]
   787  
   788      Get real time events from the server
   789  
   790        --since=""         Show all events created since timestamp
   791        --until=""         Stream events until this timestamp
   792  
   793  Docker containers will report the following events:
   794  
   795      create, destroy, die, export, kill, oom, pause, restart, start, stop, unpause
   796  
   797  and Docker images will report:
   798  
   799      untag, delete
   800  
   801  #### Filtering
   802  
   803  The filtering flag (`-f` or `--filter`) format is of "key=value". If you would like to use
   804  multiple filters, pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
   805  
   806  Using the same filter multiple times will be handled as a *OR*; for example
   807  `--filter container=588a23dac085 --filter container=a8f7720b8c22` will display events for
   808  container 588a23dac085 *OR* container a8f7720b8c22
   809  
   810  Using multiple filters will be handled as a *AND*; for example
   811  `--filter container=588a23dac085 --filter event=start` will display events for container
   812  container 588a23dac085 *AND* the event type is *start*
   813  
   814  Current filters:
   815   * event
   816   * image
   817   * container
   818  
   819  #### Examples
   820  
   821  You'll need two shells for this example.
   822  
   823  **Shell 1: Listening for events:**
   824  
   825      $ sudo docker events
   826  
   827  **Shell 2: Start and Stop containers:**
   828  
   829      $ sudo docker start 4386fb97867d
   830      $ sudo docker stop 4386fb97867d
   831      $ sudo docker stop 7805c1d35632
   832  
   833  **Shell 1: (Again .. now showing events):**
   834  
   835      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start
   836      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
   837      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
   838      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
   839      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   840  
   841  **Show events in the past from a specified time:**
   842  
   843      $ sudo docker events --since 1378216169
   844      2014-03-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
   845      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
   846      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
   847      2014-03-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   848  
   849      $ sudo docker events --since '2013-09-03'
   850      2014-09-03T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start
   851      2014-09-03T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
   852      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
   853      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
   854      2014-09-03T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   855  
   856      $ sudo docker events --since '2013-09-03 15:49:29 +0200 CEST'
   857      2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
   858      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
   859      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
   860      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   861  
   862  **Filter events:**
   863  
   864      $ sudo docker events --filter 'event=stop'
   865      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
   866      2014-09-03T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   867  
   868      $ sudo docker events --filter 'image=ubuntu-1:14.04'
   869      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) start
   870      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
   871      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
   872  
   873      $ sudo docker events --filter 'container=7805c1d35632'
   874      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
   875      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   876  
   877      $ sudo docker events --filter 'container=7805c1d35632' --filter 'container=4386fb97867d'
   878      2014-09-03T15:49:29.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) die
   879      2014-05-10T17:42:14.999999999Z07:00 4386fb97867d: (from ubuntu-1:14.04) stop
   880      2014-05-10T17:42:14.999999999Z07:00 7805c1d35632: (from redis:2.8) die
   881      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   882  
   883      $ sudo docker events --filter 'container=7805c1d35632' --filter 'event=stop'
   884      2014-09-03T15:49:29.999999999Z07:00 7805c1d35632: (from redis:2.8) stop
   885  
   886  ## exec
   887  
   888      Usage: docker exec [OPTIONS] CONTAINER COMMAND [ARG...]
   889  
   890      Run a command in a running container
   891  
   892        -d, --detach=false         Detached mode: run command in the background
   893        -i, --interactive=false    Keep STDIN open even if not attached
   894        -t, --tty=false            Allocate a pseudo-TTY
   895  
   896  The `docker exec` command runs a new command in a running container.
   897  
   898  The command started using `docker exec` will only run while the container's primary
   899  process (`PID 1`) is running, and will not be restarted if the container is restarted.
   900  
   901  If the container is paused, then the `docker exec` command will fail with an error:
   902  
   903      $ docker pause test
   904      test
   905      $ docker ps
   906      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                   PORTS               NAMES
   907      1ae3b36715d2        ubuntu:latest       "bash"              17 seconds ago      Up 16 seconds (Paused)                       test
   908      $ docker exec test ls
   909      FATA[0000] Error response from daemon: Container test is paused, unpause the container before exec
   910      $ echo $?
   911      1
   912  
   913  #### Examples
   914  
   915      $ sudo docker run --name ubuntu_bash --rm -i -t ubuntu bash
   916  
   917  This will create a container named `ubuntu_bash` and start a Bash session.
   918  
   919      $ sudo docker exec -d ubuntu_bash touch /tmp/execWorks
   920  
   921  This will create a new file `/tmp/execWorks` inside the running container
   922  `ubuntu_bash`, in the background.
   923  
   924      $ sudo docker exec -it ubuntu_bash bash
   925  
   926  This will create a new Bash session in the container `ubuntu_bash`.
   927  
   928  ## export
   929  
   930      Usage: docker export CONTAINER
   931  
   932      Export the contents of a filesystem as a tar archive to STDOUT
   933  
   934  For example:
   935  
   936      $ sudo docker export red_panda > latest.tar
   937  
   938  ## history
   939  
   940      Usage: docker history [OPTIONS] IMAGE
   941  
   942      Show the history of an image
   943  
   944        --no-trunc=false     Don't truncate output
   945        -q, --quiet=false    Only show numeric IDs
   946  
   947  To see how the `docker:latest` image was built:
   948  
   949      $ sudo docker history docker
   950      IMAGE                                                              CREATED             CREATED BY                                                                                                                                                 SIZE
   951      3e23a5875458790b7a806f95f7ec0d0b2a5c1659bfc899c89f939f6d5b8f7094   8 days ago          /bin/sh -c #(nop) ENV LC_ALL=C.UTF-8                                                                                                                       0 B
   952      8578938dd17054dce7993d21de79e96a037400e8d28e15e7290fea4f65128a36   8 days ago          /bin/sh -c dpkg-reconfigure locales &&    locale-gen C.UTF-8 &&    /usr/sbin/update-locale LANG=C.UTF-8                                                    1.245 MB
   953      be51b77efb42f67a5e96437b3e102f81e0a1399038f77bf28cea0ed23a65cf60   8 days ago          /bin/sh -c apt-get update && apt-get install -y    git    libxml2-dev    python    build-essential    make    gcc    python-dev    locales    python-pip   338.3 MB
   954      4b137612be55ca69776c7f30c2d2dd0aa2e7d72059820abf3e25b629f887a084   6 weeks ago         /bin/sh -c #(nop) ADD jessie.tar.xz in /                                                                                                                   121 MB
   955      750d58736b4b6cc0f9a9abe8f258cef269e3e9dceced1146503522be9f985ada   6 weeks ago         /bin/sh -c #(nop) MAINTAINER Tianon Gravi <admwiggin@gmail.com> - mkimage-debootstrap.sh -t jessie.tar.xz jessie http://http.debian.net/debian             0 B
   956      511136ea3c5a64f264b78b5433614aec563103b4d4702f3ba7d4d2698e22c158   9 months ago                                                                                                                                                                   0 B
   957  
   958  ## images
   959  
   960      Usage: docker images [OPTIONS] [REPOSITORY]
   961  
   962      List images
   963  
   964        -a, --all=false      Show all images (by default filter out the intermediate image layers)
   965        -f, --filter=[]      Provide filter values (i.e. 'dangling=true')
   966        --no-trunc=false     Don't truncate output
   967        -q, --quiet=false    Only show numeric IDs
   968  
   969  The default `docker images` will show all top level
   970  images, their repository and tags, and their virtual size.
   971  
   972  Docker images have intermediate layers that increase reusability,
   973  decrease disk usage, and speed up `docker build` by
   974  allowing each step to be cached. These intermediate layers are not shown
   975  by default.
   976  
   977  The `VIRTUAL SIZE` is the cumulative space taken up by the image and all
   978  its parent images. This is also the disk space used by the contents of the
   979  Tar file created when you `docker save` an image.
   980  
   981  An image will be listed more than once if it has multiple repository names
   982  or tags. This single image (identifiable by its matching `IMAGE ID`)
   983  uses up the `VIRTUAL SIZE` listed only once.
   984  
   985  #### Listing the most recently created images
   986  
   987      $ sudo docker images | head
   988      REPOSITORY                TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
   989      <none>                    <none>              77af4d6b9913        19 hours ago        1.089 GB
   990      committ                   latest              b6fa739cedf5        19 hours ago        1.089 GB
   991      <none>                    <none>              78a85c484f71        19 hours ago        1.089 GB
   992      docker                    latest              30557a29d5ab        20 hours ago        1.089 GB
   993      <none>                    <none>              5ed6274db6ce        24 hours ago        1.089 GB
   994      postgres                  9                   746b819f315e        4 days ago          213.4 MB
   995      postgres                  9.3                 746b819f315e        4 days ago          213.4 MB
   996      postgres                  9.3.5               746b819f315e        4 days ago          213.4 MB
   997      postgres                  latest              746b819f315e        4 days ago          213.4 MB
   998  
   999  
  1000  #### Listing the full length image IDs
  1001  
  1002      $ sudo docker images --no-trunc | head
  1003      REPOSITORY                    TAG                 IMAGE ID                                                           CREATED             VIRTUAL SIZE
  1004      <none>                        <none>              77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182   19 hours ago        1.089 GB
  1005      committest                    latest              b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f   19 hours ago        1.089 GB
  1006      <none>                        <none>              78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921   19 hours ago        1.089 GB
  1007      docker                        latest              30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4   20 hours ago        1.089 GB
  1008      <none>                        <none>              0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5   20 hours ago        1.089 GB
  1009      <none>                        <none>              18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b   22 hours ago        1.082 GB
  1010      <none>                        <none>              f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a   23 hours ago        1.089 GB
  1011      tryout                        latest              2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074   23 hours ago        131.5 MB
  1012      <none>                        <none>              5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df   24 hours ago        1.089 GB
  1013  
  1014  #### Filtering
  1015  
  1016  The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
  1017  than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
  1018  
  1019  Current filters:
  1020   * dangling (boolean - true or false)
  1021  
  1022  ##### Untagged images
  1023  
  1024      $ sudo docker images --filter "dangling=true"
  1025  
  1026      REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
  1027      <none>              <none>              8abc22fbb042        4 weeks ago         0 B
  1028      <none>              <none>              48e5f45168b9        4 weeks ago         2.489 MB
  1029      <none>              <none>              bf747efa0e2f        4 weeks ago         0 B
  1030      <none>              <none>              980fe10e5736        12 weeks ago        101.4 MB
  1031      <none>              <none>              dea752e4e117        12 weeks ago        101.4 MB
  1032      <none>              <none>              511136ea3c5a        8 months ago        0 B
  1033  
  1034  This will display untagged images, that are the leaves of the images tree (not
  1035  intermediary layers). These images occur when a new build of an image takes the
  1036  `repo:tag` away from the image ID, leaving it untagged. A warning will be issued
  1037  if trying to remove an image when a container is presently using it.
  1038  By having this flag it allows for batch cleanup.
  1039  
  1040  Ready for use by `docker rmi ...`, like:
  1041  
  1042      $ sudo docker rmi $(sudo docker images -f "dangling=true" -q)
  1043  
  1044      8abc22fbb042
  1045      48e5f45168b9
  1046      bf747efa0e2f
  1047      980fe10e5736
  1048      dea752e4e117
  1049      511136ea3c5a
  1050  
  1051  NOTE: Docker will warn you if any containers exist that are using these untagged images.
  1052  
  1053  ## import
  1054  
  1055      Usage: docker import URL|- [REPOSITORY[:TAG]]
  1056  
  1057      Create an empty filesystem image and import the contents of the tarball (.tar, .tar.gz, .tgz, .bzip, .tar.xz, .txz) into it, then optionally tag it.
  1058  
  1059  URLs must start with `http` and point to a single file archive (.tar,
  1060  .tar.gz, .tgz, .bzip, .tar.xz, or .txz) containing a root filesystem. If
  1061  you would like to import from a local directory or archive, you can use
  1062  the `-` parameter to take the data from `STDIN`.
  1063  
  1064  #### Examples
  1065  
  1066  **Import from a remote location:**
  1067  
  1068  This will create a new untagged image.
  1069  
  1070      $ sudo docker import http://example.com/exampleimage.tgz
  1071  
  1072  **Import from a local file:**
  1073  
  1074  Import to docker via pipe and `STDIN`.
  1075  
  1076      $ cat exampleimage.tgz | sudo docker import - exampleimagelocal:new
  1077  
  1078  **Import from a local directory:**
  1079  
  1080      $ sudo tar -c . | sudo docker import - exampleimagedir
  1081  
  1082  Note the `sudo` in this example – you must preserve
  1083  the ownership of the files (especially root ownership) during the
  1084  archiving with tar. If you are not root (or the sudo command) when you
  1085  tar, then the ownerships might not get preserved.
  1086  
  1087  ## info
  1088  
  1089  
  1090      Usage: docker info
  1091  
  1092      Display system-wide information
  1093  
  1094  For example:
  1095  
  1096      $ sudo docker -D info
  1097      Containers: 14
  1098      Images: 52
  1099      Storage Driver: aufs
  1100       Root Dir: /var/lib/docker/aufs
  1101       Dirs: 545
  1102      Execution Driver: native-0.2
  1103      Kernel Version: 3.13.0-24-generic
  1104      Operating System: Ubuntu 14.04 LTS
  1105      CPUs: 1
  1106      Name: prod-server-42
  1107      ID: 7TRN:IPZB:QYBB:VPBQ:UMPP:KARE:6ZNR:XE6T:7EWV:PKF4:ZOJD:TPYS
  1108      Total Memory: 2 GiB
  1109      Debug mode (server): false
  1110      Debug mode (client): true
  1111      Fds: 10
  1112      Goroutines: 9
  1113      EventsListeners: 0
  1114      Init Path: /usr/bin/docker
  1115      Docker Root Dir: /var/lib/docker
  1116      Username: svendowideit
  1117      Registry: [https://index.docker.io/v1/]
  1118      Labels:
  1119       storage=ssd
  1120  
  1121  The global `-D` option tells all `docker` commands to output debug information.
  1122  
  1123  When sending issue reports, please use `docker version` and `docker -D info` to
  1124  ensure we know how your setup is configured.
  1125  
  1126  ## inspect
  1127  
  1128      Usage: docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]
  1129  
  1130      Return low-level information on a container or image
  1131  
  1132        -f, --format=""    Format the output using the given go template.
  1133  
  1134  By default, this will render all results in a JSON array. If a format is
  1135  specified, the given template will be executed for each result.
  1136  
  1137  Go's [text/template](http://golang.org/pkg/text/template/) package
  1138  describes all the details of the format.
  1139  
  1140  #### Examples
  1141  
  1142  **Get an instance's IP address:**
  1143  
  1144  For the most part, you can pick out any field from the JSON in a fairly
  1145  straightforward manner.
  1146  
  1147      $ sudo docker inspect --format='{{.NetworkSettings.IPAddress}}' $INSTANCE_ID
  1148  
  1149  **Get an instance's MAC Address:**
  1150  
  1151  For the most part, you can pick out any field from the JSON in a fairly
  1152  straightforward manner.
  1153  
  1154      $ sudo docker inspect --format='{{.NetworkSettings.MacAddress}}' $INSTANCE_ID
  1155  
  1156  **List All Port Bindings:**
  1157  
  1158  One can loop over arrays and maps in the results to produce simple text
  1159  output:
  1160  
  1161      $ sudo docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
  1162  
  1163  **Find a Specific Port Mapping:**
  1164  
  1165  The `.Field` syntax doesn't work when the field name begins with a
  1166  number, but the template language's `index` function does. The
  1167  `.NetworkSettings.Ports` section contains a map of the internal port
  1168  mappings to a list of external address/port objects, so to grab just the
  1169  numeric public port, you use `index` to find the specific port map, and
  1170  then `index` 0 contains the first object inside of that. Then we ask for
  1171  the `HostPort` field to get the public address.
  1172  
  1173      $ sudo docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
  1174  
  1175  **Get config:**
  1176  
  1177  The `.Field` syntax doesn't work when the field contains JSON data, but
  1178  the template language's custom `json` function does. The `.config`
  1179  section contains complex JSON object, so to grab it as JSON, you use
  1180  `json` to convert the configuration object into JSON.
  1181  
  1182      $ sudo docker inspect --format='{{json .config}}' $INSTANCE_ID
  1183  
  1184  ## kill
  1185  
  1186      Usage: docker kill [OPTIONS] CONTAINER [CONTAINER...]
  1187  
  1188      Kill a running container using SIGKILL or a specified signal
  1189  
  1190        -s, --signal="KILL"    Signal to send to the container
  1191  
  1192  The main process inside the container will be sent `SIGKILL`, or any
  1193  signal specified with option `--signal`.
  1194  
  1195  ## load
  1196  
  1197      Usage: docker load [OPTIONS]
  1198  
  1199      Load an image from a tar archive on STDIN
  1200  
  1201        -i, --input=""     Read from a tar archive file, instead of STDIN
  1202  
  1203  Loads a tarred repository from a file or the standard input stream.
  1204  Restores both images and tags.
  1205  
  1206      $ sudo docker images
  1207      REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
  1208      $ sudo docker load < busybox.tar
  1209      $ sudo docker images
  1210      REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
  1211      busybox             latest              769b9341d937        7 weeks ago         2.489 MB
  1212      $ sudo docker load --input fedora.tar
  1213      $ sudo docker images
  1214      REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
  1215      busybox             latest              769b9341d937        7 weeks ago         2.489 MB
  1216      fedora              rawhide             0d20aec6529d        7 weeks ago         387 MB
  1217      fedora              20                  58394af37342        7 weeks ago         385.5 MB
  1218      fedora              heisenbug           58394af37342        7 weeks ago         385.5 MB
  1219      fedora              latest              58394af37342        7 weeks ago         385.5 MB
  1220  
  1221  ## login
  1222  
  1223      Usage: docker login [OPTIONS] [SERVER]
  1224  
  1225      Register or log in to a Docker registry server, if no server is specified "https://index.docker.io/v1/" is the default.
  1226  
  1227        -e, --email=""       Email
  1228        -p, --password=""    Password
  1229        -u, --username=""    Username
  1230  
  1231  If you want to login to a self-hosted registry you can specify this by
  1232  adding the server name.
  1233  
  1234      example:
  1235      $ sudo docker login localhost:8080
  1236  
  1237  ## logout
  1238  
  1239      Usage: docker logout [SERVER]
  1240  
  1241      Log out from a Docker registry, if no server is specified "https://index.docker.io/v1/" is the default.
  1242  
  1243  For example:
  1244  
  1245      $ sudo docker logout localhost:8080
  1246  
  1247  ## logs
  1248  
  1249      Usage: docker logs [OPTIONS] CONTAINER
  1250  
  1251      Fetch the logs of a container
  1252  
  1253        -f, --follow=false        Follow log output
  1254        -t, --timestamps=false    Show timestamps
  1255        --tail="all"              Output the specified number of lines at the end of logs (defaults to all logs)
  1256  
  1257  The `docker logs` command batch-retrieves logs present at the time of execution.
  1258  
  1259  The `docker logs --follow` command will continue streaming the new output from
  1260  the container's `STDOUT` and `STDERR`.
  1261  
  1262  Passing a negative number or a non-integer to `--tail` is invalid and the
  1263  value is set to `all` in that case. This behavior may change in the future.
  1264  
  1265  The `docker logs --timestamp` commands will add an RFC3339Nano
  1266  timestamp, for example `2014-09-16T06:17:46.000000000Z`, to each
  1267  log entry. To ensure that the timestamps for are aligned the
  1268  nano-second part of the timestamp will be padded with zero when necessary.
  1269  
  1270  ## port
  1271  
  1272      Usage: docker port CONTAINER [PRIVATE_PORT[/PROTO]]
  1273  
  1274      List port mappings for the CONTAINER, or lookup the public-facing port that is NAT-ed to the PRIVATE_PORT
  1275  
  1276  You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or
  1277  just a specific mapping:
  1278  
  1279      $ sudo docker ps test
  1280      CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS                                            NAMES
  1281      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
  1282      $ sudo docker port test
  1283      7890/tcp -> 0.0.0.0:4321
  1284      9876/tcp -> 0.0.0.0:1234
  1285      $ sudo docker port test 7890/tcp
  1286      0.0.0.0:4321
  1287      $ sudo docker port test 7890/udp
  1288      2014/06/24 11:53:36 Error: No public port '7890/udp' published for test
  1289      $ sudo docker port test 7890
  1290      0.0.0.0:4321
  1291  
  1292  ## pause
  1293  
  1294      Usage: docker pause CONTAINER
  1295  
  1296      Pause all processes within a container
  1297  
  1298  The `docker pause` command uses the cgroups freezer to suspend all processes in
  1299  a container.  Traditionally when suspending a process the `SIGSTOP` signal is
  1300  used, which is observable by the process being suspended. With the cgroups freezer
  1301  the process is unaware, and unable to capture, that it is being suspended,
  1302  and subsequently resumed.
  1303  
  1304  See the
  1305  [cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt)
  1306  for further details.
  1307  
  1308  ## ps
  1309  
  1310      Usage: docker ps [OPTIONS]
  1311  
  1312      List containers
  1313  
  1314        -a, --all=false       Show all containers. Only running containers are shown by default.
  1315        --before=""           Show only container created before Id or Name, include non-running ones.
  1316        -f, --filter=[]       Provide filter values. Valid filters:
  1317                                exited=<int> - containers with exit code of <int>
  1318                                status=(restarting|running|paused|exited)
  1319        -l, --latest=false    Show only the latest created container, include non-running ones.
  1320        -n=-1                 Show n last created containers, include non-running ones.
  1321        --no-trunc=false      Don't truncate output
  1322        -q, --quiet=false     Only display numeric IDs
  1323        -s, --size=false      Display total file sizes
  1324        --since=""            Show only containers created since Id or Name, include non-running ones.
  1325  
  1326  Running `docker ps` showing 2 linked containers.
  1327  
  1328      $ sudo docker ps
  1329      CONTAINER ID        IMAGE                        COMMAND                CREATED              STATUS              PORTS               NAMES
  1330      4c01db0b339c        ubuntu:12.04                 bash                   17 seconds ago       Up 16 seconds                           webapp
  1331      d7886598dbe2        crosbymichael/redis:latest   /redis-server --dir    33 minutes ago       Up 33 minutes       6379/tcp            redis,webapp/db
  1332  
  1333  `docker ps` will show only running containers by default. To see all containers:
  1334  `docker ps -a`
  1335  
  1336  #### Filtering
  1337  
  1338  The filtering flag (`-f` or `--filter)` format is a `key=value` pair. If there is more
  1339  than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`)
  1340  
  1341  Current filters:
  1342   * exited (int - the code of exited containers. Only useful with '--all')
  1343   * status (restarting|running|paused|exited)
  1344  
  1345  ##### Successfully exited containers
  1346  
  1347      $ sudo docker ps -a --filter 'exited=0'
  1348      CONTAINER ID        IMAGE             COMMAND                CREATED             STATUS                   PORTS                      NAMES
  1349      ea09c3c82f6e        registry:latest   /srv/run.sh            2 weeks ago         Exited (0) 2 weeks ago   127.0.0.1:5000->5000/tcp   desperate_leakey
  1350      106ea823fe4e        fedora:latest     /bin/sh -c 'bash -l'   2 weeks ago         Exited (0) 2 weeks ago                              determined_albattani
  1351      48ee228c9464        fedora:20         bash                   2 weeks ago         Exited (0) 2 weeks ago                              tender_torvalds
  1352  
  1353  This shows all the containers that have exited with status of '0'
  1354  
  1355  ## pull
  1356  
  1357      Usage: docker pull [OPTIONS] NAME[:TAG]
  1358  
  1359      Pull an image or a repository from the registry
  1360  
  1361        -a, --all-tags=false    Download all tagged images in the repository
  1362  
  1363  Most of your images will be created on top of a base image from the
  1364  [Docker Hub](https://hub.docker.com) registry.
  1365  
  1366  [Docker Hub](https://hub.docker.com) contains many pre-built images that you
  1367  can `pull` and try without needing to define and configure your own.
  1368  
  1369  It is also possible to manually specify the path of a registry to pull from.
  1370  For example, if you have set up a local registry, you can specify its path to
  1371  pull from it. A repository path is similar to a URL, but does not contain
  1372  a protocol specifier (`https://`, for example).
  1373  
  1374  To download a particular image, or set of images (i.e., a repository),
  1375  use `docker pull`:
  1376  
  1377      $ sudo docker pull debian
  1378      # will pull the debian:latest image, its intermediate layers
  1379      # and any aliases of the same id
  1380      $ sudo docker pull debian:testing
  1381      # will pull the image named debian:testing and any intermediate
  1382      # layers it is based on.
  1383      # (Typically the empty `scratch` image, a MAINTAINER layer,
  1384      # and the un-tarred base).
  1385      $ sudo docker pull --all-tags centos
  1386      # will pull all the images from the centos repository
  1387      $ sudo docker pull registry.hub.docker.com/debian
  1388      # manually specifies the path to the default Docker registry. This could
  1389      # be replaced with the path to a local registry to pull from another source.
  1390  
  1391  ## push
  1392  
  1393      Usage: docker push NAME[:TAG]
  1394  
  1395      Push an image or a repository to the registry
  1396  
  1397  Use `docker push` to share your images to the [Docker Hub](https://hub.docker.com)
  1398  registry or to a self-hosted one.
  1399  
  1400  ## restart
  1401  
  1402      Usage: docker restart [OPTIONS] CONTAINER [CONTAINER...]
  1403  
  1404      Restart a running container
  1405  
  1406        -t, --time=10      Number of seconds to try to stop for before killing the container. Once killed it will then be restarted. Default is 10 seconds.
  1407  
  1408  ## rm
  1409  
  1410      Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
  1411  
  1412      Remove one or more containers
  1413  
  1414        -f, --force=false      Force the removal of a running container (uses SIGKILL)
  1415        -l, --link=false       Remove the specified link and not the underlying container
  1416        -v, --volumes=false    Remove the volumes associated with the container
  1417  
  1418  #### Examples
  1419  
  1420      $ sudo docker rm /redis
  1421      /redis
  1422  
  1423  This will remove the container referenced under the link
  1424  `/redis`.
  1425  
  1426      $ sudo docker rm --link /webapp/redis
  1427      /webapp/redis
  1428  
  1429  This will remove the underlying link between `/webapp` and the `/redis`
  1430  containers removing all network communication.
  1431  
  1432      $ sudo docker rm --force redis
  1433      redis
  1434  
  1435  The main process inside the container referenced under the link `/redis` will receive
  1436  `SIGKILL`, then the container will be removed.
  1437  
  1438  This command will delete all stopped containers. The command `docker ps
  1439  -a -q` will return all existing container IDs and pass them to the `rm`
  1440  command which will delete them. Any running containers will not be
  1441  deleted.
  1442  
  1443  ## rmi
  1444  
  1445      Usage: docker rmi [OPTIONS] IMAGE [IMAGE...]
  1446  
  1447      Remove one or more images
  1448  
  1449        -f, --force=false    Force removal of the image
  1450        --no-prune=false     Do not delete untagged parents
  1451  
  1452  #### Removing tagged images
  1453  
  1454  Images can be removed either by their short or long IDs, or their image
  1455  names. If an image has more than one name, each of them needs to be
  1456  removed before the image is removed.
  1457  
  1458      $ sudo docker images
  1459      REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
  1460      test1                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1461      test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1462      test2                     latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1463  
  1464      $ sudo docker rmi fd484f19954f
  1465      Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories
  1466      2013/12/11 05:47:16 Error: failed to remove one or more images
  1467  
  1468      $ sudo docker rmi test1
  1469      Untagged: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
  1470      $ sudo docker rmi test2
  1471      Untagged: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
  1472  
  1473      $ sudo docker images
  1474      REPOSITORY                TAG                 IMAGE ID            CREATED             SIZE
  1475      test                      latest              fd484f19954f        23 seconds ago      7 B (virtual 4.964 MB)
  1476      $ sudo docker rmi test
  1477      Untagged: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
  1478      Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
  1479  
  1480  ## run
  1481  
  1482      Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
  1483  
  1484      Run a command in a new container
  1485  
  1486        -a, --attach=[]            Attach to STDIN, STDOUT or STDERR.
  1487        --add-host=[]              Add a custom host-to-IP mapping (host:ip)
  1488        -c, --cpu-shares=0         CPU shares (relative weight)
  1489        --cap-add=[]               Add Linux capabilities
  1490        --cap-drop=[]              Drop Linux capabilities
  1491        --cidfile=""               Write the container ID to the file
  1492        --cpuset=""                CPUs in which to allow execution (0-3, 0,1)
  1493        -d, --detach=false         Detached mode: run the container in the background and print the new container ID
  1494        --device=[]                Add a host device to the container (e.g. --device=/dev/sdc:/dev/xvdc:rwm)
  1495        --dns=[]                   Set custom DNS servers
  1496        --dns-search=[]            Set custom DNS search domains (Use --dns-search=. if you don't wish to set the search domain)
  1497        -e, --env=[]               Set environment variables
  1498        --entrypoint=""            Overwrite the default ENTRYPOINT of the image
  1499        --env-file=[]              Read in a line delimited file of environment variables
  1500        --expose=[]                Expose a port or a range of ports (e.g. --expose=3300-3310) from the container without publishing it to your host
  1501        -h, --hostname=""          Container host name
  1502        -i, --interactive=false    Keep STDIN open even if not attached
  1503        --ipc=""                   Default is to create a private IPC namespace (POSIX SysV IPC) for the container
  1504                                     'container:<name|id>': reuses another container shared memory, semaphores and message queues
  1505                                     'host': use the host shared memory,semaphores and message queues inside the container.  Note: the host mode gives the container full access to local shared memory and is therefore considered insecure.
  1506        --link=[]                  Add link to another container in the form of name:alias
  1507        --lxc-conf=[]              (lxc exec-driver only) Add custom lxc options --lxc-conf="lxc.cgroup.cpuset.cpus = 0,1"
  1508        -m, --memory=""            Memory limit (format: <number><optional unit>, where unit = b, k, m or g)
  1509        --mac-address=""           Container MAC address (e.g. 92:d0:c6:0a:29:33)
  1510        --name=""                  Assign a name to the container
  1511        --net="bridge"             Set the Network mode for the container
  1512                                     'bridge': creates a new network stack for the container on the docker bridge
  1513                                     'none': no networking for this container
  1514                                     'container:<name|id>': reuses another container network stack
  1515                                     'host': use the host network stack inside the container.  Note: the host mode gives the container full access to local system services such as D-bus and is therefore considered insecure.
  1516        -P, --publish-all=false    Publish all exposed ports to the host interfaces
  1517        -p, --publish=[]           Publish a container's port to the host
  1518                                     format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort
  1519                                     Both hostPort and containerPort can be specified as a range of ports. 
  1520                                     When specifying ranges for both, the number of container ports in the range must match the number of host ports in the range. (e.g., `-p 1234-1236:1234-1236/tcp`)
  1521                                     (use 'docker port' to see the actual mapping)
  1522        --privileged=false         Give extended privileges to this container
  1523        --restart=""               Restart policy to apply when a container exits (no, on-failure[:max-retry], always)
  1524        --rm=false                 Automatically remove the container when it exits (incompatible with -d)
  1525        --security-opt=[]          Security Options
  1526        --sig-proxy=true           Proxy received signals to the process (non-TTY mode only). SIGCHLD, SIGSTOP, and SIGKILL are not proxied.
  1527        -t, --tty=false            Allocate a pseudo-TTY
  1528        -u, --user=""              Username or UID
  1529        -v, --volume=[]            Bind mount a volume (e.g., from the host: -v /host:/container, from Docker: -v /container)
  1530        --volumes-from=[]          Mount volumes from the specified container(s)
  1531        -w, --workdir=""           Working directory inside the container
  1532  
  1533  The `docker run` command first `creates` a writeable container layer over the
  1534  specified image, and then `starts` it using the specified command. That is,
  1535  `docker run` is equivalent to the API `/containers/create` then
  1536  `/containers/(id)/start`. A stopped container can be restarted with all its
  1537  previous changes intact using `docker start`. See `docker ps -a` to view a list
  1538  of all containers.
  1539  
  1540  There is detailed information about `docker run` in the [Docker run reference](
  1541  /reference/run/).
  1542  
  1543  The `docker run` command can be used in combination with `docker commit` to
  1544  [*change the command that a container runs*](#commit-an-existing-container).
  1545  
  1546  See the [Docker User Guide](/userguide/dockerlinks/) for more detailed
  1547  information about the `--expose`, `-p`, `-P` and `--link` parameters,
  1548  and linking containers.
  1549  
  1550  #### Examples
  1551  
  1552      $ sudo docker run --cidfile /tmp/docker_test.cid ubuntu echo "test"
  1553  
  1554  This will create a container and print `test` to the console. The `cidfile`
  1555  flag makes Docker attempt to create a new file and write the container ID to it.
  1556  If the file exists already, Docker will return an error. Docker will close this
  1557  file when `docker run` exits.
  1558  
  1559      $ sudo docker run -t -i --rm ubuntu bash
  1560      root@bc338942ef20:/# mount -t tmpfs none /mnt
  1561      mount: permission denied
  1562  
  1563  This will *not* work, because by default, most potentially dangerous kernel
  1564  capabilities are dropped; including `cap_sys_admin` (which is required to mount
  1565  filesystems). However, the `--privileged` flag will allow it to run:
  1566  
  1567      $ sudo docker run --privileged ubuntu bash
  1568      root@50e3f57e16e6:/# mount -t tmpfs none /mnt
  1569      root@50e3f57e16e6:/# df -h
  1570      Filesystem      Size  Used Avail Use% Mounted on
  1571      none            1.9G     0  1.9G   0% /mnt
  1572  
  1573  The `--privileged` flag gives *all* capabilities to the container, and it also
  1574  lifts all the limitations enforced by the `device` cgroup controller. In other
  1575  words, the container can then do almost everything that the host can do. This
  1576  flag exists to allow special use-cases, like running Docker within Docker.
  1577  
  1578      $ sudo docker  run -w /path/to/dir/ -i -t  ubuntu pwd
  1579  
  1580  The `-w` lets the command being executed inside directory given, here
  1581  `/path/to/dir/`. If the path does not exists it is created inside the container.
  1582  
  1583      $ sudo docker  run  -v `pwd`:`pwd` -w `pwd` -i -t  ubuntu pwd
  1584  
  1585  The `-v` flag mounts the current working directory into the container. The `-w`
  1586  lets the command being executed inside the current working directory, by
  1587  changing into the directory to the value returned by `pwd`. So this
  1588  combination executes the command using the container, but inside the
  1589  current working directory.
  1590  
  1591      $ sudo docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash
  1592  
  1593  When the host directory of a bind-mounted volume doesn't exist, Docker
  1594  will automatically create this directory on the host for you. In the
  1595  example above, Docker will create the `/doesnt/exist`
  1596  folder before starting your container.
  1597  
  1598      $ sudo docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v ./static-docker:/usr/bin/docker busybox sh
  1599  
  1600  By bind-mounting the docker unix socket and statically linked docker
  1601  binary (such as that provided by [https://get.docker.com](
  1602  https://get.docker.com)), you give the container the full access to create and
  1603  manipulate the host's Docker daemon.
  1604  
  1605      $ sudo docker run -p 127.0.0.1:80:8080 ubuntu bash
  1606  
  1607  This binds port `8080` of the container to port `80` on `127.0.0.1` of
  1608  the host machine. The [Docker User Guide](/userguide/dockerlinks/)
  1609  explains in detail how to manipulate ports in Docker.
  1610  
  1611      $ sudo docker run --expose 80 ubuntu bash
  1612  
  1613  This exposes port `80` of the container for use within a link without
  1614  publishing the port to the host system's interfaces. The [Docker User
  1615  Guide](/userguide/dockerlinks) explains in detail how to manipulate
  1616  ports in Docker.
  1617  
  1618      $ sudo docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash
  1619  
  1620  This sets environmental variables in the container. For illustration all three
  1621  flags are shown here. Where `-e`, `--env` take an environment variable and
  1622  value, or if no "=" is provided, then that variable's current value is passed
  1623  through (i.e. `$MYVAR1` from the host is set to `$MYVAR1` in the container). All
  1624  three flags, `-e`, `--env` and `--env-file` can be repeated.
  1625  
  1626  Regardless of the order of these three flags, the `--env-file` are processed
  1627  first, and then `-e`, `--env` flags. This way, the `-e` or `--env` will
  1628  override variables as needed.
  1629  
  1630      $ cat ./env.list
  1631      TEST_FOO=BAR
  1632      $ sudo docker run --env TEST_FOO="This is a test" --env-file ./env.list busybox env | grep TEST_FOO
  1633      TEST_FOO=This is a test
  1634  
  1635  The `--env-file` flag takes a filename as an argument and expects each line
  1636  to be in the `VAR=VAL` format, mimicking the argument passed to `--env`. Comment
  1637  lines need only be prefixed with `#`
  1638  
  1639  An example of a file passed with `--env-file`
  1640  
  1641      $ cat ./env.list
  1642      TEST_FOO=BAR
  1643  
  1644      # this is a comment
  1645      TEST_APP_DEST_HOST=10.10.0.127
  1646      TEST_APP_DEST_PORT=8888
  1647  
  1648      # pass through this variable from the caller
  1649      TEST_PASSTHROUGH
  1650      $ sudo TEST_PASSTHROUGH=howdy docker run --env-file ./env.list busybox env
  1651      HOME=/
  1652      PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
  1653      HOSTNAME=5198e0745561
  1654      TEST_FOO=BAR
  1655      TEST_APP_DEST_HOST=10.10.0.127
  1656      TEST_APP_DEST_PORT=8888
  1657      TEST_PASSTHROUGH=howdy
  1658  
  1659      $ sudo docker run --name console -t -i ubuntu bash
  1660  
  1661  This will create and run a new container with the container name being
  1662  `console`.
  1663  
  1664      $ sudo docker run --link /redis:redis --name console ubuntu bash
  1665  
  1666  The `--link` flag will link the container named `/redis` into the newly
  1667  created container with the alias `redis`. The new container can access the
  1668  network and environment of the `redis` container via environment variables.
  1669  The `--name` flag will assign the name `console` to the newly created
  1670  container.
  1671  
  1672      $ sudo docker run --volumes-from 777f7dc92da7 --volumes-from ba8c0c54f0f2:ro -i -t ubuntu pwd
  1673  
  1674  The `--volumes-from` flag mounts all the defined volumes from the referenced
  1675  containers. Containers can be specified by repetitions of the `--volumes-from`
  1676  argument. The container ID may be optionally suffixed with `:ro` or `:rw` to
  1677  mount the volumes in read-only or read-write mode, respectively. By default,
  1678  the volumes are mounted in the same mode (read write or read only) as
  1679  the reference container.
  1680  
  1681  The `-a` flag tells `docker run` to bind to the container's `STDIN`, `STDOUT` or
  1682  `STDERR`. This makes it possible to manipulate the output and input as needed.
  1683  
  1684      $ echo "test" | sudo docker run -i -a stdin ubuntu cat -
  1685  
  1686  This pipes data into a container and prints the container's ID by attaching
  1687  only to the container's `STDIN`.
  1688  
  1689      $ sudo docker run -a stderr ubuntu echo test
  1690  
  1691  This isn't going to print anything unless there's an error because we've
  1692  only attached to the `STDERR` of the container. The container's logs
  1693  still store what's been written to `STDERR` and `STDOUT`.
  1694  
  1695      $ cat somefile | sudo docker run -i -a stdin mybuilder dobuild
  1696  
  1697  This is how piping a file into a container could be done for a build.
  1698  The container's ID will be printed after the build is done and the build
  1699  logs could be retrieved using `docker logs`. This is
  1700  useful if you need to pipe a file or something else into a container and
  1701  retrieve the container's ID once the container has finished running.
  1702  
  1703     $ sudo docker run --device=/dev/sdc:/dev/xvdc --device=/dev/sdd --device=/dev/zero:/dev/nulo -i -t ubuntu ls -l /dev/{xvdc,sdd,nulo}
  1704     brw-rw---- 1 root disk 8, 2 Feb  9 16:05 /dev/xvdc
  1705     brw-rw---- 1 root disk 8, 3 Feb  9 16:05 /dev/sdd
  1706     crw-rw-rw- 1 root root 1, 5 Feb  9 16:05 /dev/nulo
  1707  
  1708  It is often necessary to directly expose devices to a container. The `--device`
  1709  option enables that.  For example, a specific block storage device or loop
  1710  device or audio device can be added to an otherwise unprivileged container
  1711  (without the `--privileged` flag) and have the application directly access it.
  1712  
  1713  By default, the container will be able to `read`, `write` and `mknod` these devices.
  1714  This can be overridden using a third `:rwm` set of options to each `--device`
  1715  flag:
  1716  
  1717  
  1718  ```
  1719  	$ sudo docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk  /dev/xvdc
  1720  
  1721  	Command (m for help): q
  1722  	$ sudo docker run --device=/dev/sda:/dev/xvdc:r --rm -it ubuntu fdisk  /dev/xvdc
  1723  	You will not be able to write the partition table.
  1724  
  1725  	Command (m for help): q
  1726  
  1727  	$ sudo docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk  /dev/xvdc
  1728  
  1729  	Command (m for help): q
  1730  
  1731  	$ sudo docker run --device=/dev/sda:/dev/xvdc:m --rm -it ubuntu fdisk  /dev/xvdc
  1732  	fdisk: unable to open /dev/xvdc: Operation not permitted
  1733  ```
  1734  
  1735  **Note:**
  1736  > `--device` cannot be safely used with ephemeral devices. Block devices that
  1737  > may be removed should not be added to untrusted containers with `--device`.
  1738  
  1739  **A complete example:**
  1740  
  1741      $ sudo docker run -d --name static static-web-files sh
  1742      $ sudo docker run -d --expose=8098 --name riak riakserver
  1743      $ sudo docker run -d -m 100m -e DEVELOPMENT=1 -e BRANCH=example-code -v $(pwd):/app/bin:ro --name app appserver
  1744      $ sudo 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
  1745      $ sudo docker run -t -i --rm --volumes-from web -w /var/log/httpd busybox tail -f access.log
  1746  
  1747  This example shows five containers that might be set up to test a web
  1748  application change:
  1749  
  1750  1. Start a pre-prepared volume image `static-web-files` (in the background)
  1751     that has CSS, image and static HTML in it, (with a `VOLUME` instruction in
  1752     the Dockerfile to allow the web server to use those files);
  1753  2. Start a pre-prepared `riakserver` image, give the container name `riak` and
  1754     expose port `8098` to any containers that link to it;
  1755  3. Start the `appserver` image, restricting its memory usage to 100MB, setting
  1756     two environment variables `DEVELOPMENT` and `BRANCH` and bind-mounting the
  1757     current directory (`$(pwd)`) in the container in read-only mode as `/app/bin`;
  1758  4. Start the `webserver`, mapping port `443` in the container to port `1443` on
  1759     the Docker server, setting the DNS server to `10.0.0.1` and DNS search
  1760     domain to `dev.org`, creating a volume to put the log files into (so we can
  1761     access it from another container), then importing the files from the volume
  1762     exposed by the `static` container, and linking to all exposed ports from
  1763     `riak` and `app`. Lastly, we set the hostname to `web.sven.dev.org` so its
  1764     consistent with the pre-generated SSL certificate;
  1765  5. Finally, we create a container that runs `tail -f access.log` using the logs
  1766     volume from the `web` container, setting the workdir to `/var/log/httpd`. The
  1767     `--rm` option means that when the container exits, the container's layer is
  1768     removed.
  1769  
  1770  #### Restart Policies
  1771  
  1772  Using the `--restart` flag on Docker run you can specify a restart policy for
  1773  how a container should or should not be restarted on exit.
  1774  
  1775  An ever increasing delay (double the previous delay, starting at 100 milliseconds)
  1776  is added before each restart to prevent flooding the server. This means the daemaon
  1777  will wait for 100 mS, then 200 mS, 400, 800, 1600, and so on until either the
  1778  `on-failure` limit is hit, or when you `docker stop` or even `docker rm -f`
  1779  the container.
  1780  
  1781  When a restart policy is active on a container, it will be shown in `docker ps`
  1782  as either `Up` or `Restarting` in `docker ps`. It can also be useful to use
  1783  `docker events` to see the restart policy in effect.
  1784  
  1785  ** no ** - Do not restart the container when it exits.
  1786  
  1787  ** on-failure ** - Restart the container only if it exits with a non zero exit status.
  1788  
  1789  ** always ** - Always restart the container regardless of the exit status.
  1790  
  1791  You can also specify the maximum amount of times Docker will try to
  1792  restart the container when using the ** on-failure ** policy.  The
  1793  default is that Docker will try forever to restart the container.
  1794  
  1795      $ sudo docker run --restart=always redis
  1796  
  1797  This will run the `redis` container with a restart policy of ** always ** so that if
  1798  the container exits, Docker will restart it.
  1799  
  1800      $ sudo docker run --restart=on-failure:10 redis
  1801  
  1802  This will run the `redis` container with a restart policy of **
  1803  on-failure ** and a maximum restart count of 10.  If the `redis`
  1804  container exits with a non-zero exit status more than 10 times in a row
  1805  Docker will abort trying to restart the container.  Providing a maximum
  1806  restart limit is only valid for the ** on-failure ** policy.
  1807  
  1808  ### Adding entries to a container hosts file
  1809  
  1810  You can add other hosts into a container's `/etc/hosts` file by using one or more
  1811  `--add-host` flags. This example adds a static address for a host named `docker`:
  1812  
  1813  ```
  1814      $ docker run --add-host=docker:10.180.0.1 --rm -it debian
  1815      $$ ping docker
  1816      PING docker (10.180.0.1): 48 data bytes
  1817      56 bytes from 10.180.0.1: icmp_seq=0 ttl=254 time=7.600 ms
  1818      56 bytes from 10.180.0.1: icmp_seq=1 ttl=254 time=30.705 ms
  1819      ^C--- docker ping statistics ---
  1820      2 packets transmitted, 2 packets received, 0% packet loss
  1821      round-trip min/avg/max/stddev = 7.600/19.152/30.705/11.553 ms
  1822  ```
  1823  
  1824  > **Note:**
  1825  > Sometimes you need to connect to the Docker host, which means getting the IP
  1826  > address of the host. You can use the following shell commands to simplify this
  1827  > process:
  1828  >
  1829  >      $ alias hostip="ip route show 0.0.0.0/0 | grep -Eo 'via \S+' | awk '{ print \$2 }'"
  1830  >      $ docker run  --add-host=docker:$(hostip) --rm -it debian
  1831  
  1832  ## save
  1833  
  1834      Usage: docker save [OPTIONS] IMAGE [IMAGE...]
  1835  
  1836      Save an image(s) to a tar archive (streamed to STDOUT by default)
  1837  
  1838        -o, --output=""    Write to a file, instead of STDOUT
  1839  
  1840  Produces a tarred repository to the standard output stream.
  1841  Contains all parent layers, and all tags + versions, or specified `repo:tag`, for
  1842  each argument provided.
  1843  
  1844  It is used to create a backup that can then be used with `docker load`
  1845  
  1846      $ sudo docker save busybox > busybox.tar
  1847      $ ls -sh busybox.tar
  1848      2.7M busybox.tar
  1849      $ sudo docker save --output busybox.tar busybox
  1850      $ ls -sh busybox.tar
  1851      2.7M busybox.tar
  1852      $ sudo docker save -o fedora-all.tar fedora
  1853      $ sudo docker save -o fedora-latest.tar fedora:latest
  1854  
  1855  It is even useful to cherry-pick particular tags of an image repository
  1856  
  1857     $ sudo docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy
  1858  
  1859  ## search
  1860  
  1861  Search [Docker Hub](https://hub.docker.com) for images
  1862  
  1863      Usage: docker search [OPTIONS] TERM
  1864  
  1865      Search the Docker Hub for images
  1866  
  1867        --automated=false    Only show automated builds
  1868        --no-trunc=false     Don't truncate output
  1869        -s, --stars=0        Only displays with at least x stars
  1870  
  1871  See [*Find Public Images on Docker Hub*](
  1872  /userguide/dockerrepos/#searching-for-images) for
  1873  more details on finding shared images from the command line.
  1874  
  1875  ## start
  1876  
  1877      Usage: docker start [OPTIONS] CONTAINER [CONTAINER...]
  1878  
  1879      Restart a stopped container
  1880  
  1881        -a, --attach=false         Attach container's STDOUT and STDERR and forward all signals to the process
  1882        -i, --interactive=false    Attach container's STDIN
  1883  
  1884  When run on a container that has already been started,
  1885  takes no action and succeeds unconditionally.
  1886  
  1887  ## stop
  1888  
  1889      Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...]
  1890  
  1891      Stop a running container by sending SIGTERM and then SIGKILL after a grace period
  1892  
  1893        -t, --time=10      Number of seconds to wait for the container to stop before killing it. Default is 10 seconds.
  1894  
  1895  The main process inside the container will receive `SIGTERM`, and after a
  1896  grace period, `SIGKILL`.
  1897  
  1898  ## tag
  1899  
  1900      Usage: docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
  1901  
  1902      Tag an image into a repository
  1903  
  1904        -f, --force=false    Force
  1905  
  1906  You can group your images together using names and tags, and then upload
  1907  them to [*Share Images via Repositories*](
  1908  /userguide/dockerrepos/#contributing-to-docker-hub).
  1909  
  1910  ## top
  1911  
  1912      Usage: docker top CONTAINER [ps OPTIONS]
  1913  
  1914      Display the running processes of a container
  1915  
  1916  ## unpause
  1917  
  1918      Usage: docker unpause CONTAINER
  1919  
  1920      Unpause all processes within a container
  1921  
  1922  The `docker unpause` command uses the cgroups freezer to un-suspend all
  1923  processes in a container.
  1924  
  1925  See the
  1926  [cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroups/freezer-subsystem.txt)
  1927  for further details.
  1928  
  1929  ## version
  1930  
  1931      Usage: docker version
  1932  
  1933      Show the Docker version information.
  1934  
  1935  Show the Docker version, API version, Git commit, and Go version of
  1936  both Docker client and daemon.
  1937  
  1938  ## wait
  1939  
  1940      Usage: docker wait CONTAINER [CONTAINER...]
  1941  
  1942      Block until a container stops, then print its exit code.
  1943