Get Started
About Docker Apply custom metadata Docker Deprecated Features Understand the architecture
Image management Using certificates for repository client verification Run a local registry mirror
Docker run reference Dockerfile reference Remote API client libraries accounts API Docker Trusted Registry

Using the command line

To list available commands, either run docker with no parameters or execute docker help:

$ docker
  Usage: docker [OPTIONS] COMMAND [arg...]
         docker daemon [ --help | ... ]
         docker [ -h | --help | -v | --version ]

    -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.

  A self-sufficient runtime for Linux containers.


Depending on your Docker system configuration, you may be required to preface each docker command with sudo. To avoid having to use sudo with the docker command, your system administrator can create a Unix group called docker and add users to it.

For more information about installing Docker or sudo configuration, refer to the installation instructions for your operating system.

Environment variables

For easy reference, the following list of environment variables are supported by the docker command line:

  • DOCKER_CONFIG The location of your client configuration files.
  • DOCKER_CERT_PATH The location of your authentication keys.
  • DOCKER_DRIVER The graph driver to use.
  • DOCKER_HOST Daemon socket to connect to.
  • DOCKER_NOWARN_KERNEL_VERSION Prevent warnings that your Linux kernel is unsuitable for Docker.
  • DOCKER_RAMDISK If set this will disable ‘pivot_root’.
  • DOCKER_TLS_VERIFY When set Docker uses TLS and verifies the remote.
  • DOCKER_CONTENT_TRUST When set Docker uses notary to sign and verify images. Equates to --disable-content-trust=false for build, create, pull, push, run.
  • DOCKER_TMPDIR Location for temporary Docker files.

Because Docker is developed using ‘Go’, you can also use any environment variables used by the ‘Go’ runtime. In particular, you may find these useful:


These Go environment variables are case-insensitive. See the Go specification for details on these variables.

Configuration files

By default, the Docker command line stores its configuration files in a directory called .docker within your HOME directory. However, you can specify a different location via the DOCKER_CONFIG environment variable or the --config command line option. If both are specified, then the --config option overrides the DOCKER_CONFIG environment variable. For example:

docker --config ~/testconfigs/ ps

Instructs Docker to use the configuration files in your ~/testconfigs/ directory when running the ps command.

Docker manages most of the files in the configuration directory and you should not modify them. However, you can modify the config.json file to control certain aspects of how the docker command behaves.

Currently, you can modify the docker command behavior using environment variables or command-line options. You can also use options within config.json to modify some of the same behavior. When using these mechanisms, you must keep in mind the order of precedence among them. Command line options override environment variables and environment variables override properties you specify in a config.json file.

The config.json file stores a JSON encoding of several properties:

The property HttpHeaders specifies a set of headers to include in all messages sent from the Docker client to the daemon. Docker does not try to interpret or understand these header; it simply puts them into the messages. Docker does not allow these headers to change any headers it sets for itself.

The property psFormat specifies the default format for docker ps output. When the --format flag is not provided with the docker ps command, Docker’s client uses this property. If this property is not set, the client falls back to the default table format. For a list of supported formatting directives, see the Formatting section in the docker ps documentation

Following is a sample config.json file:

  "HttpHeaders: {
    "MyHeader": "MyValue"
  "psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Command}}\\t{{.Labels}}"


To list the help on any command just execute the command, followed by the --help option.

$ docker run --help

Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]

Run a command in a new container

  -a, --attach=[]            Attach to STDIN, STDOUT or STDERR
  -c, --cpu-shares=0         CPU shares (relative weight)

Option types

Single character command line options can be combined, so rather than typing docker run -i -t --name test busybox sh, you can write docker run -it --name test busybox sh.


Boolean options take the form -d=false. The value you see in the help text is the default value which is set if you do not specify that flag. If you specify a Boolean flag without a value, this will set the flag to true, irrespective of the default value.

For example, running docker run -d will set the value to true, so your container will run in “detached” mode, in the background.

Options which default to true (e.g., docker build --rm=true) can only be set to the non-default value by explicitly setting them to false:

$ docker build --rm=false .


You can specify options like -a=[] multiple times in a single command line, for example in these commands:

$ docker run -a stdin -a stdout -i -t ubuntu /bin/bash
$ docker run -a stdin -a stdout -a stderr ubuntu /bin/ls

Sometimes, multiple options can call for a more complex value string as for -v:

$ docker run -v /host:/container example/mysql

Note: Do not use the -t and -a stderr options together due to limitations in the pty implementation. All stderr in pty mode simply goes to stdout.

Strings and Integers

Options like --name="" expect a string, and they can only be specified once. Options like -c=0 expect an integer, and they can only be specified once.

Aug 27, 2015 at 11:46pm (PST) { "docker/compose": { "ref": "docs", "repos": [ "" ], "sha": "f9bcc88c93a147d7f3b015d901afa91ebcc256e7" }, "docker/docker": { "ref": "docs", "repos": [ "" ], "sha": "942363d3ca119c19d82525b4b9e0c65dc35b9359" }, "docker/docker-hub": { "ref": "master", "repos": [ "" ], "sha": "4816b34e1d1935e22dac91a2a81d521a33b4de3d" }, "docker/docker-trusted-registry": { "ref": "docs", "repos": [ "" ], "sha": "e6b9a5522a543356f0c8b718e0d4f3427048ab0f" }, "docker/docs-base": { "ref": "master", "repos": [ "" ], "sha": "17fc4389cb6298c89a3fd538d5843c40e85a7aba" }, "docker/machine": { "ref": "docs", "repos": [ "" ], "sha": "7b9c2c695e449262b77b2253910a033a05b209d2" }, "docker/opensource": { "ref": "master", "repos": [ "" ], "sha": "aa9aab78892ca979683dbaa54dafa3c7d8a02304" }, "docker/registry": { "ref": "release/2.1", "repos": [ "" ], "sha": "9ca7921603852314b18a6ecc19f91806935f34bd" }, "docker/swarm": { "ref": "docs", "repos": [ "" ], "sha": "a4cd6eff19f6c622b860581df45c5745f4ab916a" }, "docker/tutorials": { "ref": "docs", "repos": [ "" ], "sha": "907aa04ef0e55229c1346643ee3ed59f23c7da6a" }, "": { "ref": "refs/heads/dtr-1.3-release", "repos": [ "", "" ], "sha": "c6e54a2c5c3455189fc3b7916e2bf437c3be1884" }, "kitematic/kitematic": { "ref": "docs", "repos": [ "" ], "sha": "7baf7707caf9a797f276e668df8e8e8a203746ee" } }