github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/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 -h, --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 Following is a sample `config.json` file: 147 148 { 149 "HttpHeaders": { 150 "MyHeader": "MyValue" 151 }, 152 "psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Command}}\\t{{.Labels}}", 153 "imagesFormat": "table {{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}", 154 "detachKeys": "ctrl-e,e" 155 } 156 157 ### Notary 158 159 If using your own notary server and a self-signed certificate or an internal 160 Certificate Authority, you need to place the certificate at 161 `tls/<registry_url>/ca.crt` in your docker config directory. 162 163 Alternatively you can trust the certificate globally by adding it to your system's 164 list of root Certificate Authorities. 165 166 ## Help 167 168 To list the help on any command just execute the command, followed by the 169 `--help` option. 170 171 $ docker run --help 172 173 Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] 174 175 Run a command in a new container 176 177 -a, --attach=[] Attach to STDIN, STDOUT or STDERR 178 --cpu-shares=0 CPU shares (relative weight) 179 ... 180 181 ## Option types 182 183 Single character command line options can be combined, so rather than 184 typing `docker run -i -t --name test busybox sh`, 185 you can write `docker run -it --name test busybox sh`. 186 187 ### Boolean 188 189 Boolean options take the form `-d=false`. The value you see in the help text is 190 the default value which is set if you do **not** specify that flag. If you 191 specify a Boolean flag without a value, this will set the flag to `true`, 192 irrespective of the default value. 193 194 For example, running `docker run -d` will set the value to `true`, so your 195 container **will** run in "detached" mode, in the background. 196 197 Options which default to `true` (e.g., `docker build --rm=true`) can only be 198 set to the non-default value by explicitly setting them to `false`: 199 200 $ docker build --rm=false . 201 202 ### Multi 203 204 You can specify options like `-a=[]` multiple times in a single command line, 205 for example in these commands: 206 207 $ docker run -a stdin -a stdout -i -t ubuntu /bin/bash 208 $ docker run -a stdin -a stdout -a stderr ubuntu /bin/ls 209 210 Sometimes, multiple options can call for a more complex value string as for 211 `-v`: 212 213 $ docker run -v /host:/container example/mysql 214 215 > **Note:** 216 > Do not use the `-t` and `-a stderr` options together due to 217 > limitations in the `pty` implementation. All `stderr` in `pty` mode 218 > simply goes to `stdout`. 219 220 ### Strings and Integers 221 222 Options like `--name=""` expect a string, and they 223 can only be specified once. Options like `-c=0` 224 expect an integer, and they can only be specified once.