github.com/tompao/docker@v1.9.1/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      $ docker
    18        Usage: docker [OPTIONS] COMMAND [arg...]
    19               docker daemon [ --help | ... ]
    20               docker [ --help | -v | --version ]
    21  
    22          -H, --host=[]: The socket(s) to talk to the Docker daemon in the format of tcp://host:port/path, unix:///path/to/socket, fd://* or fd://socketfd.
    23  
    24        A self-sufficient runtime for Linux containers.
    25  
    26        ...
    27  
    28  Depending on your Docker system configuration, you may be required to preface
    29  each `docker` command with `sudo`. To avoid having to use `sudo` with the
    30  `docker` command, your system administrator can create a Unix group called
    31  `docker` and add users to it.
    32  
    33  For more information about installing Docker or `sudo` configuration, refer to
    34  the [installation](../../installation) instructions for your operating system.
    35  
    36  ## Environment variables
    37  
    38  For easy reference, the following list of environment variables are supported
    39  by the `docker` command line:
    40  
    41  * `DOCKER_CONFIG` The location of your client configuration files.
    42  * `DOCKER_CERT_PATH` The location of your authentication keys.
    43  * `DOCKER_DRIVER` The graph driver to use.
    44  * `DOCKER_HOST` Daemon socket to connect to.
    45  * `DOCKER_NOWARN_KERNEL_VERSION` Prevent warnings that your Linux kernel is
    46    unsuitable for Docker.
    47  * `DOCKER_RAMDISK` If set this will disable 'pivot_root'.
    48  * `DOCKER_TLS_VERIFY` When set Docker uses TLS and verifies the remote.
    49  * `DOCKER_CONTENT_TRUST` When set Docker uses notary to sign and verify images.
    50    Equates to `--disable-content-trust=false` for build, create, pull, push, run.
    51  * `DOCKER_TMPDIR` Location for temporary Docker files.
    52  
    53  Because Docker is developed using 'Go', you can also use any environment
    54  variables used by the 'Go' runtime. In particular, you may find these useful:
    55  
    56  * `HTTP_PROXY`
    57  * `HTTPS_PROXY`
    58  * `NO_PROXY`
    59  
    60  These Go environment variables are case-insensitive. See the
    61  [Go specification](http://golang.org/pkg/net/http/) for details on these
    62  variables.
    63  
    64  ## Configuration files
    65  
    66  By default, the Docker command line stores its configuration files in a
    67  directory called `.docker` within your `HOME` directory. However, you can
    68  specify a different location via the `DOCKER_CONFIG` environment variable
    69  or the `--config` command line option. If both are specified, then the
    70  `--config` option overrides the `DOCKER_CONFIG` environment variable.
    71  For example:
    72  
    73      docker --config ~/testconfigs/ ps
    74  
    75  Instructs Docker to use the configuration files in your `~/testconfigs/`
    76  directory when running the `ps` command.
    77  
    78  Docker manages most of the files in the configuration directory
    79  and you should not modify them. However, you *can modify* the
    80  `config.json` file to control certain aspects of how the `docker`
    81  command behaves.
    82  
    83  Currently, you can modify the `docker` command behavior using environment
    84  variables or command-line options. You can also use options within
    85  `config.json` to modify some of the same behavior. When using these
    86  mechanisms, you must keep in mind the order of precedence among them. Command
    87  line options override environment variables and environment variables override
    88  properties you specify in a `config.json` file.
    89  
    90  The `config.json` file stores a JSON encoding of several properties:
    91  
    92  The property `HttpHeaders` specifies a set of headers to include in all messages
    93  sent from the Docker client to the daemon. Docker does not try to interpret or
    94  understand these header; it simply puts them into the messages. Docker does
    95  not allow these headers to change any headers it sets for itself.
    96  
    97  The property `psFormat` specifies the default format for `docker ps` output.
    98  When the `--format` flag is not provided with the `docker ps` command,
    99  Docker's client uses this property. If this property is not set, the client
   100  falls back to the default table format. For a list of supported formatting
   101  directives, see the [**Formatting** section in the `docker ps` documentation](ps.md)
   102  
   103  Following is a sample `config.json` file:
   104  
   105      {
   106        "HttpHeaders": {
   107          "MyHeader": "MyValue"
   108        },
   109        "psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Command}}\\t{{.Labels}}"
   110      }
   111  
   112  ## Help
   113  
   114  To list the help on any command just execute the command, followed by the
   115  `--help` option.
   116  
   117      $ docker run --help
   118  
   119      Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
   120  
   121      Run a command in a new container
   122  
   123        -a, --attach=[]            Attach to STDIN, STDOUT or STDERR
   124        --cpu-shares=0             CPU shares (relative weight)
   125      ...
   126  
   127  ## Option types
   128  
   129  Single character command line options can be combined, so rather than
   130  typing `docker run -i -t --name test busybox sh`,
   131  you can write `docker run -it --name test busybox sh`.
   132  
   133  ### Boolean
   134  
   135  Boolean options take the form `-d=false`. The value you see in the help text is
   136  the default value which is set if you do **not** specify that flag. If you
   137  specify a Boolean flag without a value, this will set the flag to `true`,
   138  irrespective of the default value.
   139  
   140  For example, running `docker run -d` will set the value to `true`, so your
   141  container **will** run in "detached" mode, in the background.
   142  
   143  Options which default to `true` (e.g., `docker build --rm=true`) can only be
   144  set to the non-default value by explicitly setting them to `false`:
   145  
   146      $ docker build --rm=false .
   147  
   148  ### Multi
   149  
   150  You can specify options like `-a=[]` multiple times in a single command line,
   151  for example in these commands:
   152  
   153      $ docker run -a stdin -a stdout -i -t ubuntu /bin/bash
   154      $ docker run -a stdin -a stdout -a stderr ubuntu /bin/ls
   155  
   156  Sometimes, multiple options can call for a more complex value string as for
   157  `-v`:
   158  
   159      $ docker run -v /host:/container example/mysql
   160  
   161  > **Note:**
   162  > Do not use the `-t` and `-a stderr` options together due to
   163  > limitations in the `pty` implementation. All `stderr` in `pty` mode
   164  > simply goes to `stdout`.
   165  
   166  ### Strings and Integers
   167  
   168  Options like `--name=""` expect a string, and they
   169  can only be specified once. Options like `-c=0`
   170  expect an integer, and they can only be specified once.