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