2016-10-14 18:30:36 -04:00
---
title: "Use the Docker command line"
description: "Docker's CLI command description and usage"
2021-04-30 08:59:05 -04:00
keywords: "Docker, Docker documentation, CLI, command line, config.json, CLI configuration file"
2023-11-06 12:25:49 -05:00
aliases:
2021-08-23 11:35:25 -04:00
- /reference/commandline/cli/
2019-12-06 04:46:54 -05:00
- /engine/reference/commandline/engine/
- /engine/reference/commandline/engine_activate/
- /engine/reference/commandline/engine_check/
- /engine/reference/commandline/engine_update/
2016-10-14 18:30:36 -04:00
---
2014-04-15 20:53:12 -04:00
2017-10-04 13:03:55 -04:00
<!-- This file is maintained within the docker/cli GitHub
2017-07-28 13:28:23 -04:00
repository at https://github.com/docker/cli/. Make all
2016-10-19 13:25:45 -04:00
pull requests against that repo. If you see this file in
another repository, consider it read-only there, as it will
periodically be overwritten by the definitive file. Pull
requests which include edits to this file in other repositories
will be rejected.
-->
2017-02-07 18:42:48 -05:00
# docker
2014-04-15 20:53:12 -04:00
2014-04-23 16:48:28 -04:00
To list available commands, either run `docker` with no parameters
or execute `docker help` :
2014-04-15 20:53:12 -04:00
2023-01-06 13:04:05 -05:00
<!-- - MARKER_GEN_START -->
The base command for the Docker CLI.
### Subcommands
2024-01-19 08:06:29 -05:00
| Name | Description |
| :-------------------------------- | :---------------------------------------------------------------------------- |
| [`attach` ](container_attach.md ) | Attach local standard input, output, and error streams to a running container |
| [`build` ](image_build.md ) | Build an image from a Dockerfile |
| [`builder` ](builder.md ) | Manage builds |
| [`checkpoint` ](checkpoint.md ) | Manage checkpoints |
| [`commit` ](container_commit.md ) | Create a new image from a container's changes |
| [`config` ](config.md ) | Manage Swarm configs |
| [`container` ](container.md ) | Manage containers |
| [`context` ](context.md ) | Manage contexts |
| [`cp` ](container_cp.md ) | Copy files/folders between a container and the local filesystem |
| [`create` ](container_create.md ) | Create a new container |
| [`diff` ](container_diff.md ) | Inspect changes to files or directories on a container's filesystem |
| [`events` ](system_events.md ) | Get real time events from the server |
| [`exec` ](container_exec.md ) | Execute a command in a running container |
| [`export` ](container_export.md ) | Export a container's filesystem as a tar archive |
| [`history` ](image_history.md ) | Show the history of an image |
| [`image` ](image.md ) | Manage images |
| [`images` ](image_ls.md ) | List images |
| [`import` ](image_import.md ) | Import the contents from a tarball to create a filesystem image |
| [`info` ](system_info.md ) | Display system-wide information |
| [`inspect` ](inspect.md ) | Return low-level information on Docker objects |
| [`kill` ](container_kill.md ) | Kill one or more running containers |
| [`load` ](image_load.md ) | Load an image from a tar archive or STDIN |
| [`login` ](login.md ) | Log in to a registry |
| [`logout` ](logout.md ) | Log out from a registry |
| [`logs` ](container_logs.md ) | Fetch the logs of a container |
| [`manifest` ](manifest.md ) | Manage Docker image manifests and manifest lists |
| [`network` ](network.md ) | Manage networks |
| [`node` ](node.md ) | Manage Swarm nodes |
| [`pause` ](container_pause.md ) | Pause all processes within one or more containers |
| [`plugin` ](plugin.md ) | Manage plugins |
| [`port` ](container_port.md ) | List port mappings or a specific mapping for the container |
| [`ps` ](container_ls.md ) | List containers |
| [`pull` ](image_pull.md ) | Download an image from a registry |
| [`push` ](image_push.md ) | Upload an image to a registry |
| [`rename` ](container_rename.md ) | Rename a container |
| [`restart` ](container_restart.md ) | Restart one or more containers |
| [`rm` ](container_rm.md ) | Remove one or more containers |
| [`rmi` ](image_rm.md ) | Remove one or more images |
| [`run` ](container_run.md ) | Create and run a new container from an image |
| [`save` ](image_save.md ) | Save one or more images to a tar archive (streamed to STDOUT by default) |
| [`search` ](search.md ) | Search Docker Hub for images |
| [`secret` ](secret.md ) | Manage Swarm secrets |
| [`service` ](service.md ) | Manage Swarm services |
| [`stack` ](stack.md ) | Manage Swarm stacks |
| [`start` ](container_start.md ) | Start one or more stopped containers |
| [`stats` ](container_stats.md ) | Display a live stream of container(s) resource usage statistics |
| [`stop` ](container_stop.md ) | Stop one or more running containers |
| [`swarm` ](swarm.md ) | Manage Swarm |
| [`system` ](system.md ) | Manage Docker |
| [`tag` ](image_tag.md ) | Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE |
| [`top` ](container_top.md ) | Display the running processes of a container |
| [`trust` ](trust.md ) | Manage trust on Docker images |
| [`unpause` ](container_unpause.md ) | Unpause all processes within one or more containers |
| [`update` ](container_update.md ) | Update configuration of one or more containers |
| [`version` ](version.md ) | Show the Docker version information |
| [`volume` ](volume.md ) | Manage volumes |
| [`wait` ](container_wait.md ) | Block until one or more containers stop, then print their exit codes |
2023-01-06 13:04:05 -05:00
### Options
2023-05-05 10:47:16 -04:00
| Name | Type | Default | Description |
|:---------------------------------|:---------|:-------------------------|:--------------------------------------------------------------------------------------------------------------------------------------|
| `--config` | `string` | `/root/.docker` | Location of client config files |
| `-c` , `--context` | `string` | | Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with `docker context use` ) |
| `-D` , `--debug` | | | Enable debug mode |
| [`-H` ](#host ), [`--host` ](#host ) | `list` | | Daemon socket to connect to |
| `-l` , `--log-level` | `string` | `info` | Set the logging level (`debug`, `info` , `warn` , `error` , `fatal` ) |
| `--tls` | | | Use TLS; implied by --tlsverify |
| `--tlscacert` | `string` | `/root/.docker/ca.pem` | Trust certs signed only by this CA |
| `--tlscert` | `string` | `/root/.docker/cert.pem` | Path to TLS certificate file |
| `--tlskey` | `string` | `/root/.docker/key.pem` | Path to TLS key file |
| `--tlsverify` | | | Use TLS and verify the remote |
2023-01-06 13:04:05 -05:00
<!-- - MARKER_GEN_END -->
2015-05-27 13:38:29 -04:00
2017-02-07 18:42:48 -05:00
## Description
2015-05-27 13:38:29 -04:00
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
2015-03-26 14:12:37 -04:00
`docker` and add users to it.
For more information about installing Docker or `sudo` configuration, refer to
Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
1 Letterman Drive
Suite D4700
San Francisco, CA, 94129
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
Developer's Certificate of Origin 1.1
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the open source license
indicated in the file; or
(b) The contribution is based upon previous work that, to the best
of my knowledge, is covered under an appropriate open source
license and I have the right under that license to submit that
work with modifications, whether created in whole or in part
by me, under the same open source license (unless I am
permitted to submit under a different license), as indicated
in the file; or
(c) The contribution was provided directly to me by some other
person who certified (a), (b) or (c) and I have not modified
it.
(d) I understand and agree that this project and the contribution
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
Signed-off-by: nkwangleiGIT <nkwanglei@126.com>
2018-05-16 08:16:08 -04:00
the [installation ](https://docs.docker.com/install/ ) instructions for your operating system.
2014-04-15 20:53:12 -04:00
2019-10-07 18:29:19 -04:00
## Environment variables
2015-03-24 13:08:37 -04:00
2021-04-30 08:59:05 -04:00
The following list of environment variables are supported by the `docker` command
line:
2023-04-12 12:15:13 -04:00
| Variable | Description |
2024-01-19 08:06:29 -05:00
| :---------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2023-04-12 12:15:13 -04:00
| `DOCKER_API_VERSION` | Override the negotiated API version to use for debugging (e.g. `1.19` ) |
| `DOCKER_CERT_PATH` | Location of your authentication keys. This variable is used both by the `docker` CLI and the [`dockerd` daemon ](dockerd.md ) |
| `DOCKER_CONFIG` | The location of your client configuration files. |
| `DOCKER_CONTENT_TRUST_SERVER` | The URL of the Notary server to use. Defaults to the same URL as the registry. |
| `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_CONTEXT` | Name of the `docker context` to use (overrides `DOCKER_HOST` env var and default context set with `docker context use` ) |
| `DOCKER_DEFAULT_PLATFORM` | Default platform for commands that take the `--platform` flag. |
| `DOCKER_HIDE_LEGACY_COMMANDS` | When set, Docker hides "legacy" top-level commands (such as `docker rm` , and `docker pull` ) in `docker help` output, and only `Management commands` per object-type (e.g., `docker container` ) are printed. This may become the default in a future release. |
| `DOCKER_HOST` | Daemon socket to connect to. |
2023-07-19 09:03:40 -04:00
| `DOCKER_TLS` | Enable TLS for connections made by the `docker` CLI (equivalent of the `--tls` command-line option). Set to a non-empty value to enable TLS. Note that TLS is enabled automatically if any of the other TLS options are set. |
2023-04-12 12:15:13 -04:00
| `DOCKER_TLS_VERIFY` | When set Docker uses TLS and verifies the remote. This variable is used both by the `docker` CLI and the [`dockerd` daemon ](dockerd.md ) |
2024-01-19 08:06:29 -05:00
| `BUILDKIT_PROGRESS` | Set type of progress output (`auto`, `plain` , `tty` ) when [building ](image_build.md ) with [BuildKit backend ](https://docs.docker.com/build/buildkit/ ). Use plain to show container output (default `auto` ). |
2018-01-12 12:30:31 -05:00
2016-11-24 15:07:06 -05:00
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:
2015-03-24 13:08:37 -04:00
2023-04-12 12:19:20 -04:00
| Variable | Description |
|:--------------|:-------------------------------------------------------------------------------|
| `HTTP_PROXY` | Proxy URL for HTTP requests unless overridden by NoProxy. |
| `HTTPS_PROXY` | Proxy URL for HTTPS requests unless overridden by NoProxy. |
| `NO_PROXY` | Comma-separated values specifying hosts that should be excluded from proxying. |
See the [Go specification ](https://pkg.go.dev/golang.org/x/net/http/httpproxy#Config )
for details on these variables.
2015-03-24 13:08:37 -04:00
2021-04-30 08:59:05 -04:00
## Configuration files
2015-04-01 18:39:37 -04:00
2015-04-28 11:00:18 -04:00
By default, the Docker command line stores its configuration files in a
2019-09-03 19:23:27 -04:00
directory called `.docker` within your `$HOME` directory.
2015-04-28 11:00:18 -04:00
Docker manages most of the files in the configuration directory
2023-12-13 09:16:56 -05:00
and you shouldn't modify them. However, you can modify the
2015-04-28 11:00:18 -04:00
`config.json` file to control certain aspects of how the `docker`
2015-04-01 18:39:37 -04:00
command behaves.
2019-09-03 19:23:27 -04:00
You can modify the `docker` command behavior using environment
2015-05-27 13:38:29 -04:00
variables or command-line options. You can also use options within
2019-09-03 19:23:27 -04:00
`config.json` to modify some of the same behavior. If an environment variable
and the `--config` flag are set, the flag takes precedent over the environment
variable. Command line options override environment variables and environment
variables override properties you specify in a `config.json` file.
2019-10-07 18:29:19 -04:00
### Change the `.docker` directory
2019-09-03 19:23:27 -04:00
To specify a different directory, use the `DOCKER_CONFIG`
environment variable or the `--config` command line option. If both are
specified, then the `--config` option overrides the `DOCKER_CONFIG` environment
2019-10-07 18:29:19 -04:00
variable. The example below overrides the `docker ps` command using a
2019-09-03 19:23:27 -04:00
`config.json` file located in the `~/testconfigs/` directory.
2021-04-30 08:59:05 -04:00
```console
2019-09-03 19:23:27 -04:00
$ docker --config ~/testconfigs/ ps
```
This flag only applies to whatever command is being ran. For persistent
configuration, you can set the `DOCKER_CONFIG` environment variable in your
shell (e.g. `~/.profile` or `~/.bashrc` ). The example below sets the new
directory to be `HOME/newdir/.docker` .
2021-04-30 08:59:05 -04:00
```console
$ echo export DOCKER_CONFIG=$HOME/newdir/.docker > ~/.profile
2019-09-03 19:23:27 -04:00
```
2021-04-30 08:59:05 -04:00
## Docker CLI configuration file (`config.json`) properties
< a name = "configjson-properties" > <!-- included for deep - links to old section --> < / a >
2015-04-01 18:39:37 -04:00
2021-04-30 08:59:05 -04:00
Use the Docker CLI configuration to customize settings for the `docker` CLI. The
configuration file uses JSON formatting, and properties:
By default, configuration file is stored in `~/.docker/config.json` . Refer to the
[change the `.docker` directory ](#change-the-docker-directory ) section to use a
different location.
> **Warning**
2023-12-13 09:16:56 -05:00
>
2021-04-30 08:59:05 -04:00
> The configuration file and other files inside the `~/.docker` configuration
> directory may contain sensitive information, such as authentication information
> for proxies or, depending on your credential store, credentials for your image
> registries. Review your configuration file's content before sharing with others,
> and prevent committing the file to version control.
### Customize the default output format for commands
2023-12-13 09:16:56 -05:00
These fields lets you customize the default output format for some commands
2021-04-30 08:59:05 -04:00
if no `--format` flag is provided.
2023-12-13 09:16:56 -05:00
| Property | Description |
| :--------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `configFormat` | Custom default format for `docker config ls` output. See [`docker config ls` ](config_ls.md#format ) for a list of supported formatting directives. |
2024-01-19 08:06:29 -05:00
| `imagesFormat` | Custom default format for `docker images` / `docker image ls` output. See [`docker images` ](image_ls.md#format ) for a list of supported formatting directives. |
2024-01-03 10:09:42 -05:00
| `networksFormat` | Custom default format for `docker network ls` output. See [`docker network ls` ](network_ls.md#format ) for a list of supported formatting directives. |
2023-12-13 09:16:56 -05:00
| `nodesFormat` | Custom default format for `docker node ls` output. See [`docker node ls` ](node_ls.md#format ) for a list of supported formatting directives. |
| `pluginsFormat` | Custom default format for `docker plugin ls` output. See [`docker plugin ls` ](plugin_ls.md#format ) for a list of supported formatting directives. |
2024-01-19 08:06:29 -05:00
| `psFormat` | Custom default format for `docker ps` / `docker container ps` output. See [`docker ps` ](container_ls.md#format ) for a list of supported formatting directives. |
2023-12-13 09:16:56 -05:00
| `secretFormat` | Custom default format for `docker secret ls` output. See [`docker secret ls` ](secret_ls.md#format ) for a list of supported formatting directives. |
| `serviceInspectFormat` | Custom default format for `docker service inspect` output. See [`docker service inspect` ](service_inspect.md#format ) for a list of supported formatting directives. |
| `servicesFormat` | Custom default format for `docker service ls` output. See [`docker service ls` ](service_ls.md#format ) for a list of supported formatting directives. |
2024-01-19 08:06:29 -05:00
| `statsFormat` | Custom default format for `docker stats` output. See [`docker stats` ](container_stats.md#format ) for a list of supported formatting directives. |
2024-01-03 10:09:42 -05:00
| `tasksFormat` | Custom default format for `docker stack ps` output. See [`docker stack ps` ](stack_ps.md#format ) for a list of supported formatting directives. |
| `volumesFormat` | Custom default format for `docker volume ls` output. See [`docker volume ls` ](volume_ls.md#format ) for a list of supported formatting directives. |
2021-04-30 08:59:05 -04:00
### Custom HTTP headers
2015-07-17 00:03:16 -04:00
The property `HttpHeaders` specifies a set of headers to include in all messages
2023-12-13 09:16:56 -05:00
sent from the Docker client to the daemon. Docker doesn't try to interpret or
2021-04-30 08:59:05 -04:00
understand these headers; it simply puts them into the messages. Docker does
2015-05-27 13:38:29 -04:00
not allow these headers to change any headers it sets for itself.
2015-04-01 18:39:37 -04:00
2021-04-30 08:59:05 -04:00
### Credential store options
2017-03-16 13:39:18 -04:00
2016-12-02 19:03:16 -05:00
The property `credsStore` specifies an external binary to serve as the default
credential store. When this property is set, `docker login` will attempt to
store credentials in the binary specified by `docker-credential-<value>` which
2023-12-13 09:16:56 -05:00
is visible on `$PATH` . If this property isn't set, credentials are stored
in the `auths` property of the CLI configuration file. For more information,
see the [**Credential stores** section in the `docker login` documentation ](login.md#credential-stores )
2016-12-02 19:03:16 -05:00
The property `credHelpers` specifies a set of credential helpers to use
preferentially over `credsStore` or `auths` when storing and retrieving
credentials for specific registries. If this property is set, the binary
`docker-credential-<value>` will be used when storing or retrieving credentials
for a specific registry. For more information, see the
[**Credential helpers** section in the `docker login` documentation ](login.md#credential-helpers )
2021-04-30 08:59:05 -04:00
### Automatic proxy configuration for containers
2018-05-22 15:28:00 -04:00
The property `proxies` specifies proxy environment variables to be automatically
set on containers, and set as `--build-arg` on containers used during `docker build` .
2023-12-13 09:16:56 -05:00
A `"default"` set of proxies can be configured, and will be used for any Docker
daemon that the client connects to, or a configuration per host (Docker daemon),
for example, `https://docker-daemon1.example.com` . The following properties can
2018-05-22 15:28:00 -04:00
be set for each environment:
2021-04-30 08:59:05 -04:00
| Property | Description |
|:---------------|:--------------------------------------------------------------------------------------------------------|
| `httpProxy` | Default value of `HTTP_PROXY` and `http_proxy` for containers, and as `--build-arg` on `docker build` |
| `httpsProxy` | Default value of `HTTPS_PROXY` and `https_proxy` for containers, and as `--build-arg` on `docker build` |
| `ftpProxy` | Default value of `FTP_PROXY` and `ftp_proxy` for containers, and as `--build-arg` on `docker build` |
| `noProxy` | Default value of `NO_PROXY` and `no_proxy` for containers, and as `--build-arg` on `docker build` |
2021-04-30 05:53:53 -04:00
| `allProxy` | Default value of `ALL_PROXY` and `all_proxy` for containers, and as `--build-arg` on `docker build` |
2021-04-30 08:59:05 -04:00
These settings are used to configure proxy settings for containers only, and not
used as proxy settings for the `docker` CLI or the `dockerd` daemon. Refer to the
[environment variables ](#environment-variables ) and [HTTP/HTTPS proxy ](https://docs.docker.com/config/daemon/systemd/#httphttps-proxy )
sections for configuring proxy settings for the cli and daemon.
2018-05-22 15:28:00 -04:00
2021-04-30 06:08:28 -04:00
> **Warning**
2023-12-13 09:16:56 -05:00
>
2021-04-30 06:08:28 -04:00
> Proxy settings may contain sensitive information (for example, if the proxy
> requires authentication). Environment variables are stored as plain text in
> the container's configuration, and as such can be inspected through the remote
> API or committed to an image when using `docker commit`.
2023-12-13 09:16:56 -05:00
{ .warning }
2018-05-22 15:28:00 -04:00
2021-04-30 08:59:05 -04:00
### Default key-sequence to detach from containers
2016-01-03 17:03:39 -05:00
Once attached to a container, users detach from it and leave it running using
the using `CTRL-p CTRL-q` key sequence. This detach key sequence is customizable
using the `detachKeys` property. Specify a `<sequence>` value for the
2016-10-14 18:30:36 -04:00
property. The format of the `<sequence>` is a comma-separated list of either
2016-01-14 16:58:41 -05:00
a letter [a-Z], or the `ctrl-` combined with any of the following:
2016-01-03 17:03:39 -05:00
* `a-z` (a single lowercase alpha character )
2016-02-05 16:47:57 -05:00
* `@` (at sign)
2016-01-03 17:03:39 -05:00
* `[` (left bracket)
* `\\` (two backward slashes)
2023-12-13 09:16:56 -05:00
* `_` (underscore)
2016-01-03 17:03:39 -05:00
* `^` (caret)
Your customization applies to all containers started in with your Docker client.
Users can override your custom or the default key sequence on a per-container
basis. To do this, the user specifies the `--detach-keys` flag with the `docker
attach`, `docker exec` , `docker run` or `docker start` command.
2015-07-17 00:03:16 -04:00
2023-12-13 09:16:56 -05:00
### CLI plugin options
2021-04-30 08:59:05 -04:00
2019-02-18 09:23:30 -05:00
The property `plugins` contains settings specific to CLI plugins. The
key is the plugin name, while the value is a further map of options,
which are specific to that plugin.
2021-04-30 08:59:05 -04:00
### Sample configuration file
Following is a sample `config.json` file to illustrate the format used for
various fields:
2015-04-01 18:39:37 -04:00
2017-02-07 18:42:48 -05:00
```json
{
"HttpHeaders": {
"MyHeader": "MyValue"
},
"psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Command}}\\t{{.Labels}}",
"imagesFormat": "table {{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}",
"pluginsFormat": "table {{.ID}}\t{{.Name}}\t{{.Enabled}}",
"statsFormat": "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}",
"servicesFormat": "table {{.ID}}\t{{.Name}}\t{{.Mode}}",
2017-03-05 06:11:04 -05:00
"secretFormat": "table {{.ID}}\t{{.Name}}\t{{.CreatedAt}}\t{{.UpdatedAt}}",
2017-03-16 13:39:18 -04:00
"configFormat": "table {{.ID}}\t{{.Name}}\t{{.CreatedAt}}\t{{.UpdatedAt}}",
2017-02-07 18:42:48 -05:00
"serviceInspectFormat": "pretty",
2017-01-24 16:17:40 -05:00
"nodesFormat": "table {{.ID}}\t{{.Hostname}}\t{{.Availability}}",
2017-02-07 18:42:48 -05:00
"detachKeys": "ctrl-e,e",
"credsStore": "secretservice",
"credHelpers": {
"awesomereg.example.org": "hip-star",
"unicorn.example.com": "vcbait"
2018-06-22 02:16:27 -04:00
},
2019-02-18 09:23:30 -05:00
"plugins": {
"plugin1": {
"option": "value"
},
"plugin2": {
"anotheroption": "anothervalue",
"athirdoption": "athirdvalue"
}
2018-05-22 15:28:00 -04:00
},
"proxies": {
"default": {
"httpProxy": "http://user:pass@example.com:3128",
2021-04-30 06:08:28 -04:00
"httpsProxy": "https://my-proxy.example.com:3129",
"noProxy": "intra.mycorp.example.com",
2021-04-30 05:53:53 -04:00
"ftpProxy": "http://user:pass@example.com:3128",
"allProxy": "socks://example.com:1234"
2018-05-22 15:28:00 -04:00
},
"https://manager1.mycorp.example.com:2377": {
"httpProxy": "http://user:pass@example.com:3128",
2021-04-30 06:08:28 -04:00
"httpsProxy": "https://my-proxy.example.com:3129"
2021-04-30 08:59:05 -04:00
}
2019-02-18 09:23:30 -05:00
}
2017-02-07 18:42:48 -05:00
}
```
2015-04-01 18:39:37 -04:00
2019-09-03 19:23:27 -04:00
### Experimental features
2019-09-19 16:33:47 -04:00
Experimental features provide early access to future product functionality.
2020-10-02 08:19:34 -04:00
These features are intended for testing and feedback, and they may change
between releases without warning or can be removed from a future release.
2019-09-03 19:23:27 -04:00
2021-08-23 11:35:25 -04:00
Starting with Docker 20.10, experimental CLI features are enabled by default,
and require no configuration to enable them.
2015-10-26 19:54:47 -04:00
### Notary
If using your own notary server and a self-signed certificate or an internal
Certificate Authority, you need to place the certificate at
2023-12-13 09:16:56 -05:00
`tls/<registry_url>/ca.crt` in your Docker config directory.
2015-10-26 19:54:47 -04:00
Alternatively you can trust the certificate globally by adding it to your system's
list of root Certificate Authorities.
2017-02-07 18:42:48 -05:00
## Examples
2023-05-05 10:47:16 -04:00
### <a name="host"></a> Specify daemon host (-H, --host)
You can use the `-H` , `--host` flag to specify a socket to use when you invoke
a `docker` command. You can use the following protocols:
| Scheme | Description | Example |
|----------------------------------------|---------------------------|----------------------------------|
| `unix://[<path>]` | Unix socket (Linux only) | `unix:///var/run/docker.sock` |
| `tcp://[<IP or host>[:port]]` | TCP connection | `tcp://174.17.0.1:2376` |
| `ssh://[username@]<IP or host>[:port]` | SSH connection | `ssh://user@192.168.64.5` |
| `npipe://[<name>]` | Named pipe (Windows only) | `npipe:////./pipe/docker_engine` |
If you don't specify the `-H` flag, and you're not using a custom
[context ](https://docs.docker.com/engine/context/working-with-contexts ),
commands use the following default sockets:
- `unix:///var/run/docker.sock` on macOS and Linux
- `npipe:////./pipe/docker_engine` on Windows
To achieve a similar effect without having to specify the `-H` flag for every
command, you could also [create a context ](context_create.md ),
or alternatively, use the
[`DOCKER_HOST` environment variable ](#environment-variables ).
For more information about the `-H` flag, see
[Daemon socket option ](dockerd.md#daemon-socket-option ).
#### Using TCP sockets
The following example shows how to invoke `docker ps` over TCP, to a remote
daemon with IP address `174.17.0.1` , listening on port `2376` :
```console
$ docker -H tcp://174.17.0.1:2376 ps
```
> **Note**
>
> By convention, the Docker daemon uses port `2376` for secure TLS connections,
> and port `2375` for insecure, non-TLS connections.
#### Using SSH sockets
When you use SSH invoke a command on a remote daemon, the request gets forwarded
to the `/var/run/docker.sock` Unix socket on the SSH host.
```console
$ docker -H ssh://user@192.168.64.5 ps
```
2023-06-02 08:39:57 -04:00
You can optionally specify the location of the socket by appending a path
component to the end of the SSH address.
```console
$ docker -H ssh://user@192.168.64.5/var/run/docker.sock ps
```
2017-02-07 18:42:48 -05:00
### Display help text
2015-05-27 13:38:29 -04:00
To list the help on any command just execute the command, followed by the
`--help` option.
2014-10-15 17:14:12 -04:00
2021-04-30 08:59:05 -04:00
```console
$ docker run --help
2014-10-15 17:14:12 -04:00
2021-04-30 08:59:05 -04:00
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
2014-10-15 17:14:12 -04:00
2022-03-29 17:58:36 -04:00
Create and run a new container from an image
2014-10-15 17:14:12 -04:00
2021-04-30 08:59:05 -04:00
Options:
--add-host value Add a custom host-to-IP mapping (host:ip) (default [])
-a, --attach value Attach to STDIN, STDOUT or STDERR (default [])
< ... >
```
2014-10-15 17:14:12 -04:00
2017-02-07 18:42:48 -05:00
### Option types
2014-04-15 20:53:12 -04:00
2015-02-03 22:36:52 -05:00
Single character command line options can be combined, so rather than
2015-02-27 09:45:37 -05:00
typing `docker run -i -t --name test busybox sh` ,
you can write `docker run -it --name test busybox sh` .
2014-04-15 20:53:12 -04:00
2017-02-07 18:42:48 -05:00
#### Boolean
2014-04-15 20:53:12 -04:00
2015-05-27 13:38:29 -04:00
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.
2015-02-03 22:36:52 -05:00
2015-05-27 13:38:29 -04:00
For example, running `docker run -d` will set the value to `true` , so your
container **will** run in "detached" mode, in the background.
2015-02-03 22:36:52 -05:00
2015-05-27 13:38:29 -04:00
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` :
2015-02-03 22:36:52 -05:00
2021-04-30 08:59:05 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker build --rm=false .
```
2014-04-15 20:53:12 -04:00
2017-02-07 18:42:48 -05:00
#### Multi
2014-04-15 20:53:12 -04:00
2015-04-07 16:25:48 -04:00
You can specify options like `-a=[]` multiple times in a single command line,
for example in these commands:
2014-04-15 20:53:12 -04:00
2021-04-30 08:59:05 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker run -a stdin -a stdout -i -t ubuntu /bin/bash
$ docker run -a stdin -a stdout -a stderr ubuntu /bin/ls
```
2014-04-15 20:53:12 -04:00
2015-05-27 13:38:29 -04:00
Sometimes, multiple options can call for a more complex value string as for
`-v` :
2014-04-15 20:53:12 -04:00
2021-04-30 08:59:05 -04:00
```console
2017-02-07 18:42:48 -05:00
$ docker run -v /host:/container example/mysql
```
2014-04-15 20:53:12 -04:00
2020-04-19 11:08:37 -04:00
> **Note**
>
> Do not use the `-t` and `-a stderr` options together due to
2015-05-27 13:38:29 -04:00
> limitations in the `pty` implementation. All `stderr` in `pty` mode
> simply goes to `stdout`.
2015-04-07 16:25:48 -04:00
2017-02-07 18:42:48 -05:00
#### Strings and Integers
2014-04-15 20:53:12 -04:00
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.