github.com/chenchun/docker@v1.3.2-0.20150629222414-20467faf132b/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 -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. 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_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_TMPDIR` Location for temporary Docker files. 49 50 Because Docker is developed using 'Go', you can also use any environment 51 variables used by the 'Go' runtime. In particular, you may find these useful: 52 53 * `HTTP_PROXY` 54 * `HTTPS_PROXY` 55 * `NO_PROXY` 56 57 These Go environment variables are case-insensitive. See the 58 [Go specification](http://golang.org/pkg/net/http/) for details on these 59 variables. 60 61 ## Configuration files 62 63 The Docker command line stores its configuration files in a directory called 64 `.docker` within your `HOME` directory. Docker manages most of the files in 65 `.docker` and you should not modify them. However, you *can modify* the 66 `.docker/config.json` file to control certain aspects of how the `docker` 67 command behaves. 68 69 Currently, you can modify the `docker` command behavior using environment 70 variables or command-line options. You can also use options within 71 `config.json` to modify some of the same behavior. When using these 72 mechanisms, you must keep in mind the order of precedence among them. Command 73 line options override environment variables and environment variables override 74 properties you specify in a `config.json` file. 75 76 The `config.json` file stores a JSON encoding of a single `HttpHeaders` 77 property. The property specifies a set of headers to include in all messages 78 sent from the Docker client to the daemon. Docker does not try to interpret or 79 understand these header; it simply puts them into the messages. Docker does 80 not allow these headers to change any headers it sets for itself. 81 82 Following is a sample `config.json` file: 83 84 { 85 "HttpHeaders: { 86 "MyHeader": "MyValue" 87 } 88 } 89 90 ## Help 91 92 To list the help on any command just execute the command, followed by the 93 `--help` option. 94 95 $ docker run --help 96 97 Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] 98 99 Run a command in a new container 100 101 -a, --attach=[] Attach to STDIN, STDOUT or STDERR 102 -c, --cpu-shares=0 CPU shares (relative weight) 103 ... 104 105 ## Option types 106 107 Single character command line options can be combined, so rather than 108 typing `docker run -i -t --name test busybox sh`, 109 you can write `docker run -it --name test busybox sh`. 110 111 ### Boolean 112 113 Boolean options take the form `-d=false`. The value you see in the help text is 114 the default value which is set if you do **not** specify that flag. If you 115 specify a Boolean flag without a value, this will set the flag to `true`, 116 irrespective of the default value. 117 118 For example, running `docker run -d` will set the value to `true`, so your 119 container **will** run in "detached" mode, in the background. 120 121 Options which default to `true` (e.g., `docker build --rm=true`) can only be 122 set to the non-default value by explicitly setting them to `false`: 123 124 $ docker build --rm=false . 125 126 ### Multi 127 128 You can specify options like `-a=[]` multiple times in a single command line, 129 for example in these commands: 130 131 $ docker run -a stdin -a stdout -i -t ubuntu /bin/bash 132 $ docker run -a stdin -a stdout -a stderr ubuntu /bin/ls 133 134 Sometimes, multiple options can call for a more complex value string as for 135 `-v`: 136 137 $ docker run -v /host:/container example/mysql 138 139 > **Note:** 140 > Do not use the `-t` and `-a stderr` options together due to 141 > limitations in the `pty` implementation. All `stderr` in `pty` mode 142 > simply goes to `stdout`. 143 144 ### Strings and Integers 145 146 Options like `--name=""` expect a string, and they 147 can only be specified once. Options like `-c=0` 148 expect an integer, and they can only be specified once.