github.com/slene/docker@v1.8.0-rc1/docs/reference/commandline/cli.md (about)

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