github.com/vieux/docker@v0.6.3-0.20161004191708-e097c2a938c7/docs/reference/commandline/cli.md (about)

     1  <!--[metadata]>
     2  +++
     3  title = "Use the Docker command line"
     4  description = "Docker's CLI command description and usage"
     5  keywords = ["Docker, Docker documentation, CLI,  command line"]
     6  [menu.main]
     7  parent = "smn_cli"
     8  weight = -2
     9  +++
    10  <![end-metadata]-->
    11  
    12  # Use the Docker command line
    13  
    14  To list available commands, either run `docker` with no parameters
    15  or execute `docker help`:
    16  
    17  ```bash
    18  $ docker
    19  Usage: docker [OPTIONS] COMMAND [arg...]
    20         docker [ --help | -v | --version ]
    21  
    22  A self-sufficient runtime for containers.
    23  
    24  Options:
    25  
    26    --config=~/.docker              Location of client config files
    27    -D, --debug                     Enable debug mode
    28    -H, --host=[]                   Daemon socket(s) to connect to
    29    --help                          Print usage
    30    -l, --log-level=info            Set the logging level
    31    --tls                           Use TLS; implied by --tlsverify
    32    --tlscacert=~/.docker/ca.pem    Trust certs signed only by this CA
    33    --tlscert=~/.docker/cert.pem    Path to TLS certificate file
    34    --tlskey=~/.docker/key.pem      Path to TLS key file
    35    --tlsverify                     Use TLS and verify the remote
    36    -v, --version                   Print version information and quit
    37  
    38  Commands:
    39      attach    Attach to a running container
    40      # […]
    41  ```
    42  
    43  Depending on your Docker system configuration, you may be required to preface
    44  each `docker` command with `sudo`. To avoid having to use `sudo` with the
    45  `docker` command, your system administrator can create a Unix group called
    46  `docker` and add users to it.
    47  
    48  For more information about installing Docker or `sudo` configuration, refer to
    49  the [installation](../../installation/index.md) instructions for your operating system.
    50  
    51  ## Environment variables
    52  
    53  For easy reference, the following list of environment variables are supported
    54  by the `docker` command line:
    55  
    56  * `DOCKER_API_VERSION` The API version to use (e.g. `1.19`)
    57  * `DOCKER_CONFIG` The location of your client configuration files.
    58  * `DOCKER_CERT_PATH` The location of your authentication keys.
    59  * `DOCKER_DRIVER` The graph driver to use.
    60  * `DOCKER_HOST` Daemon socket to connect to.
    61  * `DOCKER_NOWARN_KERNEL_VERSION` Prevent warnings that your Linux kernel is
    62    unsuitable for Docker.
    63  * `DOCKER_RAMDISK` If set this will disable 'pivot_root'.
    64  * `DOCKER_TLS_VERIFY` When set Docker uses TLS and verifies the remote.
    65  * `DOCKER_CONTENT_TRUST` When set Docker uses notary to sign and verify images.
    66    Equates to `--disable-content-trust=false` for build, create, pull, push, run.
    67  * `DOCKER_CONTENT_TRUST_SERVER` The URL of the Notary server to use. This defaults
    68    to the same URL as the registry.
    69  * `DOCKER_TMPDIR` Location for temporary Docker files.
    70  
    71  Because Docker is developed using 'Go', you can also use any environment
    72  variables used by the 'Go' runtime. In particular, you may find these useful:
    73  
    74  * `HTTP_PROXY`
    75  * `HTTPS_PROXY`
    76  * `NO_PROXY`
    77  
    78  These Go environment variables are case-insensitive. See the
    79  [Go specification](http://golang.org/pkg/net/http/) for details on these
    80  variables.
    81  
    82  ## Configuration files
    83  
    84  By default, the Docker command line stores its configuration files in a
    85  directory called `.docker` within your `$HOME` directory. However, you can
    86  specify a different location via the `DOCKER_CONFIG` environment variable
    87  or the `--config` command line option. If both are specified, then the
    88  `--config` option overrides the `DOCKER_CONFIG` environment variable.
    89  For example:
    90  
    91      docker --config ~/testconfigs/ ps
    92  
    93  Instructs Docker to use the configuration files in your `~/testconfigs/`
    94  directory when running the `ps` command.
    95  
    96  Docker manages most of the files in the configuration directory
    97  and you should not modify them. However, you *can modify* the
    98  `config.json` file to control certain aspects of how the `docker`
    99  command behaves.
   100  
   101  Currently, you can modify the `docker` command behavior using environment
   102  variables or command-line options. You can also use options within
   103  `config.json` to modify some of the same behavior. When using these
   104  mechanisms, you must keep in mind the order of precedence among them. Command
   105  line options override environment variables and environment variables override
   106  properties you specify in a `config.json` file.
   107  
   108  The `config.json` file stores a JSON encoding of several properties:
   109  
   110  The property `HttpHeaders` specifies a set of headers to include in all messages
   111  sent from the Docker client to the daemon. Docker does not try to interpret or
   112  understand these header; it simply puts them into the messages. Docker does
   113  not allow these headers to change any headers it sets for itself.
   114  
   115  The property `psFormat` specifies the default format for `docker ps` output.
   116  When the `--format` flag is not provided with the `docker ps` command,
   117  Docker's client uses this property. If this property is not set, the client
   118  falls back to the default table format. For a list of supported formatting
   119  directives, see the
   120  [**Formatting** section in the `docker ps` documentation](ps.md)
   121  
   122  Once attached to a container, users detach from it and leave it running using
   123  the using `CTRL-p CTRL-q` key sequence. This detach key sequence is customizable
   124  using the `detachKeys` property. Specify a `<sequence>` value for the
   125  property. The format of the `<sequence>` is a comma-separated list of either 
   126  a letter [a-Z], or the `ctrl-` combined with any of the following:
   127  
   128  * `a-z` (a single lowercase alpha character )
   129  * `@` (at sign)
   130  * `[` (left bracket)
   131  * `\\` (two backward slashes)
   132  *  `_` (underscore)
   133  * `^` (caret)
   134  
   135  Your customization applies to all containers started in with your Docker client.
   136  Users can override your custom or the default key sequence on a per-container
   137  basis. To do this, the user specifies the `--detach-keys` flag with the `docker
   138  attach`, `docker exec`, `docker run` or `docker start` command.
   139  
   140  The property `imagesFormat` specifies the default format for `docker images` output.
   141  When the `--format` flag is not provided with the `docker images` command,
   142  Docker's client uses this property. If this property is not set, the client
   143  falls back to the default table format. For a list of supported formatting
   144  directives, see the [**Formatting** section in the `docker images` documentation](images.md)
   145  
   146  The property `serviceInspectFormat` specifies the default format for `docker
   147  service inspect` output. When the `--format` flag is not provided with the
   148  `docker service inspect` command, Docker's client uses this property. If this
   149  property is not set, the client falls back to the default json format. For a
   150  list of supported formatting directives, see the
   151  [**Formatting** section in the `docker service inspect` documentation](service_inspect.md)
   152  
   153  Following is a sample `config.json` file:
   154  
   155      {
   156        "HttpHeaders": {
   157          "MyHeader": "MyValue"
   158        },
   159        "psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Command}}\\t{{.Labels}}",
   160        "imagesFormat": "table {{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}",
   161        "serviceInspectFormat": "pretty",
   162        "detachKeys": "ctrl-e,e"
   163      }
   164  
   165  ### Notary
   166  
   167  If using your own notary server and a self-signed certificate or an internal
   168  Certificate Authority, you need to place the certificate at
   169  `tls/<registry_url>/ca.crt` in your docker config directory.
   170  
   171  Alternatively you can trust the certificate globally by adding it to your system's
   172  list of root Certificate Authorities.
   173  
   174  ## Help
   175  
   176  To list the help on any command just execute the command, followed by the
   177  `--help` option.
   178  
   179      $ docker run --help
   180  
   181      Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
   182  
   183      Run a command in a new container
   184  
   185      Options:
   186            --add-host value             Add a custom host-to-IP mapping (host:ip) (default [])
   187        -a, --attach value               Attach to STDIN, STDOUT or STDERR (default [])
   188      ...
   189  
   190  ## Option types
   191  
   192  Single character command line options can be combined, so rather than
   193  typing `docker run -i -t --name test busybox sh`,
   194  you can write `docker run -it --name test busybox sh`.
   195  
   196  ### Boolean
   197  
   198  Boolean options take the form `-d=false`. The value you see in the help text is
   199  the default value which is set if you do **not** specify that flag. If you
   200  specify a Boolean flag without a value, this will set the flag to `true`,
   201  irrespective of the default value.
   202  
   203  For example, running `docker run -d` will set the value to `true`, so your
   204  container **will** run in "detached" mode, in the background.
   205  
   206  Options which default to `true` (e.g., `docker build --rm=true`) can only be
   207  set to the non-default value by explicitly setting them to `false`:
   208  
   209      $ docker build --rm=false .
   210  
   211  ### Multi
   212  
   213  You can specify options like `-a=[]` multiple times in a single command line,
   214  for example in these commands:
   215  
   216      $ docker run -a stdin -a stdout -i -t ubuntu /bin/bash
   217      $ docker run -a stdin -a stdout -a stderr ubuntu /bin/ls
   218  
   219  Sometimes, multiple options can call for a more complex value string as for
   220  `-v`:
   221  
   222      $ docker run -v /host:/container example/mysql
   223  
   224  > **Note:**
   225  > Do not use the `-t` and `-a stderr` options together due to
   226  > limitations in the `pty` implementation. All `stderr` in `pty` mode
   227  > simply goes to `stdout`.
   228  
   229  ### Strings and Integers
   230  
   231  Options like `--name=""` expect a string, and they
   232  can only be specified once. Options like `-c=0`
   233  expect an integer, and they can only be specified once.