Merge pull request #31242 from thaJeztah/17.03-docs-cherry-picks
17.03 docs cherry picks
This commit is contained in:
commit
d7bc6e4e7c
131 changed files with 3737 additions and 1924 deletions
|
@ -4043,6 +4043,11 @@ paths:
|
|||
description: "If the container is running, kill it before removing it."
|
||||
type: "boolean"
|
||||
default: false
|
||||
- name: "link"
|
||||
in: "query"
|
||||
description: "Remove the specified link associated with the container."
|
||||
type: "boolean"
|
||||
default: false
|
||||
tags: ["Container"]
|
||||
/containers/{id}/archive:
|
||||
head:
|
||||
|
|
|
@ -21,7 +21,7 @@ func NewDiffCommand(dockerCli *command.DockerCli) *cobra.Command {
|
|||
|
||||
return &cobra.Command{
|
||||
Use: "diff CONTAINER",
|
||||
Short: "Inspect changes on a container's filesystem",
|
||||
Short: "Inspect changes to files or directories on a container's filesystem",
|
||||
Args: cli.ExactArgs(1),
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
opts.container = args[0]
|
||||
|
|
|
@ -35,7 +35,7 @@ script
|
|||
end script
|
||||
```
|
||||
|
||||
Once that's done, you need to set up a SSH tunnel between your host machine and the vagrant machine that's running Docker. This can be done by running the following command in a host terminal:
|
||||
Once that's done, you need to set up an SSH tunnel between your host machine and the vagrant machine that's running Docker. This can be done by running the following command in a host terminal:
|
||||
|
||||
```
|
||||
ssh -L 2375:localhost:2375 -p 2222 vagrant@localhost
|
||||
|
|
|
@ -21,8 +21,8 @@ redirect_from:
|
|||
- The daemon listens on `unix:///var/run/docker.sock` but you can
|
||||
[Bind Docker to another host/port or a Unix socket](../reference/commandline/dockerd.md#bind-docker-to-another-host-port-or-a-unix-socket).
|
||||
- The API tends to be REST, but for some complex commands, like `attach`
|
||||
or `pull`, the HTTP connection is hijacked to transport `STDOUT`,
|
||||
`STDIN` and `STDERR`.
|
||||
or `pull`, the HTTP connection is hijacked to transport `stdout`,
|
||||
`stdin` and `stderr`.
|
||||
|
||||
## 2. Endpoints
|
||||
|
||||
|
@ -1056,6 +1056,8 @@ Remove the container `id` from the filesystem
|
|||
associated to the container. Default `false`.
|
||||
- **force** - 1/True/true or 0/False/false, Kill then remove the container.
|
||||
Default `false`.
|
||||
- **link** - 1/True/true or 0/False/false, Remove the specified
|
||||
link associated to the container. Default `false`.
|
||||
|
||||
**Status codes**:
|
||||
|
||||
|
|
|
@ -1095,6 +1095,8 @@ Remove the container `id` from the filesystem
|
|||
associated to the container. Default `false`.
|
||||
- **force** - 1/True/true or 0/False/false, Kill then remove the container.
|
||||
Default `false`.
|
||||
- **link** - 1/True/true or 0/False/false, Remove the specified
|
||||
link associated to the container. Default `false`.
|
||||
|
||||
**Status codes**:
|
||||
|
||||
|
|
|
@ -1102,6 +1102,8 @@ Remove the container `id` from the filesystem
|
|||
associated to the container. Default `false`.
|
||||
- **force** - 1/True/true or 0/False/false, Kill then remove the container.
|
||||
Default `false`.
|
||||
- **link** - 1/True/true or 0/False/false, Remove the specified
|
||||
link associated to the container. Default `false`.
|
||||
|
||||
**Status codes**:
|
||||
|
||||
|
|
|
@ -1185,6 +1185,8 @@ Remove the container `id` from the filesystem
|
|||
associated to the container. Default `false`.
|
||||
- **force** - 1/True/true or 0/False/false, Kill then remove the container.
|
||||
Default `false`.
|
||||
- **link** - 1/True/true or 0/False/false, Remove the specified
|
||||
link associated to the container. Default `false`.
|
||||
|
||||
**Status codes**:
|
||||
|
||||
|
|
|
@ -388,7 +388,7 @@ Create a container
|
|||
`"BlkioDeviceWriteBps": [{"Path": "/dev/sda", "Rate": "1024"}]"`
|
||||
- **BlkioDeviceReadIOps** - Limit read rate (IO per second) from a device in the form of: `"BlkioDeviceReadIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
|
||||
`"BlkioDeviceReadIOps": [{"Path": "/dev/sda", "Rate": "1000"}]`
|
||||
- **BlkioDeviceWiiteIOps** - Limit write rate (IO per second) to a device in the form of: `"BlkioDeviceWriteIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
|
||||
- **BlkioDeviceWriteIOps** - Limit write rate (IO per second) to a device in the form of: `"BlkioDeviceWriteIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
|
||||
`"BlkioDeviceWriteIOps": [{"Path": "/dev/sda", "Rate": "1000"}]`
|
||||
- **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
|
||||
- **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not.
|
||||
|
@ -1108,7 +1108,7 @@ Update resource configs of one or more containers.
|
|||
"Memory": 314572800,
|
||||
"MemorySwap": 514288000,
|
||||
"MemoryReservation": 209715200,
|
||||
"KernelMemory": 52428800,
|
||||
"KernelMemory": 52428800
|
||||
}
|
||||
|
||||
**Example response**:
|
||||
|
@ -1364,6 +1364,8 @@ Remove the container `id` from the filesystem
|
|||
associated to the container. Default `false`.
|
||||
- **force** - 1/True/true or 0/False/false, Kill then remove the container.
|
||||
Default `false`.
|
||||
- **link** - 1/True/true or 0/False/false, Remove the specified
|
||||
link associated to the container. Default `false`.
|
||||
|
||||
**Status codes**:
|
||||
|
||||
|
|
|
@ -413,7 +413,7 @@ Create a container
|
|||
`"BlkioDeviceWriteBps": [{"Path": "/dev/sda", "Rate": "1024"}]"`
|
||||
- **BlkioDeviceReadIOps** - Limit read rate (IO per second) from a device in the form of: `"BlkioDeviceReadIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
|
||||
`"BlkioDeviceReadIOps": [{"Path": "/dev/sda", "Rate": "1000"}]`
|
||||
- **BlkioDeviceWiiteIOps** - Limit write rate (IO per second) to a device in the form of: `"BlkioDeviceWriteIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
|
||||
- **BlkioDeviceWriteIOps** - Limit write rate (IO per second) to a device in the form of: `"BlkioDeviceWriteIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
|
||||
`"BlkioDeviceWriteIOps": [{"Path": "/dev/sda", "Rate": "1000"}]`
|
||||
- **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
|
||||
- **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not.
|
||||
|
@ -1143,7 +1143,7 @@ Update configuration of one or more containers.
|
|||
"RestartPolicy": {
|
||||
"MaximumRetryCount": 4,
|
||||
"Name": "on-failure"
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
**Example response**:
|
||||
|
@ -1399,6 +1399,8 @@ Remove the container `id` from the filesystem
|
|||
associated to the container. Default `false`.
|
||||
- **force** - 1/True/true or 0/False/false, Kill then remove the container.
|
||||
Default `false`.
|
||||
- **link** - 1/True/true or 0/False/false, Remove the specified
|
||||
link associated to the container. Default `false`.
|
||||
|
||||
**Status codes**:
|
||||
|
||||
|
|
|
@ -431,7 +431,7 @@ Create a container
|
|||
`"BlkioDeviceWriteBps": [{"Path": "/dev/sda", "Rate": "1024"}]"`
|
||||
- **BlkioDeviceReadIOps** - Limit read rate (IO per second) from a device in the form of: `"BlkioDeviceReadIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
|
||||
`"BlkioDeviceReadIOps": [{"Path": "/dev/sda", "Rate": "1000"}]`
|
||||
- **BlkioDeviceWiiteIOps** - Limit write rate (IO per second) to a device in the form of: `"BlkioDeviceWriteIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
|
||||
- **BlkioDeviceWriteIOps** - Limit write rate (IO per second) to a device in the form of: `"BlkioDeviceWriteIOps": [{"Path": "device_path", "Rate": rate}]`, for example:
|
||||
`"BlkioDeviceWriteIOps": [{"Path": "/dev/sda", "Rate": "1000"}]`
|
||||
- **MemorySwappiness** - Tune a container's memory swappiness behavior. Accepts an integer between 0 and 100.
|
||||
- **OomKillDisable** - Boolean value, whether to disable OOM Killer for the container or not.
|
||||
|
@ -1170,7 +1170,7 @@ Update configuration of one or more containers.
|
|||
"RestartPolicy": {
|
||||
"MaximumRetryCount": 4,
|
||||
"Name": "on-failure"
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
**Example response**:
|
||||
|
@ -1426,6 +1426,8 @@ Remove the container `id` from the filesystem
|
|||
associated to the container. Default `false`.
|
||||
- **force** - 1/True/true or 0/False/false, Kill then remove the container.
|
||||
Default `false`.
|
||||
- **link** - 1/True/true or 0/False/false, Remove the specified
|
||||
link associated to the container. Default `false`.
|
||||
|
||||
**Status codes**:
|
||||
|
||||
|
@ -4689,7 +4691,7 @@ image](#create-an-image) section for more details.
|
|||
as part of this service.
|
||||
- **Condition** – Condition for restart (`none`, `on-failure`, or `any`).
|
||||
- **Delay** – Delay between restart attempts.
|
||||
- **Attempts** – Maximum attempts to restart a given container before giving up (default value
|
||||
- **MaxAttempts** – Maximum attempts to restart a given container before giving up (default value
|
||||
is 0, which is ignored).
|
||||
- **Window** – Windows is the time window used to evaluate the restart policy (default value is
|
||||
0, which is unbounded).
|
||||
|
@ -4835,7 +4837,7 @@ Return information on the service `id`.
|
|||
|
||||
#### Update a service
|
||||
|
||||
`POST /services/(id or name)/update`
|
||||
`POST /services/(id)/update`
|
||||
|
||||
Update a service. When using this endpoint to create a service using a
|
||||
private repository from the registry, the `X-Registry-Auth` header can be used
|
||||
|
|
|
@ -83,6 +83,7 @@ keywords: "API, Docker, rcli, REST, documentation"
|
|||
* `DELETE /secrets/{id}` removes the secret `id`.
|
||||
* `GET /secrets/{id}` returns information on the secret `id`.
|
||||
* `POST /secrets/{id}/update` updates the secret `id`.
|
||||
* `POST /services/(id or name)/update` now accepts service name or prefix of service id as a parameter.
|
||||
|
||||
## v1.24 API changes
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ see [Feature Deprecation Policy](https://docs.docker.com/engine/#feature-depreca
|
|||
|
||||
### Top-level network properties in NetworkSettings
|
||||
|
||||
**Deprecated In Release: v1.13.0**
|
||||
**Deprecated In Release: [v1.13.0](https://github.com/docker/docker/releases/tag/v1.13.0)**
|
||||
|
||||
**Target For Removal In Release: v1.16**
|
||||
|
||||
|
@ -183,7 +183,11 @@ Log tags are now generated in a standard way across different logging drivers.
|
|||
Because of which, the driver specific log tag options `syslog-tag`, `gelf-tag` and
|
||||
`fluentd-tag` have been deprecated in favor of the generic `tag` option.
|
||||
|
||||
docker --log-driver=syslog --log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}"
|
||||
```bash
|
||||
{% raw %}
|
||||
docker --log-driver=syslog --log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}"
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### LXC built-in exec driver
|
||||
**Deprecated In Release: [v1.8.0](https://github.com/docker/docker/releases/tag/v1.8.0)**
|
||||
|
|
|
@ -17,10 +17,10 @@ title: Managed plugin system
|
|||
|
||||
* [Installing and using a plugin](index.md#installing-and-using-a-plugin)
|
||||
* [Developing a plugin](index.md#developing-a-plugin)
|
||||
* [Debugging plugins](index.md#debugging-plugins)
|
||||
|
||||
Docker Engine's plugins system allows you to install, start, stop, and remove
|
||||
plugins using Docker Engine. This mechanism is currently only available for
|
||||
volume drivers, but more plugin driver types will be available in future releases.
|
||||
plugins using Docker Engine.
|
||||
|
||||
For information about the legacy plugin system available in Docker Engine 1.12
|
||||
and earlier, see [Understand legacy Docker Engine plugins](legacy_plugins.md).
|
||||
|
@ -46,6 +46,8 @@ operation, such as creating a volume.
|
|||
In the following example, you install the `sshfs` plugin, verify that it is
|
||||
enabled, and use it to create a volume.
|
||||
|
||||
> **Note**: This example is intended for instructional purposes only. Once the volume is created, your SSH password to the remote host will be exposed as plaintext when inspecting the volume. You should delete the volume as soon as you are done with the example.
|
||||
|
||||
1. Install the `sshfs` plugin.
|
||||
|
||||
```bash
|
||||
|
@ -75,13 +77,16 @@ enabled, and use it to create a volume.
|
|||
|
||||
3. Create a volume using the plugin.
|
||||
This example mounts the `/remote` directory on host `1.2.3.4` into a
|
||||
volume named `sshvolume`. This volume can now be mounted into containers.
|
||||
volume named `sshvolume`.
|
||||
|
||||
This volume can now be mounted into containers.
|
||||
|
||||
```bash
|
||||
$ docker volume create \
|
||||
-d vieux/sshfs \
|
||||
--name sshvolume \
|
||||
-o sshcmd=user@1.2.3.4:/remote
|
||||
-o sshcmd=user@1.2.3.4:/remote \
|
||||
-o password=$(cat file_containing_password_for_remote_host)
|
||||
|
||||
sshvolume
|
||||
```
|
||||
|
@ -97,11 +102,17 @@ enabled, and use it to create a volume.
|
|||
5. Start a container that uses the volume `sshvolume`.
|
||||
|
||||
```bash
|
||||
$ docker run -v sshvolume:/data busybox ls /data
|
||||
$ docker run --rm -v sshvolume:/data busybox ls /data
|
||||
|
||||
<content of /remote on machine 1.2.3.4>
|
||||
```
|
||||
|
||||
6. Remove the volume `sshvolume`
|
||||
```bash
|
||||
docker volume rm sshvolume
|
||||
|
||||
sshvolume
|
||||
```
|
||||
To disable a plugin, use the `docker plugin disable` command. To completely
|
||||
remove it, use the `docker plugin remove` command. For other available
|
||||
commands and options, see the
|
||||
|
@ -111,10 +122,10 @@ commands and options, see the
|
|||
|
||||
In swarm mode, it is possible to create a service that allows for attaching
|
||||
to networks or mounting volumes. Swarm schedules services based on plugin availability
|
||||
on a node. In this example, a volume plugin is installed on a swarm worker and a volume
|
||||
on a node. In this example, a volume plugin is installed on a swarm worker and a volume
|
||||
is created using the plugin. In the manager, a service is created with the relevant
|
||||
mount options. It can be observed that the service is scheduled to run on the worker
|
||||
node with the said volume plugin and volume.
|
||||
node with the said volume plugin and volume.
|
||||
|
||||
In the following example, node1 is the manager and node2 is the worker.
|
||||
|
||||
|
@ -141,7 +152,7 @@ In the following example, node1 is the manager and node2 is the worker.
|
|||
Status: Downloaded newer image for tiborvass/sample-volume-plugin:latest
|
||||
Installed plugin tiborvass/sample-volume-plugin
|
||||
```
|
||||
|
||||
|
||||
```bash
|
||||
$ docker volume create -d tiborvass/sample-volume-plugin --name pluginVol
|
||||
```
|
||||
|
@ -152,15 +163,17 @@ In the following example, node1 is the manager and node2 is the worker.
|
|||
$ docker service create --name my-service --mount type=volume,volume-driver=tiborvass/sample-volume-plugin,source=pluginVol,destination=/tmp busybox top
|
||||
|
||||
$ docker service ls
|
||||
z1sj8bb8jnfn my-service replicated 1/1 busybox:latest
|
||||
z1sj8bb8jnfn my-service replicated 1/1 busybox:latest
|
||||
```
|
||||
docker service ls shows service 1 instance of service running.
|
||||
|
||||
4. Observe the task getting scheduled in node 2:
|
||||
|
||||
```bash
|
||||
$ docker ps --format '{{.ID}}\t {{.Status}} {{.Names}} {{.Command}}'
|
||||
{% raw %}
|
||||
$ docker ps --format '{{.ID}}\t {{.Status}} {{.Names}} {{.Command}}'
|
||||
83fc1e842599 Up 2 days my-service.1.9jn59qzn7nbc3m0zt1hij12xs "top"
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Developing a plugin
|
||||
|
@ -201,7 +214,9 @@ Consider the following `config.json` file.
|
|||
"types": ["docker.volumedriver/1.0"],
|
||||
"socket": "sshfs.sock"
|
||||
},
|
||||
"capabilities": ["CAP_SYS_ADMIN"]
|
||||
"linux": {
|
||||
"capabilities": ["CAP_SYS_ADMIN"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -215,8 +230,89 @@ with Docker Engine. This plugin has no runtime parameters.
|
|||
A new plugin can be created by running
|
||||
`docker plugin create <plugin-name> ./path/to/plugin/data` where the plugin
|
||||
data contains a plugin configuration file `config.json` and a root filesystem
|
||||
in subdirectory `rootfs`.
|
||||
in subdirectory `rootfs`.
|
||||
|
||||
After that the plugin `<plugin-name>` will show up in `docker plugin ls`.
|
||||
Plugins can be pushed to remote registries with
|
||||
`docker plugin push <plugin-name>`.
|
||||
|
||||
|
||||
## Debugging plugins
|
||||
|
||||
Stdout of a plugin is redirected to dockerd logs. Such entries have a
|
||||
`plugin=<ID>` suffix. Here are a few examples of commands for pluginID
|
||||
`f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62` and their
|
||||
corresponding log entries in the docker daemon logs.
|
||||
|
||||
```bash
|
||||
$ docker plugin install tiborvass/sample-volume-plugins
|
||||
|
||||
INFO[0036] Starting... Found 0 volumes on startup plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
```
|
||||
|
||||
```bash
|
||||
$ docker volume create -d tiborvass/sample-volume-plugins samplevol
|
||||
|
||||
INFO[0193] Create Called... Ensuring directory /data/samplevol exists on host... plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
INFO[0193] open /var/lib/docker/plugin-data/local-persist.json: no such file or directory plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
INFO[0193] Created volume samplevol with mountpoint /data/samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
INFO[0193] Path Called... Returned path /data/samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
```
|
||||
|
||||
```bash
|
||||
$ docker run -v samplevol:/tmp busybox sh
|
||||
|
||||
INFO[0421] Get Called... Found samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
INFO[0421] Mount Called... Mounted samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
INFO[0421] Path Called... Returned path /data/samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
INFO[0421] Unmount Called... Unmounted samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
|
||||
```
|
||||
|
||||
#### Using docker-runc to obtain logfiles and shell into the plugin.
|
||||
|
||||
`docker-runc`, the default docker container runtime can be used for debugging
|
||||
plugins. This is specifically useful to collect plugin logs if they are
|
||||
redirected to a file.
|
||||
|
||||
```bash
|
||||
$ docker-runc list
|
||||
ID PID STATUS BUNDLE CREATED
|
||||
f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62 2679 running /run/docker/libcontainerd/f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62 2017-02-06T21:53:03.031537592Z
|
||||
r
|
||||
```
|
||||
|
||||
```bash
|
||||
$ docker-runc exec f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62 cat /var/log/plugin.log
|
||||
```
|
||||
|
||||
If the plugin has a built-in shell, then exec into the plugin can be done as
|
||||
follows:
|
||||
```bash
|
||||
$ docker-runc exec -t f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62 sh
|
||||
```
|
||||
|
||||
#### Using curl to debug plugin socket issues.
|
||||
|
||||
To verify if the plugin API socket that the docker daemon communicates with
|
||||
is responsive, use curl. In this example, we will make API calls from the
|
||||
docker host to volume and network plugins using curl 7.47.0 to ensure that
|
||||
the plugin is listening on the said socket. For a well functioning plugin,
|
||||
these basic requests should work. Note that plugin sockets are available on the host under `/var/run/docker/plugins/<pluginID>`
|
||||
|
||||
|
||||
```bash
|
||||
curl -H "Content-Type: application/json" -XPOST -d '{}' --unix-socket /var/run/docker/plugins/e8a37ba56fc879c991f7d7921901723c64df6b42b87e6a0b055771ecf8477a6d/plugin.sock http:/VolumeDriver.List
|
||||
|
||||
{"Mountpoint":"","Err":"","Volumes":[{"Name":"myvol1","Mountpoint":"/data/myvol1"},{"Name":"myvol2","Mountpoint":"/data/myvol2"}],"Volume":null}
|
||||
```
|
||||
|
||||
```bash
|
||||
curl -H "Content-Type: application/json" -XPOST -d '{}' --unix-socket /var/run/docker/plugins/45e00a7ce6185d6e365904c8bcf62eb724b1fe307e0d4e7ecc9f6c1eb7bcdb70/plugin.sock http:/NetworkDriver.GetCapabilities
|
||||
|
||||
{"Scope":"local"}
|
||||
```
|
||||
When using curl 7.5 and above, the URL should be of the form
|
||||
`http://hostname/APICall`, where `hostname` is the valid hostname where the
|
||||
plugin is installed and `APICall` is the call to the plugin API.
|
||||
|
||||
For example, `http://localhost/VolumeDriver.List`
|
||||
|
|
|
@ -63,8 +63,10 @@ Plugin
|
|||
[Blockbridge plugin](https://github.com/blockbridge/blockbridge-docker-volume) | A volume plugin that provides access to an extensible set of container-based persistent storage options. It supports single and multi-host Docker environments with features that include tenant isolation, automated provisioning, encryption, secure deletion, snapshots and QoS.
|
||||
[Contiv Volume Plugin](https://github.com/contiv/volplugin) | An open source volume plugin that provides multi-tenant, persistent, distributed storage with intent based consumption. It has support for Ceph and NFS.
|
||||
[Convoy plugin](https://github.com/rancher/convoy) | A volume plugin for a variety of storage back-ends including device mapper and NFS. It's a simple standalone executable written in Go and provides the framework to support vendor-specific extensions such as snapshots, backups and restore.
|
||||
[DigitalOcean Block Storage plugin](https://github.com/omallo/docker-volume-plugin-dostorage) | Integrates DigitalOcean's [block storage solution](https://www.digitalocean.com/products/storage/) into the Docker ecosystem by automatically attaching a given block storage volume to a DigitalOcean droplet and making the contents of the volume available to Docker containers running on that droplet.
|
||||
[DRBD plugin](https://www.drbd.org/en/supported-projects/docker) | A volume plugin that provides highly available storage replicated by [DRBD](https://www.drbd.org). Data written to the docker volume is replicated in a cluster of DRBD nodes.
|
||||
[Flocker plugin](https://clusterhq.com/docker-plugin/) | A volume plugin that provides multi-host portable volumes for Docker, enabling you to run databases and other stateful containers and move them around across a cluster of machines.
|
||||
[Fuxi Volume Plugin](https://github.com/openstack/fuxi) | A volume plugin that is developed as part of the OpenStack Kuryr project and implements the Docker volume plugin API by utilizing Cinder, the OpenStack block storage service.
|
||||
[gce-docker plugin](https://github.com/mcuadros/gce-docker) | A volume plugin able to attach, format and mount Google Compute [persistent-disks](https://cloud.google.com/compute/docs/disks/persistent-disks).
|
||||
[GlusterFS plugin](https://github.com/calavera/docker-volume-glusterfs) | A volume plugin that provides multi-host volumes management for Docker using GlusterFS.
|
||||
[Horcrux Volume Plugin](https://github.com/muthu-r/horcrux) | A volume plugin that allows on-demand, version controlled access to your data. Horcrux is an open-source plugin, written in Go, and supports SCP, [Minio](https://www.minio.io) and Amazon S3.
|
||||
|
|
|
@ -287,7 +287,9 @@ and `Parent`. `Parent` may be an empty string, in which case there is no parent.
|
|||
|
||||
**Response**:
|
||||
```
|
||||
{% raw %}
|
||||
{{ TAR STREAM }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### /GraphDriver.Changes
|
||||
|
@ -330,7 +332,9 @@ Respond with a non-empty string error if an error occurred.
|
|||
|
||||
**Request**:
|
||||
```
|
||||
{% raw %}
|
||||
{{ TAR STREAM }}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Extract the changeset from the given diff into the layer with the specified `ID`
|
||||
|
|
|
@ -16,67 +16,86 @@ keywords: "Examples, Usage, volume, docker, data, volumes, plugin, api"
|
|||
# Write a volume plugin
|
||||
|
||||
Docker Engine volume plugins enable Engine deployments to be integrated with
|
||||
external storage systems, such as Amazon EBS, and enable data volumes to persist
|
||||
beyond the lifetime of a single Engine host. See the
|
||||
external storage systems such as Amazon EBS, and enable data volumes to persist
|
||||
beyond the lifetime of a single Docker host. See the
|
||||
[plugin documentation](legacy_plugins.md) for more information.
|
||||
|
||||
## Changelog
|
||||
|
||||
### 1.13.0
|
||||
|
||||
- If used as part of the v2 plugin architecture, mountpoints that are part of paths returned by plugin have to be mounted under the directory specified by PropagatedMount in the plugin configuration [#26398](https://github.com/docker/docker/pull/26398)
|
||||
- If used as part of the v2 plugin architecture, mountpoints that are part of
|
||||
paths returned by the plugin must be mounted under the directory specified by
|
||||
`PropagatedMount` in the plugin configuration
|
||||
([#26398](https://github.com/docker/docker/pull/26398))
|
||||
|
||||
### 1.12.0
|
||||
|
||||
- Add `Status` field to `VolumeDriver.Get` response ([#21006](https://github.com/docker/docker/pull/21006#))
|
||||
- Add `VolumeDriver.Capabilities` to get capabilities of the volume driver([#22077](https://github.com/docker/docker/pull/22077))
|
||||
- Add `Status` field to `VolumeDriver.Get` response
|
||||
([#21006](https://github.com/docker/docker/pull/21006#))
|
||||
- Add `VolumeDriver.Capabilities` to get capabilities of the volume driver
|
||||
([#22077](https://github.com/docker/docker/pull/22077))
|
||||
|
||||
### 1.10.0
|
||||
|
||||
- Add `VolumeDriver.Get` which gets the details about the volume ([#16534](https://github.com/docker/docker/pull/16534))
|
||||
- Add `VolumeDriver.List` which lists all volumes owned by the driver ([#16534](https://github.com/docker/docker/pull/16534))
|
||||
- Add `VolumeDriver.Get` which gets the details about the volume
|
||||
([#16534](https://github.com/docker/docker/pull/16534))
|
||||
- Add `VolumeDriver.List` which lists all volumes owned by the driver
|
||||
([#16534](https://github.com/docker/docker/pull/16534))
|
||||
|
||||
### 1.8.0
|
||||
|
||||
- Initial support for volume driver plugins ([#14659](https://github.com/docker/docker/pull/14659))
|
||||
- Initial support for volume driver plugins
|
||||
([#14659](https://github.com/docker/docker/pull/14659))
|
||||
|
||||
## Command-line changes
|
||||
|
||||
A volume plugin makes use of the `-v`and `--volume-driver` flag on the `docker run` command. The `-v` flag accepts a volume name and the `--volume-driver` flag a driver type, for example:
|
||||
To give a container access to a volume, use the `--volume` and `--volume-driver`
|
||||
flags on the `docker container run` command. The `--volume` (or `-v`) flag
|
||||
accepts a volume name and path on the host, and the `--volume-driver` flag
|
||||
accepts a driver type.
|
||||
|
||||
$ docker run -ti -v volumename:/data --volume-driver=flocker busybox sh
|
||||
```bash
|
||||
$ docker volume create --driver=flocker volumename
|
||||
|
||||
This command passes the `volumename` through to the volume plugin as a
|
||||
user-given name for the volume. The `volumename` must not begin with a `/`.
|
||||
$ docker container run -it --volume volumename:/data busybox sh
|
||||
```
|
||||
|
||||
By having the user specify a `volumename`, a plugin can associate the volume
|
||||
with an external volume beyond the lifetime of a single container or container
|
||||
host. This can be used, for example, to move a stateful container from one
|
||||
server to another.
|
||||
### `--volume`
|
||||
|
||||
By specifying a `volumedriver` in conjunction with a `volumename`, users can use plugins such as [Flocker](https://clusterhq.com/docker-plugin/) to manage volumes external to a single host, such as those on EBS.
|
||||
The `--volume` (or `-v`) flag takes a value that is in the format
|
||||
`<volume_name>:<mountpoint>`. The two parts of the value are
|
||||
separated by a colon (`:`) character.
|
||||
|
||||
- The volume name is a human-readable name for the volume, and cannot begin with
|
||||
a `/` character. It is referred to as `volume_name` in the rest of this topic.
|
||||
- The `Mountpoint` is the path on the host (v1) or in the plugin (v2) where the
|
||||
volume has been made available.
|
||||
|
||||
### `volumedriver`
|
||||
|
||||
Specifying a `volumedriver` in conjunction with a `volumename` allows you to
|
||||
use plugins such as [Flocker](https://github.com/ScatterHQ/flocker) to manage
|
||||
volumes external to a single host, such as those on EBS.
|
||||
|
||||
## Create a VolumeDriver
|
||||
|
||||
The container creation endpoint (`/containers/create`) accepts a `VolumeDriver`
|
||||
field of type `string` allowing to specify the name of the driver. It's default
|
||||
value of `"local"` (the default driver for local volumes).
|
||||
field of type `string` allowing to specify the name of the driver. If not
|
||||
specified, it defaults to `"local"` (the default driver for local volumes).
|
||||
|
||||
## Volume plugin protocol
|
||||
|
||||
If a plugin registers itself as a `VolumeDriver` when activated, then it is
|
||||
expected to provide writeable paths on the host filesystem for the Docker
|
||||
daemon to provide to containers to consume.
|
||||
|
||||
The Docker daemon handles bind-mounting the provided paths into user
|
||||
containers.
|
||||
If a plugin registers itself as a `VolumeDriver` when activated, it must
|
||||
provide the Docker Daemon with writeable paths on the host filesystem. The Docker
|
||||
daemon provides these paths to containers to consume. The Docker daemon makes
|
||||
the volumes available by bind-mounting the provided paths into the containers.
|
||||
|
||||
> **Note**: Volume plugins should *not* write data to the `/var/lib/docker/`
|
||||
> directory, including `/var/lib/docker/volumes`. The `/var/lib/docker/`
|
||||
> directory is reserved for Docker.
|
||||
|
||||
### /VolumeDriver.Create
|
||||
### `/VolumeDriver.Create`
|
||||
|
||||
**Request**:
|
||||
```json
|
||||
|
@ -87,9 +106,9 @@ containers.
|
|||
```
|
||||
|
||||
Instruct the plugin that the user wants to create a volume, given a user
|
||||
specified volume name. The plugin does not need to actually manifest the
|
||||
volume on the filesystem yet (until Mount is called).
|
||||
Opts is a map of driver specific options passed through from the user request.
|
||||
specified volume name. The plugin does not need to actually manifest the
|
||||
volume on the filesystem yet (until `Mount` is called).
|
||||
`Opts` is a map of driver specific options passed through from the user request.
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
|
@ -100,7 +119,7 @@ Opts is a map of driver specific options passed through from the user request.
|
|||
|
||||
Respond with a string error if an error occurred.
|
||||
|
||||
### /VolumeDriver.Remove
|
||||
### `/VolumeDriver.Remove`
|
||||
|
||||
**Request**:
|
||||
```json
|
||||
|
@ -109,7 +128,8 @@ Respond with a string error if an error occurred.
|
|||
}
|
||||
```
|
||||
|
||||
Delete the specified volume from disk. This request is issued when a user invokes `docker rm -v` to remove volumes associated with a container.
|
||||
Delete the specified volume from disk. This request is issued when a user
|
||||
invokes `docker rm -v` to remove volumes associated with a container.
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
|
@ -120,7 +140,7 @@ Delete the specified volume from disk. This request is issued when a user invoke
|
|||
|
||||
Respond with a string error if an error occurred.
|
||||
|
||||
### /VolumeDriver.Mount
|
||||
### `/VolumeDriver.Mount`
|
||||
|
||||
**Request**:
|
||||
```json
|
||||
|
@ -131,47 +151,76 @@ Respond with a string error if an error occurred.
|
|||
```
|
||||
|
||||
Docker requires the plugin to provide a volume, given a user specified volume
|
||||
name. This is called once per container start. If the same volume_name is requested
|
||||
name. `Mount` is called once per container start. If the same `volume_name` is requested
|
||||
more than once, the plugin may need to keep track of each new mount request and provision
|
||||
at the first mount request and deprovision at the last corresponding unmount request.
|
||||
|
||||
`ID` is a unique ID for the caller that is requesting the mount.
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"Mountpoint": "/path/to/directory/on/host",
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
Respond with the path on the host filesystem where the volume has been made
|
||||
available, and/or a string error if an error occurred.
|
||||
- **v1**:
|
||||
|
||||
### /VolumeDriver.Path
|
||||
```json
|
||||
{
|
||||
"Mountpoint": "/path/to/directory/on/host",
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
- **v2**:
|
||||
|
||||
```json
|
||||
{
|
||||
"Mountpoint": "/path/under/PropagatedMount",
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
`Mountpoint` is the path on the host (v1) or in the plugin (v2) where the volume
|
||||
has been made available.
|
||||
|
||||
`Err` is either empty or contains an error string.
|
||||
|
||||
### `/VolumeDriver.Path`
|
||||
|
||||
**Request**:
|
||||
|
||||
```json
|
||||
{
|
||||
"Name": "volume_name"
|
||||
}
|
||||
```
|
||||
|
||||
Docker needs reminding of the path to the volume on the host.
|
||||
Request the path to the volume with the given `volume_name`.
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"Mountpoint": "/path/to/directory/on/host",
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
Respond with the path on the host filesystem where the volume has been made
|
||||
available, and/or a string error if an error occurred. `Mountpoint` is optional,
|
||||
however the plugin may be queried again later if one is not provided.
|
||||
- **v1**:
|
||||
|
||||
### /VolumeDriver.Unmount
|
||||
```json
|
||||
{
|
||||
"Mountpoin": "/path/to/directory/on/host",
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
- **v2**:
|
||||
|
||||
```json
|
||||
{
|
||||
"Mountpoint": "/path/under/PropagatedMount",
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
Respond with the path on the host (v1) or inside the plugin (v2) where the
|
||||
volume has been made available, and/or a string error if an error occurred.
|
||||
|
||||
`Mountpoint` is optional. However, the plugin may be queried again later if one
|
||||
is not provided.
|
||||
|
||||
### `/VolumeDriver.Unmount`
|
||||
|
||||
**Request**:
|
||||
```json
|
||||
|
@ -181,8 +230,8 @@ however the plugin may be queried again later if one is not provided.
|
|||
}
|
||||
```
|
||||
|
||||
Indication that Docker no longer is using the named volume. This is called once
|
||||
per container stop. Plugin may deduce that it is safe to deprovision it at
|
||||
Docker is no longer using the named volume. `Unmount` is called once per
|
||||
container stop. Plugin may deduce that it is safe to deprovision the volume at
|
||||
this point.
|
||||
|
||||
`ID` is a unique ID for the caller that is requesting the mount.
|
||||
|
@ -197,7 +246,7 @@ this point.
|
|||
Respond with a string error if an error occurred.
|
||||
|
||||
|
||||
### /VolumeDriver.Get
|
||||
### `/VolumeDriver.Get`
|
||||
|
||||
**Request**:
|
||||
```json
|
||||
|
@ -206,20 +255,36 @@ Respond with a string error if an error occurred.
|
|||
}
|
||||
```
|
||||
|
||||
Get the volume info.
|
||||
Get info about `volume_name`.
|
||||
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"Volume": {
|
||||
"Name": "volume_name",
|
||||
"Mountpoint": "/path/to/directory/on/host",
|
||||
"Status": {}
|
||||
},
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
- **v1**:
|
||||
|
||||
```json
|
||||
{
|
||||
"Volume": {
|
||||
"Name": "volume_name",
|
||||
"Mountpoint": "/path/to/directory/on/host",
|
||||
"Status": {}
|
||||
},
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
- **v2**:
|
||||
|
||||
```json
|
||||
{
|
||||
"Volume": {
|
||||
"Name": "volume_name",
|
||||
"Mountpoint": "/path/under/PropagatedMount",
|
||||
"Status": {}
|
||||
},
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
Respond with a string error if an error occurred. `Mountpoint` and `Status` are
|
||||
optional.
|
||||
|
@ -235,17 +300,35 @@ optional.
|
|||
Get the list of volumes registered with the plugin.
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
{
|
||||
"Volumes": [
|
||||
{
|
||||
"Name": "volume_name",
|
||||
"Mountpoint": "/path/to/directory/on/host"
|
||||
}
|
||||
],
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
- **v1**:
|
||||
|
||||
```json
|
||||
{
|
||||
"Volumes": [
|
||||
{
|
||||
"Name": "volume_name",
|
||||
"Mountpoint": "/path/to/directory/on/host"
|
||||
}
|
||||
],
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
- **v2**:
|
||||
|
||||
```json
|
||||
{
|
||||
"Volumes": [
|
||||
{
|
||||
"Name": "volume_name",
|
||||
"Mountpoint": "/path/under/PropagatedMount"
|
||||
}
|
||||
],
|
||||
"Err": ""
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Respond with a string error if an error occurred. `Mountpoint` is optional.
|
||||
|
||||
|
@ -257,8 +340,9 @@ Respond with a string error if an error occurred. `Mountpoint` is optional.
|
|||
```
|
||||
|
||||
Get the list of capabilities the driver supports.
|
||||
The driver is not required to implement this endpoint, however in such cases
|
||||
the default values will be taken.
|
||||
|
||||
The driver is not required to implement `Capabilities`. If it is not
|
||||
implemented, the default values are used.
|
||||
|
||||
**Response**:
|
||||
```json
|
||||
|
@ -270,7 +354,7 @@ the default values will be taken.
|
|||
```
|
||||
|
||||
Supported scopes are `global` and `local`. Any other value in `Scope` will be
|
||||
ignored and assumed to be `local`. Scope allows cluster managers to handle the
|
||||
volume differently, for instance with a scope of `global`, the cluster manager
|
||||
knows it only needs to create the volume once instead of on every engine. More
|
||||
capabilities may be added in the future.
|
||||
ignored, and `local` is used. `Scope` allows cluster managers to handle the
|
||||
volume in different ways. For instance, a scope of `global`, signals to the
|
||||
cluster manager that it only needs to create the volume once instead of on each
|
||||
Docker host. More capabilities may be added in the future.
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
title: "Dockerfile reference"
|
||||
description: "Dockerfiles use a simple DSL which allows you to automate the steps you would normally manually take to create an image."
|
||||
keywords: "builder, docker, Dockerfile, automation, image creation"
|
||||
redirect_from:
|
||||
- /reference/builder/
|
||||
---
|
||||
|
||||
<!-- This file is maintained within the docker/docker Github
|
||||
|
|
|
@ -27,6 +27,8 @@ Options:
|
|||
--sig-proxy Proxy all received signals to the process (default true)
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Use `docker attach` to attach to a running container using the container's ID
|
||||
or name, either to view its ongoing output or to control it interactively.
|
||||
You can attach to the same contained process multiple times simultaneously,
|
||||
|
@ -55,8 +57,7 @@ performance critical applications that generate a lot of output in the
|
|||
foreground over a slow client connection. Instead, users should use the
|
||||
`docker logs` command to get access to the logs.
|
||||
|
||||
|
||||
## Override the detach sequence
|
||||
### Override the detach sequence
|
||||
|
||||
If you want, you can configure an override the Docker key sequence for detach.
|
||||
This is useful if the Docker default sequence conflicts with key sequence you
|
||||
|
@ -80,52 +81,72 @@ These `a`, `ctrl-a`, `X`, or `ctrl-\\` values are all examples of valid key
|
|||
sequences. To configure a different configuration default key sequence for all
|
||||
containers, see [**Configuration file** section](cli.md#configuration-files).
|
||||
|
||||
#### Examples
|
||||
## Examples
|
||||
|
||||
$ docker run -d --name topdemo ubuntu /usr/bin/top -b
|
||||
$ docker attach topdemo
|
||||
top - 02:05:52 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
|
||||
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||||
Cpu(s): 0.1%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
|
||||
Mem: 373572k total, 355560k used, 18012k free, 27872k buffers
|
||||
Swap: 786428k total, 0k used, 786428k free, 221740k cached
|
||||
### Attach to and detach from a running container
|
||||
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top
|
||||
```bash
|
||||
$ docker run -d --name topdemo ubuntu /usr/bin/top -b
|
||||
|
||||
top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
|
||||
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||||
Cpu(s): 0.0%us, 0.2%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
|
||||
Mem: 373572k total, 355244k used, 18328k free, 27872k buffers
|
||||
Swap: 786428k total, 0k used, 786428k free, 221776k cached
|
||||
$ docker attach topdemo
|
||||
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
|
||||
top - 02:05:52 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
|
||||
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||||
Cpu(s): 0.1%us, 0.2%sy, 0.0%ni, 99.7%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
|
||||
Mem: 373572k total, 355560k used, 18012k free, 27872k buffers
|
||||
Swap: 786428k total, 0k used, 786428k free, 221740k cached
|
||||
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 17200 1116 912 R 0 0.3 0:00.03 top
|
||||
|
||||
top - 02:05:55 up 3:05, 0 users, load average: 0.01, 0.02, 0.05
|
||||
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||||
Cpu(s): 0.0%us, 0.2%sy, 0.0%ni, 99.8%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
|
||||
Mem: 373572k total, 355244k used, 18328k free, 27872k buffers
|
||||
Swap: 786428k total, 0k used, 786428k free, 221776k cached
|
||||
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
|
||||
|
||||
|
||||
top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05
|
||||
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||||
Cpu(s): 0.2%us, 0.3%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
|
||||
Mem: 373572k total, 355780k used, 17792k free, 27880k buffers
|
||||
Swap: 786428k total, 0k used, 786428k free, 221776k cached
|
||||
top - 02:05:58 up 3:06, 0 users, load average: 0.01, 0.02, 0.05
|
||||
Tasks: 1 total, 1 running, 0 sleeping, 0 stopped, 0 zombie
|
||||
Cpu(s): 0.2%us, 0.3%sy, 0.0%ni, 99.5%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
|
||||
Mem: 373572k total, 355780k used, 17792k free, 27880k buffers
|
||||
Swap: 786428k total, 0k used, 786428k free, 221776k cached
|
||||
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
|
||||
^C$
|
||||
$ echo $?
|
||||
0
|
||||
$ docker ps -a | grep topdemo
|
||||
7998ac8581f9 ubuntu:14.04 "/usr/bin/top -b" 38 seconds ago Exited (0) 21 seconds ago topdemo
|
||||
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
|
||||
1 root 20 0 17208 1144 932 R 0 0.3 0:00.03 top
|
||||
^C$
|
||||
|
||||
$ echo $?
|
||||
0
|
||||
$ docker ps -a | grep topdemo
|
||||
|
||||
7998ac8581f9 ubuntu:14.04 "/usr/bin/top -b" 38 seconds ago Exited (0) 21 seconds ago topdemo
|
||||
```
|
||||
|
||||
### Get the exit code of the container's command
|
||||
|
||||
And in this second example, you can see the exit code returned by the `bash`
|
||||
process is returned by the `docker attach` command to its caller too:
|
||||
|
||||
```bash
|
||||
$ docker run --name test -d -it debian
|
||||
|
||||
275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab
|
||||
|
||||
$ docker attach test
|
||||
|
||||
root@f38c87f2a42d:/# exit 13
|
||||
|
||||
exit
|
||||
|
||||
$ echo $?
|
||||
|
||||
13
|
||||
|
||||
$ docker ps -a | grep test
|
||||
|
||||
275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test
|
||||
```
|
||||
|
|
|
@ -58,6 +58,8 @@ Options:
|
|||
--ulimit value Ulimit options (default [])
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Builds Docker images from a Dockerfile and a "context". A build's context is
|
||||
the files located in the specified `PATH` or `URL`. The build process can refer
|
||||
to any of the files in the context. For example, your build can use an
|
||||
|
@ -285,7 +287,7 @@ $ docker build - < context.tar.gz
|
|||
This will build an image for a compressed context read from `STDIN`. Supported
|
||||
formats are: bzip2, gzip and xz.
|
||||
|
||||
### Usage of .dockerignore
|
||||
### Use a .dockerignore file
|
||||
|
||||
```bash
|
||||
$ docker build .
|
||||
|
@ -315,7 +317,7 @@ directory from the context. Its effect can be seen in the changed size of the
|
|||
uploaded context. The builder reference contains detailed information on
|
||||
[creating a .dockerignore file](../builder.md#dockerignore-file)
|
||||
|
||||
### Tag image (-t)
|
||||
### Tag an image (-t)
|
||||
|
||||
```bash
|
||||
$ docker build -t vieux/apache:2.0 .
|
||||
|
@ -334,7 +336,7 @@ For example, to tag an image both as `whenry/fedora-jboss:latest` and
|
|||
```bash
|
||||
$ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .
|
||||
```
|
||||
### Specify Dockerfile (-f)
|
||||
### Specify a Dockerfile (-f)
|
||||
|
||||
```bash
|
||||
$ docker build -f Dockerfile.debug .
|
||||
|
@ -373,7 +375,7 @@ the command line.
|
|||
> repeatable builds on remote Docker hosts. This is also the reason why
|
||||
> `ADD ../file` will not work.
|
||||
|
||||
### Optional parent cgroup (--cgroup-parent)
|
||||
### Use a custom parent cgroup (--cgroup-parent)
|
||||
|
||||
When `docker build` is run with the `--cgroup-parent` option the containers
|
||||
used in the build will be run with the [corresponding `docker run`
|
||||
|
|
|
@ -13,7 +13,7 @@ keywords: "Docker, Docker documentation, CLI, command line"
|
|||
will be rejected.
|
||||
-->
|
||||
|
||||
# Use the Docker command line
|
||||
# docker
|
||||
|
||||
To list available commands, either run `docker` with no parameters
|
||||
or execute `docker help`:
|
||||
|
@ -43,6 +43,8 @@ Commands:
|
|||
# […]
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
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
|
||||
|
@ -51,7 +53,7 @@ each `docker` command with `sudo`. To avoid having to use `sudo` with the
|
|||
For more information about installing Docker or `sudo` configuration, refer to
|
||||
the [installation](https://docs.docker.com/engine/installation/) instructions for your operating system.
|
||||
|
||||
## Environment variables
|
||||
### Environment variables
|
||||
|
||||
For easy reference, the following list of environment variables are supported
|
||||
by the `docker` command line:
|
||||
|
@ -69,7 +71,7 @@ by the `docker` command line:
|
|||
Equates to `--disable-content-trust=false` for build, create, pull, push, run.
|
||||
* `DOCKER_CONTENT_TRUST_SERVER` The URL of the Notary server to use. This defaults
|
||||
to the same URL as the registry.
|
||||
* `DOCKER_HIDE_LEGACY_COMMANDS` When set, Docker hides "legacy" top-level commands (such as `docker rm`, and
|
||||
* `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, at which point this environment-variable is removed.
|
||||
* `DOCKER_TMPDIR` Location for temporary Docker files.
|
||||
|
@ -85,7 +87,7 @@ These Go environment variables are case-insensitive. See the
|
|||
[Go specification](http://golang.org/pkg/net/http/) for details on these
|
||||
variables.
|
||||
|
||||
## Configuration files
|
||||
### Configuration files
|
||||
|
||||
By default, the Docker command line stores its configuration files in a
|
||||
directory called `.docker` within your `$HOME` directory. However, you can
|
||||
|
@ -165,18 +167,25 @@ attach`, `docker exec`, `docker run` or `docker start` command.
|
|||
|
||||
Following is a sample `config.json` file:
|
||||
|
||||
{% raw %}
|
||||
{
|
||||
"HttpHeaders": {
|
||||
"MyHeader": "MyValue"
|
||||
},
|
||||
"psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Command}}\\t{{.Labels}}",
|
||||
"imagesFormat": "table {{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}",
|
||||
"statsFormat": "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}",
|
||||
"serviceInspectFormat": "pretty",
|
||||
"detachKeys": "ctrl-e,e"
|
||||
}
|
||||
{% endraw %}
|
||||
```json
|
||||
{% raw %}
|
||||
{
|
||||
"HttpHeaders": {
|
||||
"MyHeader": "MyValue"
|
||||
},
|
||||
"psFormat": "table {{.ID}}\\t{{.Image}}\\t{{.Command}}\\t{{.Labels}}",
|
||||
"imagesFormat": "table {{.ID}}\\t{{.Repository}}\\t{{.Tag}}\\t{{.CreatedAt}}",
|
||||
"statsFormat": "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}",
|
||||
"serviceInspectFormat": "pretty",
|
||||
"detachKeys": "ctrl-e,e",
|
||||
"credsStore": "secretservice",
|
||||
"credHelpers": {
|
||||
"awesomereg.example.org": "hip-star",
|
||||
"unicorn.example.com": "vcbait"
|
||||
}
|
||||
}
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Notary
|
||||
|
||||
|
@ -187,7 +196,9 @@ Certificate Authority, you need to place the certificate at
|
|||
Alternatively you can trust the certificate globally by adding it to your system's
|
||||
list of root Certificate Authorities.
|
||||
|
||||
## Help
|
||||
## Examples
|
||||
|
||||
### Display help text
|
||||
|
||||
To list the help on any command just execute the command, followed by the
|
||||
`--help` option.
|
||||
|
@ -203,13 +214,13 @@ To list the help on any command just execute the command, followed by the
|
|||
-a, --attach value Attach to STDIN, STDOUT or STDERR (default [])
|
||||
...
|
||||
|
||||
## Option types
|
||||
### 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
|
||||
#### Boolean
|
||||
|
||||
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
|
||||
|
@ -222,27 +233,33 @@ 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 .
|
||||
```bash
|
||||
$ docker build --rm=false .
|
||||
```
|
||||
|
||||
### Multi
|
||||
#### Multi
|
||||
|
||||
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
|
||||
```bash
|
||||
$ 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
|
||||
```bash
|
||||
$ docker run -v /host:/container example/mysql
|
||||
```
|
||||
|
||||
> **Note:**
|
||||
> Do not use the `-t` and `-a stderr` options together due to
|
||||
> **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
|
||||
#### Strings and Integers
|
||||
|
||||
Options like `--name=""` expect a string, and they
|
||||
can only be specified once. Options like `-c=0`
|
||||
|
|
|
@ -28,6 +28,8 @@ Options:
|
|||
-p, --pause Pause container during commit (default true)
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
It can be useful to commit a container's file changes or settings into a new
|
||||
image. This allows you debug a container by running an interactive shell, or to
|
||||
export a working dataset to another server. Generally, it is better to use
|
||||
|
@ -46,48 +48,72 @@ The `--change` option will apply `Dockerfile` instructions to the image that is
|
|||
created. Supported `Dockerfile` instructions:
|
||||
`CMD`|`ENTRYPOINT`|`ENV`|`EXPOSE`|`LABEL`|`ONBUILD`|`USER`|`VOLUME`|`WORKDIR`
|
||||
|
||||
## Commit a container
|
||||
## Examples
|
||||
|
||||
$ docker ps
|
||||
ID IMAGE COMMAND CREATED STATUS PORTS
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
|
||||
$ docker commit c3f279d17e0a svendowideit/testimage:version3
|
||||
f5283438590d
|
||||
$ docker images
|
||||
REPOSITORY TAG ID CREATED SIZE
|
||||
svendowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB
|
||||
### Commit a container
|
||||
|
||||
## Commit a container with new configurations
|
||||
```bash
|
||||
$ docker ps
|
||||
|
||||
{% raw %}
|
||||
$ docker ps
|
||||
ID IMAGE COMMAND CREATED STATUS PORTS
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
|
||||
$ docker inspect -f "{{ .Config.Env }}" c3f279d17e0a
|
||||
[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin]
|
||||
$ docker commit --change "ENV DEBUG true" c3f279d17e0a svendowideit/testimage:version3
|
||||
f5283438590d
|
||||
$ docker inspect -f "{{ .Config.Env }}" f5283438590d
|
||||
[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true]
|
||||
{% endraw %}
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
|
||||
## Commit a container with new `CMD` and `EXPOSE` instructions
|
||||
$ docker commit c3f279d17e0a svendowideit/testimage:version3
|
||||
|
||||
$ docker ps
|
||||
ID IMAGE COMMAND CREATED STATUS PORTS
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
|
||||
f5283438590d
|
||||
|
||||
$ docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a svendowideit/testimage:version4
|
||||
f5283438590d
|
||||
$ docker images
|
||||
|
||||
$ docker run -d svendowideit/testimage:version4
|
||||
89373736e2e7f00bc149bd783073ac43d0507da250e999f3f1036e0db60817c0
|
||||
REPOSITORY TAG ID CREATED SIZE
|
||||
svendowideit/testimage version3 f5283438590d 16 seconds ago 335.7 MB
|
||||
```
|
||||
|
||||
$ docker ps
|
||||
ID IMAGE COMMAND CREATED STATUS PORTS
|
||||
89373736e2e7 testimage:version4 "apachectl -DFOREGROU" 3 seconds ago Up 2 seconds 80/tcp
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours
|
||||
### Commit a container with new configurations
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker ps
|
||||
|
||||
ICONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
|
||||
$ docker inspect -f "{{ .Config.Env }}" c3f279d17e0a
|
||||
|
||||
[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin]
|
||||
|
||||
$ docker commit --change "ENV DEBUG true" c3f279d17e0a svendowideit/testimage:version3
|
||||
|
||||
f5283438590d
|
||||
|
||||
$ docker inspect -f "{{ .Config.Env }}" f5283438590d
|
||||
|
||||
[HOME=/ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin DEBUG=true]
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Commit a container with new `CMD` and `EXPOSE` instructions
|
||||
|
||||
```bash
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
|
||||
$ docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a svendowideit/testimage:version4
|
||||
|
||||
f5283438590d
|
||||
|
||||
$ docker run -d svendowideit/testimage:version4
|
||||
|
||||
89373736e2e7f00bc149bd783073ac43d0507da250e999f3f1036e0db60817c0
|
||||
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
89373736e2e7 testimage:version4 "apachectl -DFOREGROU" 3 seconds ago Up 2 seconds 80/tcp distracted_fermat
|
||||
c3f279d17e0a ubuntu:12.04 /bin/bash 7 days ago Up 25 hours desperate_dubinsky
|
||||
197387f1b436 ubuntu:12.04 /bin/bash 7 days ago Up 25 hours focused_hamilton
|
||||
```
|
||||
|
|
|
@ -25,8 +25,14 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Removes all stopped containers.
|
||||
|
||||
## Examples
|
||||
|
||||
### Prune containers
|
||||
|
||||
```bash
|
||||
$ docker container prune
|
||||
WARNING! This will remove all stopped containers.
|
||||
|
@ -38,7 +44,76 @@ f98f9c2aa1eaf727e4ec9c0283bc7d4aa4762fbdba7f26191f26c97f64090360
|
|||
Total reclaimed space: 212 B
|
||||
```
|
||||
|
||||
## Related information
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
||||
The currently supported filters are:
|
||||
|
||||
* until (`<timestamp>`) - only remove containers created before given timestamp
|
||||
|
||||
The `until` filter can be Unix timestamps, date formatted
|
||||
timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed
|
||||
relative to the daemon machine’s time. Supported formats for date
|
||||
formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`,
|
||||
`2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local
|
||||
timezone on the daemon will be used if you do not provide either a `Z` or a
|
||||
`+-00:00` timezone offset at the end of the timestamp. When providing Unix
|
||||
timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
|
||||
that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
|
||||
seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
|
||||
fraction of a second no more than nine digits long.
|
||||
|
||||
The following removes containers created more than 5 minutes ago:
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED AT STATUS
|
||||
61b9efa71024 busybox "sh" 2017-01-04 13:23:33 -0800 PST Exited (0) 41 seconds ago
|
||||
53a9bc23a516 busybox "sh" 2017-01-04 13:11:59 -0800 PST Exited (0) 12 minutes ago
|
||||
|
||||
$ docker container prune --force --filter "until=5m"
|
||||
|
||||
Deleted Containers:
|
||||
53a9bc23a5168b6caa2bfbefddf1b30f93c7ad57f3dec271fd32707497cb9369
|
||||
|
||||
Total reclaimed space: 25 B
|
||||
|
||||
$ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED AT STATUS
|
||||
61b9efa71024 busybox "sh" 2017-01-04 13:23:33 -0800 PST Exited (0) 44 seconds ago
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
The following removes containers created before `2017-01-04T13:10:00`:
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED AT STATUS
|
||||
53a9bc23a516 busybox "sh" 2017-01-04 13:11:59 -0800 PST Exited (0) 7 minutes ago
|
||||
4a75091a6d61 busybox "sh" 2017-01-04 13:09:53 -0800 PST Exited (0) 9 minutes ago
|
||||
|
||||
$ docker container prune --force --filter "until=2017-01-04T13:10:00"
|
||||
|
||||
Deleted Containers:
|
||||
4a75091a6d618526fcd8b33ccd6e5928ca2a64415466f768a6180004b0c72c6c
|
||||
|
||||
Total reclaimed space: 27 B
|
||||
|
||||
$ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED AT STATUS
|
||||
53a9bc23a516 busybox "sh" 2017-01-04 13:11:59 -0800 PST Exited (0) 9 minutes ago
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Related commands
|
||||
|
||||
* [system df](system_df.md)
|
||||
* [volume prune](volume_prune.md)
|
||||
|
|
|
@ -31,6 +31,8 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `docker cp` utility copies the contents of `SRC_PATH` to the `DEST_PATH`.
|
||||
You can copy from the container's file system to the local machine or the
|
||||
reverse, from the local filesystem to the container. If `-` is specified for
|
||||
|
@ -75,9 +77,9 @@ argument of `DEST_PATH`, the behavior is as follows:
|
|||
- `DEST_PATH` exists and is a file
|
||||
- Error condition: cannot copy a directory to a file
|
||||
- `DEST_PATH` exists and is a directory
|
||||
- `SRC_PATH` does not end with `/.`
|
||||
- `SRC_PATH` does not end with `/.` (that is: _slash_ followed by _dot_)
|
||||
- the source directory is copied into this directory
|
||||
- `SRC_PATH` does end with `/.`
|
||||
- `SRC_PATH` does end with `/.` (that is: _slash_ followed by _dot_)
|
||||
- the *content* of the source directory is copied into this
|
||||
directory
|
||||
|
||||
|
@ -96,15 +98,16 @@ you must be explicit with a relative or absolute path, for example:
|
|||
It is not possible to copy certain system files such as resources under
|
||||
`/proc`, `/sys`, `/dev`, [tmpfs](run.md#mount-tmpfs-tmpfs), and mounts created by
|
||||
the user in the container. However, you can still copy such files by manually
|
||||
running `tar` in `docker exec`. For example (consider `SRC_PATH` and `DEST_PATH`
|
||||
are directories):
|
||||
running `tar` in `docker exec`. Both of the following examples do the same thing
|
||||
in different ways (consider `SRC_PATH` and `DEST_PATH` are directories):
|
||||
|
||||
$ docker exec foo tar Ccf $(dirname SRC_PATH) - $(basename SRC_PATH) | tar Cxf DEST_PATH -
|
||||
|
||||
or
|
||||
|
||||
$ tar Ccf $(dirname SRC_PATH) - $(basename SRC_PATH) | docker exec -i foo tar Cxf DEST_PATH -
|
||||
```bash
|
||||
$ docker exec foo tar Ccf $(dirname SRC_PATH) - $(basename SRC_PATH) | tar Cxf DEST_PATH -
|
||||
```
|
||||
|
||||
```bash
|
||||
$ tar Ccf $(dirname SRC_PATH) - $(basename SRC_PATH) | docker exec -i foo tar Cxf DEST_PATH -
|
||||
```
|
||||
|
||||
Using `-` as the `SRC_PATH` streams the contents of `STDIN` as a tar archive.
|
||||
The command extracts the content of the tar to the `DEST_PATH` in container's
|
||||
|
|
|
@ -132,6 +132,7 @@ Options:
|
|||
--volumes-from value Mount volumes from the specified container(s) (default [])
|
||||
-w, --workdir string Working directory inside the container
|
||||
```
|
||||
## Description
|
||||
|
||||
The `docker create` command creates a writeable container layer over the
|
||||
specified image and prepares it for running the specified command. The
|
||||
|
@ -147,42 +148,64 @@ Please see the [run command](run.md) section and the [Docker run reference](../r
|
|||
|
||||
## Examples
|
||||
|
||||
$ docker create -t -i fedora bash
|
||||
6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752
|
||||
$ docker start -a -i 6d8af538ec5
|
||||
bash-4.2#
|
||||
### Create and start a container
|
||||
|
||||
```bash
|
||||
$ docker create -t -i fedora bash
|
||||
|
||||
6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752
|
||||
|
||||
$ docker start -a -i 6d8af538ec5
|
||||
|
||||
bash-4.2#
|
||||
```
|
||||
|
||||
### Initialize volumes
|
||||
|
||||
As of v1.4.0 container volumes are initialized during the `docker create` phase
|
||||
(i.e., `docker run` too). For example, this allows you to `create` the `data`
|
||||
volume container, and then use it from another container:
|
||||
|
||||
$ docker create -v /data --name data ubuntu
|
||||
240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57
|
||||
$ docker run --rm --volumes-from data ubuntu ls -la /data
|
||||
total 8
|
||||
drwxr-xr-x 2 root root 4096 Dec 5 04:10 .
|
||||
drwxr-xr-x 48 root root 4096 Dec 5 04:11 ..
|
||||
```bash
|
||||
$ docker create -v /data --name data ubuntu
|
||||
|
||||
240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57
|
||||
|
||||
$ docker run --rm --volumes-from data ubuntu ls -la /data
|
||||
|
||||
total 8
|
||||
drwxr-xr-x 2 root root 4096 Dec 5 04:10 .
|
||||
drwxr-xr-x 48 root root 4096 Dec 5 04:11 ..
|
||||
```
|
||||
|
||||
Similarly, `create` a host directory bind mounted volume container, which can
|
||||
then be used from the subsequent container:
|
||||
|
||||
$ docker create -v /home/docker:/docker --name docker ubuntu
|
||||
9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03
|
||||
$ docker run --rm --volumes-from docker ubuntu ls -la /docker
|
||||
total 20
|
||||
drwxr-sr-x 5 1000 staff 180 Dec 5 04:00 .
|
||||
drwxr-xr-x 48 root root 4096 Dec 5 04:13 ..
|
||||
-rw-rw-r-- 1 1000 staff 3833 Dec 5 04:01 .ash_history
|
||||
-rw-r--r-- 1 1000 staff 446 Nov 28 11:51 .ashrc
|
||||
-rw-r--r-- 1 1000 staff 25 Dec 5 04:00 .gitconfig
|
||||
drwxr-sr-x 3 1000 staff 60 Dec 1 03:28 .local
|
||||
-rw-r--r-- 1 1000 staff 920 Nov 28 11:51 .profile
|
||||
drwx--S--- 2 1000 staff 460 Dec 5 00:51 .ssh
|
||||
drwxr-xr-x 32 1000 staff 1140 Dec 5 04:01 docker
|
||||
```bash
|
||||
$ docker create -v /home/docker:/docker --name docker ubuntu
|
||||
|
||||
9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03
|
||||
|
||||
$ docker run --rm --volumes-from docker ubuntu ls -la /docker
|
||||
|
||||
total 20
|
||||
drwxr-sr-x 5 1000 staff 180 Dec 5 04:00 .
|
||||
drwxr-xr-x 48 root root 4096 Dec 5 04:13 ..
|
||||
-rw-rw-r-- 1 1000 staff 3833 Dec 5 04:01 .ash_history
|
||||
-rw-r--r-- 1 1000 staff 446 Nov 28 11:51 .ashrc
|
||||
-rw-r--r-- 1 1000 staff 25 Dec 5 04:00 .gitconfig
|
||||
drwxr-sr-x 3 1000 staff 60 Dec 1 03:28 .local
|
||||
-rw-r--r-- 1 1000 staff 920 Nov 28 11:51 .profile
|
||||
drwx--S--- 2 1000 staff 460 Dec 5 00:51 .ssh
|
||||
drwxr-xr-x 32 1000 staff 1140 Dec 5 04:01 docker
|
||||
```
|
||||
|
||||
|
||||
Set storage driver options per container.
|
||||
|
||||
$ docker create -it --storage-opt size=120G fedora /bin/bash
|
||||
```bash
|
||||
$ docker create -it --storage-opt size=120G fedora /bin/bash
|
||||
```
|
||||
|
||||
This (size) will allow to set the container rootfs size to 120G at creation time.
|
||||
This option is only available for the `devicemapper`, `btrfs`, `overlay2`,
|
||||
|
|
|
@ -14,7 +14,9 @@ advisory: "experimental"
|
|||
will be rejected.
|
||||
-->
|
||||
|
||||
# deploy (alias for stack deploy) (experimental)
|
||||
# deploy (experimental)
|
||||
|
||||
An alias for `stack deploy`.
|
||||
|
||||
```markdown
|
||||
Usage: docker deploy [OPTIONS] STACK
|
||||
|
@ -31,15 +33,20 @@ Options:
|
|||
--with-registry-auth Send registry authentication details to Swarm agents
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Create and update a stack from a `compose` or a `dab` file on the swarm. This command
|
||||
has to be run targeting a manager node.
|
||||
|
||||
## Compose file
|
||||
## Examples
|
||||
|
||||
### Compose file
|
||||
|
||||
The `deploy` command supports compose file version `3.0` and above.
|
||||
|
||||
```bash
|
||||
$ docker stack deploy --compose-file docker-compose.yml vossibility
|
||||
|
||||
Ignoring unsupported options: links
|
||||
|
||||
Creating network vossibility_vossibility
|
||||
|
@ -54,8 +61,9 @@ Creating service vossibility_lookupd
|
|||
|
||||
You can verify that the services were correctly created
|
||||
|
||||
```
|
||||
```bash
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
29bv0vnlm903 vossibility_lookupd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
|
||||
4awt47624qwh vossibility_nsqd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
|
||||
|
@ -65,10 +73,11 @@ ID NAME MODE REPLICAS IMAGE
|
|||
axqh55ipl40h vossibility_vossibility-collector replicated 1/1 icecrime/vossibility-collector@sha256:f03f2977203ba6253988c18d04061c5ec7aab46bca9dfd89a9a1fa4500989fba
|
||||
```
|
||||
|
||||
## DAB file
|
||||
### DAB file
|
||||
|
||||
```bash
|
||||
$ docker stack deploy --bundle-file vossibility-stack.dab vossibility
|
||||
|
||||
Loading bundle from vossibility-stack.dab
|
||||
Creating service vossibility_elasticsearch
|
||||
Creating service vossibility_kibana
|
||||
|
@ -82,6 +91,7 @@ You can verify that the services were correctly created:
|
|||
|
||||
```bash
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
29bv0vnlm903 vossibility_lookupd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
|
||||
4awt47624qwh vossibility_nsqd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
|
||||
|
@ -91,7 +101,7 @@ ID NAME MODE REPLICAS IMAGE
|
|||
axqh55ipl40h vossibility_vossibility-collector replicated 1/1 icecrime/vossibility-collector@sha256:f03f2977203ba6253988c18d04061c5ec7aab46bca9dfd89a9a1fa4500989fba
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [stack config](stack_config.md)
|
||||
* [stack deploy](stack_deploy.md)
|
||||
|
|
|
@ -18,31 +18,50 @@ keywords: "list, changed, files, container"
|
|||
```markdown
|
||||
Usage: docker diff CONTAINER
|
||||
|
||||
Inspect changes on a container's filesystem
|
||||
Inspect changes to files or directories on a container's filesystem
|
||||
|
||||
Options:
|
||||
--help Print usage
|
||||
```
|
||||
|
||||
List the changed files and directories in a container᾿s filesystem.
|
||||
There are 3 events that are listed in the `diff`:
|
||||
## Description
|
||||
|
||||
1. `A` - Add
|
||||
2. `D` - Delete
|
||||
3. `C` - Change
|
||||
List the changed files and directories in a container᾿s filesystem since the
|
||||
container was created. Three different types of change are tracked:
|
||||
|
||||
For example:
|
||||
| Symbol | Description |
|
||||
|--------|---------------------------------|
|
||||
| `A` | A file or directory was added |
|
||||
| `D` | A file or directory was deleted |
|
||||
| `C` | A file or directory was changed |
|
||||
|
||||
$ docker diff 7bb0e258aefe
|
||||
You can use the full or shortened container ID or the container name set using
|
||||
`docker run --name` option.
|
||||
|
||||
C /dev
|
||||
A /dev/kmsg
|
||||
C /etc
|
||||
A /etc/mtab
|
||||
A /go
|
||||
A /go/src
|
||||
A /go/src/github.com
|
||||
A /go/src/github.com/docker
|
||||
A /go/src/github.com/docker/docker
|
||||
A /go/src/github.com/docker/docker/.git
|
||||
....
|
||||
## Examples
|
||||
|
||||
Inspect the changes to an `nginx` container:
|
||||
|
||||
```bash
|
||||
$ docker diff 1fdfd1f54c1b
|
||||
|
||||
C /dev
|
||||
C /dev/console
|
||||
C /dev/core
|
||||
C /dev/stdout
|
||||
C /dev/fd
|
||||
C /dev/ptmx
|
||||
C /dev/stderr
|
||||
C /dev/stdin
|
||||
C /run
|
||||
A /run/nginx.pid
|
||||
C /var/lib/nginx/tmp
|
||||
A /var/lib/nginx/tmp/client_body
|
||||
A /var/lib/nginx/tmp/fastcgi
|
||||
A /var/lib/nginx/tmp/proxy
|
||||
A /var/lib/nginx/tmp/scgi
|
||||
A /var/lib/nginx/tmp/uwsgi
|
||||
C /var/log/nginx
|
||||
A /var/log/nginx/access.log
|
||||
A /var/log/nginx/error.log
|
||||
```
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 35 KiB |
|
@ -92,13 +92,17 @@ Options:
|
|||
|
||||
Options with [] may be specified multiple times.
|
||||
|
||||
dockerd is the persistent process that manages containers. Docker
|
||||
## Description
|
||||
|
||||
`dockerd` is the persistent process that manages containers. Docker
|
||||
uses different binaries for the daemon and client. To run the daemon you
|
||||
type `dockerd`.
|
||||
|
||||
To run the daemon with debug output, use `dockerd -D`.
|
||||
|
||||
## Daemon socket option
|
||||
## Examples
|
||||
|
||||
### Daemon socket option
|
||||
|
||||
The Docker daemon can listen for [Docker Engine API](../api/)
|
||||
requests via three different types of Socket: `unix`, `tcp`, and `fd`.
|
||||
|
@ -117,8 +121,7 @@ interface using its IP address: `-H tcp://192.168.59.103:2375`. It is
|
|||
conventional to use port `2375` for un-encrypted, and port `2376` for encrypted
|
||||
communication with the daemon.
|
||||
|
||||
> **Note:**
|
||||
> If you're using an HTTPS encrypted socket, keep in mind that only
|
||||
> **Note**: If you're using an HTTPS encrypted socket, keep in mind that only
|
||||
> TLS1.0 and greater are supported. Protocols SSLv3 and under are not
|
||||
> supported anymore for security reasons.
|
||||
|
||||
|
@ -135,18 +138,21 @@ time using multiple `-H` options:
|
|||
|
||||
```bash
|
||||
# listen using the default unix socket, and on 2 specific IP addresses on this host.
|
||||
|
||||
$ sudo dockerd -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2
|
||||
```
|
||||
|
||||
The Docker client will honor the `DOCKER_HOST` environment variable to set the
|
||||
`-H` flag for the client.
|
||||
`-H` flag for the client. Use **one** of the following commands:
|
||||
|
||||
```bash
|
||||
$ docker -H tcp://0.0.0.0:2375 ps
|
||||
# or
|
||||
```
|
||||
|
||||
```bash
|
||||
$ export DOCKER_HOST="tcp://0.0.0.0:2375"
|
||||
|
||||
$ docker ps
|
||||
# both are equal
|
||||
```
|
||||
|
||||
Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than
|
||||
|
@ -164,7 +170,7 @@ The Docker client will honor the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY`
|
|||
environment variables (or the lowercase versions thereof). `HTTPS_PROXY` takes
|
||||
precedence over `HTTP_PROXY`.
|
||||
|
||||
### Bind Docker to another host/port or a Unix socket
|
||||
#### Bind Docker to another host/port or a Unix socket
|
||||
|
||||
> **Warning**:
|
||||
> Changing the default `docker` daemon binding to a
|
||||
|
@ -230,14 +236,14 @@ $ docker pull ubuntu
|
|||
$ docker -H tcp://127.0.0.1:2375 pull ubuntu
|
||||
```
|
||||
|
||||
### Daemon storage-driver option
|
||||
### Daemon storage-driver
|
||||
|
||||
The Docker daemon has support for several different image layer storage
|
||||
drivers: `aufs`, `devicemapper`, `btrfs`, `zfs`, `overlay` and `overlay2`.
|
||||
|
||||
The `aufs` driver is the oldest, but is based on a Linux kernel patch-set that
|
||||
is unlikely to be merged into the main kernel. These are also known to cause
|
||||
some serious kernel crashes. However, `aufs` allows containers to share
|
||||
some serious kernel crashes. However `aufs` allows containers to share
|
||||
executable and shared library memory, so is a useful choice when running
|
||||
thousands of containers with the same program or libraries.
|
||||
|
||||
|
@ -267,22 +273,20 @@ the same file can share a single page cache entry (or entries), it makes
|
|||
`overlay` as efficient with memory as `aufs` driver. Call
|
||||
`dockerd -s overlay` to use it.
|
||||
|
||||
> **Note:**
|
||||
> As promising as `overlay` is, the feature is still quite young and should not
|
||||
> be used in production. Most notably, using `overlay` can cause excessive
|
||||
> inode consumption (especially as the number of images grows), as well as
|
||||
> being incompatible with the use of RPMs.
|
||||
> **Note**: As promising as `overlay` is, the feature is still quite young and
|
||||
> should not be used in production. Most notably, using `overlay` can cause
|
||||
> excessive inode consumption (especially as the number of images grows), as
|
||||
> well as > being incompatible with the use of RPMs.
|
||||
|
||||
The `overlay2` uses the same fast union filesystem but takes advantage of
|
||||
[additional features](https://lkml.org/lkml/2015/2/11/106) added in Linux
|
||||
kernel 4.0 to avoid excessive inode consumption. Call `dockerd -s overlay2`
|
||||
to use it.
|
||||
|
||||
> **Note:**
|
||||
> Both `overlay` and `overlay2` are currently unsupported on `btrfs` or any
|
||||
> Copy on Write filesystem and should only be used over `ext4` partitions.
|
||||
> **Note**: Both `overlay` and `overlay2` are currently unsupported on `btrfs`
|
||||
> or any Copy on Write filesystem and should only be used over `ext4` partitions.
|
||||
|
||||
### Storage driver options
|
||||
### Options per storage driver
|
||||
|
||||
Particular storage-driver can be configured with options specified with
|
||||
`--storage-opt` flags. Options for `devicemapper` are prefixed with `dm`,
|
||||
|
@ -290,380 +294,376 @@ options for `zfs` start with `zfs` and options for `btrfs` start with `btrfs`.
|
|||
|
||||
#### Devicemapper options
|
||||
|
||||
* `dm.thinpooldev`
|
||||
##### `dm.thinpooldev`
|
||||
|
||||
Specifies a custom block storage device to use for the thin pool.
|
||||
Specifies a custom block storage device to use for the thin pool.
|
||||
|
||||
If using a block device for device mapper storage, it is best to use `lvm`
|
||||
to create and manage the thin-pool volume. This volume is then handed to Docker
|
||||
to exclusively create snapshot volumes needed for images and containers.
|
||||
If using a block device for device mapper storage, it is best to use `lvm`
|
||||
to create and manage the thin-pool volume. This volume is then handed to Docker
|
||||
to exclusively create snapshot volumes needed for images and containers.
|
||||
|
||||
Managing the thin-pool outside of Engine makes for the most feature-rich
|
||||
method of having Docker utilize device mapper thin provisioning as the
|
||||
backing storage for Docker containers. The highlights of the lvm-based
|
||||
thin-pool management feature include: automatic or interactive thin-pool
|
||||
resize support, dynamically changing thin-pool features, automatic thinp
|
||||
metadata checking when lvm activates the thin-pool, etc.
|
||||
Managing the thin-pool outside of Engine makes for the most feature-rich
|
||||
method of having Docker utilize device mapper thin provisioning as the
|
||||
backing storage for Docker containers. The highlights of the lvm-based
|
||||
thin-pool management feature include: automatic or interactive thin-pool
|
||||
resize support, dynamically changing thin-pool features, automatic thinp
|
||||
metadata checking when lvm activates the thin-pool, etc.
|
||||
|
||||
As a fallback if no thin pool is provided, loopback files are
|
||||
created. Loopback is very slow, but can be used without any
|
||||
pre-configuration of storage. It is strongly recommended that you do
|
||||
not use loopback in production. Ensure your Engine daemon has a
|
||||
`--storage-opt dm.thinpooldev` argument provided.
|
||||
As a fallback if no thin pool is provided, loopback files are
|
||||
created. Loopback is very slow, but can be used without any
|
||||
pre-configuration of storage. It is strongly recommended that you do
|
||||
not use loopback in production. Ensure your Engine daemon has a
|
||||
`--storage-opt dm.thinpooldev` argument provided.
|
||||
|
||||
Example use:
|
||||
###### Example:
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.thinpooldev=/dev/mapper/thin-pool
|
||||
```
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.thinpooldev=/dev/mapper/thin-pool
|
||||
```
|
||||
|
||||
* `dm.basesize`
|
||||
##### `dm.basesize`
|
||||
|
||||
Specifies the size to use when creating the base device, which limits the
|
||||
size of images and containers. The default value is 10G. Note, thin devices
|
||||
are inherently "sparse", so a 10G device which is mostly empty doesn't use
|
||||
10 GB of space on the pool. However, the filesystem will use more space for
|
||||
the empty case the larger the device is.
|
||||
Specifies the size to use when creating the base device, which limits the
|
||||
size of images and containers. The default value is 10G. Note, thin devices
|
||||
are inherently "sparse", so a 10G device which is mostly empty doesn't use
|
||||
10 GB of space on the pool. However, the filesystem will use more space for
|
||||
the empty case the larger the device is.
|
||||
|
||||
The base device size can be increased at daemon restart which will allow
|
||||
all future images and containers (based on those new images) to be of the
|
||||
new base device size.
|
||||
The base device size can be increased at daemon restart which will allow
|
||||
all future images and containers (based on those new images) to be of the
|
||||
new base device size.
|
||||
|
||||
Example use:
|
||||
###### Examples
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.basesize=50G
|
||||
```
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.basesize=50G
|
||||
```
|
||||
|
||||
This will increase the base device size to 50G. The Docker daemon will throw an
|
||||
error if existing base device size is larger than 50G. A user can use
|
||||
this option to expand the base device size however shrinking is not permitted.
|
||||
This will increase the base device size to 50G. The Docker daemon will throw an
|
||||
error if existing base device size is larger than 50G. A user can use
|
||||
this option to expand the base device size however shrinking is not permitted.
|
||||
|
||||
This value affects the system-wide "base" empty filesystem
|
||||
that may already be initialized and inherited by pulled images. Typically,
|
||||
a change to this value requires additional steps to take effect:
|
||||
This value affects the system-wide "base" empty filesystem
|
||||
that may already be initialized and inherited by pulled images. Typically,
|
||||
a change to this value requires additional steps to take effect:
|
||||
|
||||
```bash
|
||||
$ sudo service docker stop
|
||||
$ sudo rm -rf /var/lib/docker
|
||||
$ sudo service docker start
|
||||
```
|
||||
```bash
|
||||
$ sudo service docker stop
|
||||
|
||||
Example use:
|
||||
$ sudo rm -rf /var/lib/docker
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.basesize=20G
|
||||
```
|
||||
$ sudo service docker start
|
||||
```
|
||||
|
||||
* `dm.loopdatasize`
|
||||
|
||||
> **Note**:
|
||||
> This option configures devicemapper loopback, which should not
|
||||
> be used in production.
|
||||
##### `dm.loopdatasize`
|
||||
|
||||
Specifies the size to use when creating the loopback file for the
|
||||
"data" device which is used for the thin pool. The default size is
|
||||
100G. The file is sparse, so it will not initially take up this
|
||||
much space.
|
||||
> **Note**: This option configures devicemapper loopback, which should not
|
||||
> be used in production.
|
||||
|
||||
Example use:
|
||||
Specifies the size to use when creating the loopback file for the
|
||||
"data" device which is used for the thin pool. The default size is
|
||||
100G. The file is sparse, so it will not initially take up this
|
||||
much space.
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.loopdatasize=200G
|
||||
```
|
||||
###### Example
|
||||
|
||||
* `dm.loopmetadatasize`
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.loopdatasize=200G
|
||||
```
|
||||
|
||||
> **Note**:
|
||||
> This option configures devicemapper loopback, which should not
|
||||
> be used in production.
|
||||
##### `dm.loopmetadatasize`
|
||||
|
||||
Specifies the size to use when creating the loopback file for the
|
||||
"metadata" device which is used for the thin pool. The default size
|
||||
is 2G. The file is sparse, so it will not initially take up
|
||||
this much space.
|
||||
> **Note**: This option configures devicemapper loopback, which should not
|
||||
> be used in production.
|
||||
|
||||
Example use:
|
||||
Specifies the size to use when creating the loopback file for the
|
||||
"metadata" device which is used for the thin pool. The default size
|
||||
is 2G. The file is sparse, so it will not initially take up
|
||||
this much space.
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.loopmetadatasize=4G
|
||||
```
|
||||
###### Example
|
||||
|
||||
* `dm.fs`
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.loopmetadatasize=4G
|
||||
```
|
||||
|
||||
Specifies the filesystem type to use for the base device. The supported
|
||||
options are "ext4" and "xfs". The default is "xfs"
|
||||
##### `dm.fs`
|
||||
|
||||
Example use:
|
||||
Specifies the filesystem type to use for the base device. The supported
|
||||
options are "ext4" and "xfs". The default is "xfs"
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.fs=ext4
|
||||
```
|
||||
###### Example
|
||||
|
||||
* `dm.mkfsarg`
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.fs=ext4
|
||||
```
|
||||
|
||||
Specifies extra mkfs arguments to be used when creating the base device.
|
||||
##### `dm.mkfsarg`
|
||||
|
||||
Example use:
|
||||
Specifies extra mkfs arguments to be used when creating the base device.
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt "dm.mkfsarg=-O ^has_journal"
|
||||
```
|
||||
###### Example
|
||||
|
||||
* `dm.mountopt`
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt "dm.mkfsarg=-O ^has_journal"
|
||||
```
|
||||
|
||||
Specifies extra mount options used when mounting the thin devices.
|
||||
##### `dm.mountopt`
|
||||
|
||||
Example use:
|
||||
Specifies extra mount options used when mounting the thin devices.
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.mountopt=nodiscard
|
||||
```
|
||||
###### Example
|
||||
|
||||
* `dm.datadev`
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.mountopt=nodiscard
|
||||
```
|
||||
|
||||
(Deprecated, use `dm.thinpooldev`)
|
||||
##### `dm.datadev`
|
||||
|
||||
Specifies a custom blockdevice to use for data for the thin pool.
|
||||
(Deprecated, use `dm.thinpooldev`)
|
||||
|
||||
If using a block device for device mapper storage, ideally both datadev and
|
||||
metadatadev should be specified to completely avoid using the loopback
|
||||
device.
|
||||
Specifies a custom blockdevice to use for data for the thin pool.
|
||||
|
||||
Example use:
|
||||
If using a block device for device mapper storage, ideally both `datadev` and
|
||||
`metadatadev` should be specified to completely avoid using the loopback
|
||||
device.
|
||||
|
||||
```bash
|
||||
$ sudo dockerd \
|
||||
--storage-opt dm.datadev=/dev/sdb1 \
|
||||
--storage-opt dm.metadatadev=/dev/sdc1
|
||||
```
|
||||
###### Example
|
||||
|
||||
* `dm.metadatadev`
|
||||
```bash
|
||||
$ sudo dockerd \
|
||||
--storage-opt dm.datadev=/dev/sdb1 \
|
||||
--storage-opt dm.metadatadev=/dev/sdc1
|
||||
```
|
||||
|
||||
(Deprecated, use `dm.thinpooldev`)
|
||||
##### `dm.metadatadev`
|
||||
|
||||
Specifies a custom blockdevice to use for metadata for the thin pool.
|
||||
(Deprecated, use `dm.thinpooldev`)
|
||||
|
||||
For best performance the metadata should be on a different spindle than the
|
||||
data, or even better on an SSD.
|
||||
Specifies a custom blockdevice to use for metadata for the thin pool.
|
||||
|
||||
If setting up a new metadata pool it is required to be valid. This can be
|
||||
achieved by zeroing the first 4k to indicate empty metadata, like this:
|
||||
For best performance the metadata should be on a different spindle than the
|
||||
data, or even better on an SSD.
|
||||
|
||||
```bash
|
||||
$ dd if=/dev/zero of=$metadata_dev bs=4096 count=1
|
||||
```
|
||||
If setting up a new metadata pool it is required to be valid. This can be
|
||||
achieved by zeroing the first 4k to indicate empty metadata, like this:
|
||||
|
||||
Example use:
|
||||
```bash
|
||||
$ dd if=/dev/zero of=$metadata_dev bs=4096 count=1
|
||||
```
|
||||
|
||||
```bash
|
||||
$ sudo dockerd \
|
||||
--storage-opt dm.datadev=/dev/sdb1 \
|
||||
--storage-opt dm.metadatadev=/dev/sdc1
|
||||
```
|
||||
###### Example
|
||||
|
||||
* `dm.blocksize`
|
||||
```bash
|
||||
$ sudo dockerd \
|
||||
--storage-opt dm.datadev=/dev/sdb1 \
|
||||
--storage-opt dm.metadatadev=/dev/sdc1
|
||||
```
|
||||
|
||||
Specifies a custom blocksize to use for the thin pool. The default
|
||||
blocksize is 64K.
|
||||
##### `dm.blocksize`
|
||||
|
||||
Example use:
|
||||
Specifies a custom blocksize to use for the thin pool. The default
|
||||
blocksize is 64K.
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.blocksize=512K
|
||||
```
|
||||
###### Example
|
||||
|
||||
* `dm.blkdiscard`
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.blocksize=512K
|
||||
```
|
||||
|
||||
Enables or disables the use of blkdiscard when removing devicemapper
|
||||
devices. This is enabled by default (only) if using loopback devices and is
|
||||
required to resparsify the loopback file on image/container removal.
|
||||
##### `dm.blkdiscard`
|
||||
|
||||
Disabling this on loopback can lead to *much* faster container removal
|
||||
times, but will make the space used in `/var/lib/docker` directory not be
|
||||
returned to the system for other use when containers are removed.
|
||||
Enables or disables the use of `blkdiscard` when removing devicemapper
|
||||
devices. This is enabled by default (only) if using loopback devices and is
|
||||
required to resparsify the loopback file on image/container removal.
|
||||
|
||||
Example use:
|
||||
Disabling this on loopback can lead to *much* faster container removal
|
||||
times, but will make the space used in `/var/lib/docker` directory not be
|
||||
returned to the system for other use when containers are removed.
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.blkdiscard=false
|
||||
```
|
||||
###### Examples
|
||||
|
||||
* `dm.override_udev_sync_check`
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.blkdiscard=false
|
||||
```
|
||||
|
||||
Overrides the `udev` synchronization checks between `devicemapper` and `udev`.
|
||||
`udev` is the device manager for the Linux kernel.
|
||||
##### `dm.override_udev_sync_check`
|
||||
|
||||
To view the `udev` sync support of a Docker daemon that is using the
|
||||
`devicemapper` driver, run:
|
||||
Overrides the `udev` synchronization checks between `devicemapper` and `udev`.
|
||||
`udev` is the device manager for the Linux kernel.
|
||||
|
||||
```bash
|
||||
$ docker info
|
||||
[...]
|
||||
Udev Sync Supported: true
|
||||
[...]
|
||||
```
|
||||
To view the `udev` sync support of a Docker daemon that is using the
|
||||
`devicemapper` driver, run:
|
||||
|
||||
When `udev` sync support is `true`, then `devicemapper` and udev can
|
||||
coordinate the activation and deactivation of devices for containers.
|
||||
```bash
|
||||
$ docker info
|
||||
[...]
|
||||
Udev Sync Supported: true
|
||||
[...]
|
||||
```
|
||||
|
||||
When `udev` sync support is `false`, a race condition occurs between
|
||||
the`devicemapper` and `udev` during create and cleanup. The race condition
|
||||
results in errors and failures. (For information on these failures, see
|
||||
[docker#4036](https://github.com/docker/docker/issues/4036))
|
||||
When `udev` sync support is `true`, then `devicemapper` and udev can
|
||||
coordinate the activation and deactivation of devices for containers.
|
||||
|
||||
To allow the `docker` daemon to start, regardless of `udev` sync not being
|
||||
supported, set `dm.override_udev_sync_check` to true:
|
||||
When `udev` sync support is `false`, a race condition occurs between
|
||||
the`devicemapper` and `udev` during create and cleanup. The race condition
|
||||
results in errors and failures. (For information on these failures, see
|
||||
[docker#4036](https://github.com/docker/docker/issues/4036))
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.override_udev_sync_check=true
|
||||
```
|
||||
To allow the `docker` daemon to start, regardless of `udev` sync not being
|
||||
supported, set `dm.override_udev_sync_check` to true:
|
||||
|
||||
When this value is `true`, the `devicemapper` continues and simply warns
|
||||
you the errors are happening.
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.override_udev_sync_check=true
|
||||
```
|
||||
|
||||
> **Note:**
|
||||
> The ideal is to pursue a `docker` daemon and environment that does
|
||||
> support synchronizing with `udev`. For further discussion on this
|
||||
> topic, see [docker#4036](https://github.com/docker/docker/issues/4036).
|
||||
> Otherwise, set this flag for migrating existing Docker daemons to
|
||||
> a daemon with a supported environment.
|
||||
When this value is `true`, the `devicemapper` continues and simply warns
|
||||
you the errors are happening.
|
||||
|
||||
* `dm.use_deferred_removal`
|
||||
> **Note**: The ideal is to pursue a `docker` daemon and environment that does
|
||||
> support synchronizing with `udev`. For further discussion on this
|
||||
> topic, see [docker#4036](https://github.com/docker/docker/issues/4036).
|
||||
> Otherwise, set this flag for migrating existing Docker daemons to
|
||||
> a daemon with a supported environment.
|
||||
|
||||
Enables use of deferred device removal if `libdm` and the kernel driver
|
||||
support the mechanism.
|
||||
##### `dm.use_deferred_removal`
|
||||
|
||||
Deferred device removal means that if device is busy when devices are
|
||||
being removed/deactivated, then a deferred removal is scheduled on
|
||||
device. And devices automatically go away when last user of the device
|
||||
exits.
|
||||
Enables use of deferred device removal if `libdm` and the kernel driver
|
||||
support the mechanism.
|
||||
|
||||
For example, when a container exits, its associated thin device is removed.
|
||||
If that device has leaked into some other mount namespace and can't be
|
||||
removed, the container exit still succeeds and this option causes the
|
||||
system to schedule the device for deferred removal. It does not wait in a
|
||||
loop trying to remove a busy device.
|
||||
Deferred device removal means that if device is busy when devices are
|
||||
being removed/deactivated, then a deferred removal is scheduled on
|
||||
device. And devices automatically go away when last user of the device
|
||||
exits.
|
||||
|
||||
Example use:
|
||||
For example, when a container exits, its associated thin device is removed.
|
||||
If that device has leaked into some other mount namespace and can't be
|
||||
removed, the container exit still succeeds and this option causes the
|
||||
system to schedule the device for deferred removal. It does not wait in a
|
||||
loop trying to remove a busy device.
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.use_deferred_removal=true
|
||||
```
|
||||
###### Example
|
||||
|
||||
* `dm.use_deferred_deletion`
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.use_deferred_removal=true
|
||||
```
|
||||
|
||||
Enables use of deferred device deletion for thin pool devices. By default,
|
||||
thin pool device deletion is synchronous. Before a container is deleted,
|
||||
the Docker daemon removes any associated devices. If the storage driver
|
||||
can not remove a device, the container deletion fails and daemon returns.
|
||||
##### `dm.use_deferred_deletion`
|
||||
|
||||
Error deleting container: Error response from daemon: Cannot destroy container
|
||||
Enables use of deferred device deletion for thin pool devices. By default,
|
||||
thin pool device deletion is synchronous. Before a container is deleted,
|
||||
the Docker daemon removes any associated devices. If the storage driver
|
||||
can not remove a device, the container deletion fails and daemon returns.
|
||||
|
||||
To avoid this failure, enable both deferred device deletion and deferred
|
||||
device removal on the daemon.
|
||||
```none
|
||||
Error deleting container: Error response from daemon: Cannot destroy container
|
||||
```
|
||||
|
||||
```bash
|
||||
$ sudo dockerd \
|
||||
--storage-opt dm.use_deferred_deletion=true \
|
||||
--storage-opt dm.use_deferred_removal=true
|
||||
```
|
||||
To avoid this failure, enable both deferred device deletion and deferred
|
||||
device removal on the daemon.
|
||||
|
||||
With these two options enabled, if a device is busy when the driver is
|
||||
deleting a container, the driver marks the device as deleted. Later, when
|
||||
the device isn't in use, the driver deletes it.
|
||||
```bash
|
||||
$ sudo dockerd \
|
||||
--storage-opt dm.use_deferred_deletion=true \
|
||||
--storage-opt dm.use_deferred_removal=true
|
||||
```
|
||||
|
||||
In general it should be safe to enable this option by default. It will help
|
||||
when unintentional leaking of mount point happens across multiple mount
|
||||
namespaces.
|
||||
With these two options enabled, if a device is busy when the driver is
|
||||
deleting a container, the driver marks the device as deleted. Later, when
|
||||
the device isn't in use, the driver deletes it.
|
||||
|
||||
* `dm.min_free_space`
|
||||
In general it should be safe to enable this option by default. It will help
|
||||
when unintentional leaking of mount point happens across multiple mount
|
||||
namespaces.
|
||||
|
||||
Specifies the min free space percent in a thin pool require for new device
|
||||
creation to succeed. This check applies to both free data space as well
|
||||
as free metadata space. Valid values are from 0% - 99%. Value 0% disables
|
||||
free space checking logic. If user does not specify a value for this option,
|
||||
the Engine uses a default value of 10%.
|
||||
##### `dm.min_free_space`
|
||||
|
||||
Whenever a new a thin pool device is created (during `docker pull` or during
|
||||
container creation), the Engine checks if the minimum free space is
|
||||
available. If sufficient space is unavailable, then device creation fails
|
||||
and any relevant `docker` operation fails.
|
||||
Specifies the min free space percent in a thin pool require for new device
|
||||
creation to succeed. This check applies to both free data space as well
|
||||
as free metadata space. Valid values are from 0% - 99%. Value 0% disables
|
||||
free space checking logic. If user does not specify a value for this option,
|
||||
the Engine uses a default value of 10%.
|
||||
|
||||
To recover from this error, you must create more free space in the thin pool
|
||||
to recover from the error. You can create free space by deleting some images
|
||||
and containers from the thin pool. You can also add more storage to the thin
|
||||
pool.
|
||||
Whenever a new a thin pool device is created (during `docker pull` or during
|
||||
container creation), the Engine checks if the minimum free space is
|
||||
available. If sufficient space is unavailable, then device creation fails
|
||||
and any relevant `docker` operation fails.
|
||||
|
||||
To add more space to a LVM (logical volume management) thin pool, just add
|
||||
more storage to the volume group container thin pool; this should automatically
|
||||
resolve any errors. If your configuration uses loop devices, then stop the
|
||||
Engine daemon, grow the size of loop files and restart the daemon to resolve
|
||||
the issue.
|
||||
To recover from this error, you must create more free space in the thin pool
|
||||
to recover from the error. You can create free space by deleting some images
|
||||
and containers from the thin pool. You can also add more storage to the thin
|
||||
pool.
|
||||
|
||||
Example use:
|
||||
To add more space to a LVM (logical volume management) thin pool, just add
|
||||
more storage to the volume group container thin pool; this should automatically
|
||||
resolve any errors. If your configuration uses loop devices, then stop the
|
||||
Engine daemon, grow the size of loop files and restart the daemon to resolve
|
||||
the issue.
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.min_free_space=10%
|
||||
```
|
||||
###### Example
|
||||
|
||||
* `dm.xfs_nospace_max_retries`
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.min_free_space=10%
|
||||
```
|
||||
|
||||
Specifies the maximum number of retries XFS should attempt to complete
|
||||
IO when ENOSPC (no space) error is returned by underlying storage device.
|
||||
##### `dm.xfs_nospace_max_retries`
|
||||
|
||||
By default XFS retries infinitely for IO to finish and this can result
|
||||
in unkillable process. To change this behavior one can set
|
||||
xfs_nospace_max_retries to say 0 and XFS will not retry IO after getting
|
||||
ENOSPC and will shutdown filesystem.
|
||||
Specifies the maximum number of retries XFS should attempt to complete
|
||||
IO when ENOSPC (no space) error is returned by underlying storage device.
|
||||
|
||||
Example use:
|
||||
By default XFS retries infinitely for IO to finish and this can result
|
||||
in unkillable process. To change this behavior one can set
|
||||
xfs_nospace_max_retries to say 0 and XFS will not retry IO after getting
|
||||
ENOSPC and will shutdown filesystem.
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.xfs_nospace_max_retries=0
|
||||
```
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
$ sudo dockerd --storage-opt dm.xfs_nospace_max_retries=0
|
||||
```
|
||||
|
||||
#### ZFS options
|
||||
|
||||
* `zfs.fsname`
|
||||
##### `zfs.fsname`
|
||||
|
||||
Set zfs filesystem under which docker will create its own datasets.
|
||||
By default docker will pick up the zfs filesystem where docker graph
|
||||
(`/var/lib/docker`) is located.
|
||||
Set zfs filesystem under which docker will create its own datasets.
|
||||
By default docker will pick up the zfs filesystem where docker graph
|
||||
(`/var/lib/docker`) is located.
|
||||
|
||||
Example use:
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
$ sudo dockerd -s zfs --storage-opt zfs.fsname=zroot/docker
|
||||
```
|
||||
```bash
|
||||
$ sudo dockerd -s zfs --storage-opt zfs.fsname=zroot/docker
|
||||
```
|
||||
|
||||
#### Btrfs options
|
||||
|
||||
* `btrfs.min_space`
|
||||
##### `btrfs.min_space`
|
||||
|
||||
Specifies the minimum size to use when creating the subvolume which is used
|
||||
for containers. If user uses disk quota for btrfs when creating or running
|
||||
a container with **--storage-opt size** option, docker should ensure the
|
||||
**size** cannot be smaller than **btrfs.min_space**.
|
||||
Specifies the minimum size to use when creating the subvolume which is used
|
||||
for containers. If user uses disk quota for btrfs when creating or running
|
||||
a container with **--storage-opt size** option, docker should ensure the
|
||||
**size** cannot be smaller than **btrfs.min_space**.
|
||||
|
||||
Example use:
|
||||
###### Example
|
||||
|
||||
```bash
|
||||
$ sudo dockerd -s btrfs --storage-opt btrfs.min_space=10G
|
||||
```
|
||||
```bash
|
||||
$ sudo dockerd -s btrfs --storage-opt btrfs.min_space=10G
|
||||
```
|
||||
|
||||
#### Overlay2 options
|
||||
|
||||
* `overlay2.override_kernel_check`
|
||||
##### `overlay2.override_kernel_check`
|
||||
|
||||
Overrides the Linux kernel version check allowing overlay2. Support for
|
||||
specifying multiple lower directories needed by overlay2 was added to the
|
||||
Linux kernel in 4.0.0. However some older kernel versions may be patched
|
||||
to add multiple lower directory support for OverlayFS. This option should
|
||||
only be used after verifying this support exists in the kernel. Applying
|
||||
this option on a kernel without this support will cause failures on mount.
|
||||
Overrides the Linux kernel version check allowing overlay2. Support for
|
||||
specifying multiple lower directories needed by overlay2 was added to the
|
||||
Linux kernel in 4.0.0. However, some older kernel versions may be patched
|
||||
to add multiple lower directory support for OverlayFS. This option should
|
||||
only be used after verifying this support exists in the kernel. Applying
|
||||
this option on a kernel without this support will cause failures on mount.
|
||||
|
||||
## Docker runtime execution options
|
||||
### Docker runtime execution options
|
||||
|
||||
The Docker daemon relies on a
|
||||
[OCI](https://github.com/opencontainers/runtime-spec) compliant runtime
|
||||
|
@ -706,9 +706,9 @@ This is the same example via the command line:
|
|||
$ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-runc-replacement
|
||||
```
|
||||
|
||||
> **Note**: defining runtime arguments via the command line is not supported.
|
||||
> **Note**: Defining runtime arguments via the command line is not supported.
|
||||
|
||||
## Options for the runtime
|
||||
#### Options for the runtime
|
||||
|
||||
You can configure the runtime using options specified
|
||||
with the `--exec-opt` flag. All the flag's options have the `native` prefix. A
|
||||
|
@ -738,7 +738,7 @@ Will make `hyperv` the default isolation technology on Windows. If no isolation
|
|||
value is specified on daemon start, on Windows client, the default is
|
||||
`hyperv`, and on Windows server, the default is `process`.
|
||||
|
||||
## Daemon DNS options
|
||||
#### Daemon DNS options
|
||||
|
||||
To set the DNS server for all Docker containers, use:
|
||||
|
||||
|
@ -753,8 +753,7 @@ To set the DNS search domain for all Docker containers, use:
|
|||
$ sudo dockerd --dns-search example.com
|
||||
```
|
||||
|
||||
|
||||
## Insecure registries
|
||||
#### Insecure registries
|
||||
|
||||
Docker considers a private registry either secure or insecure. In the rest of
|
||||
this section, *registry* is used for *private registry*, and `myregistry:5000`
|
||||
|
@ -798,11 +797,11 @@ because its use creates security vulnerabilities it should ONLY be enabled for
|
|||
testing purposes. For increased security, users should add their CA to their
|
||||
system's list of trusted CAs instead of enabling `--insecure-registry`.
|
||||
|
||||
## Legacy Registries
|
||||
##### Legacy Registries
|
||||
|
||||
Enabling `--disable-legacy-registry` forces a docker daemon to only interact with registries which support the V2 protocol. Specifically, the daemon will not attempt `push`, `pull` and `login` to v1 registries. The exception to this is `search` which can still be performed on v1 registries.
|
||||
|
||||
## Running a Docker daemon behind an HTTPS_PROXY
|
||||
#### Running a Docker daemon behind an HTTPS_PROXY
|
||||
|
||||
When running inside a LAN that uses an `HTTPS` proxy, the Docker Hub
|
||||
certificates will be replaced by the proxy's certificates. These certificates
|
||||
|
@ -819,7 +818,7 @@ This will only add the proxy and authentication to the Docker daemon's requests
|
|||
your `docker build`s and running containers will need extra configuration to
|
||||
use the proxy
|
||||
|
||||
## Default Ulimits
|
||||
#### Default `ulimit` settings
|
||||
|
||||
`--default-ulimit` allows you to set the default `ulimit` options to use for
|
||||
all containers. It takes the same options as `--ulimit` for `docker run`. If
|
||||
|
@ -831,7 +830,7 @@ Be careful setting `nproc` with the `ulimit` flag as `nproc` is designed by Linu
|
|||
set the maximum number of processes available to a user, not to a container. For details
|
||||
please check the [run](run.md) reference.
|
||||
|
||||
## Nodes discovery
|
||||
#### Node discovery
|
||||
|
||||
The `--cluster-advertise` option specifies the `host:port` or `interface:port`
|
||||
combination that this particular daemon instance should use when advertising
|
||||
|
@ -857,39 +856,16 @@ $ sudo dockerd \
|
|||
|
||||
The currently supported cluster store options are:
|
||||
|
||||
* `discovery.heartbeat`
|
||||
| Option | Description |
|
||||
|-----------------------|-------------|
|
||||
| `discovery.heartbeat` | Specifies the heartbeat timer in seconds which is used by the daemon as a `keepalive` mechanism to make sure discovery module treats the node as alive in the cluster. If not configured, the default value is 20 seconds. |
|
||||
| `discovery.ttl` | Specifies the TTL (time-to-live) in seconds which is used by the discovery module to timeout a node if a valid heartbeat is not received within the configured ttl value. If not configured, the default value is 60 seconds. |
|
||||
| `kv.cacertfile` | Specifies the path to a local file with PEM encoded CA certificates to trust. |
|
||||
| `kv.certfile` | Specifies the path to a local file with a PEM encoded certificate. This certificate is used as the client cert for communication with the Key/Value store. |
|
||||
| `kv.keyfile` | Specifies the path to a local file with a PEM encoded private key. This private key is used as the client key for communication with the Key/Value store. |
|
||||
| `kv.path` | Specifies the path in the Key/Value store. If not configured, the default value is 'docker/nodes'. |
|
||||
|
||||
Specifies the heartbeat timer in seconds which is used by the daemon as a
|
||||
keepalive mechanism to make sure discovery module treats the node as alive
|
||||
in the cluster. If not configured, the default value is 20 seconds.
|
||||
|
||||
* `discovery.ttl`
|
||||
|
||||
Specifies the ttl (time-to-live) in seconds which is used by the discovery
|
||||
module to timeout a node if a valid heartbeat is not received within the
|
||||
configured ttl value. If not configured, the default value is 60 seconds.
|
||||
|
||||
* `kv.cacertfile`
|
||||
|
||||
Specifies the path to a local file with PEM encoded CA certificates to trust
|
||||
|
||||
* `kv.certfile`
|
||||
|
||||
Specifies the path to a local file with a PEM encoded certificate. This
|
||||
certificate is used as the client cert for communication with the
|
||||
Key/Value store.
|
||||
|
||||
* `kv.keyfile`
|
||||
|
||||
Specifies the path to a local file with a PEM encoded private key. This
|
||||
private key is used as the client key for communication with the
|
||||
Key/Value store.
|
||||
|
||||
* `kv.path`
|
||||
|
||||
Specifies the path in the Key/Value store. If not configured, the default value is 'docker/nodes'.
|
||||
|
||||
## Access authorization
|
||||
#### Access authorization
|
||||
|
||||
Docker's access authorization can be extended by authorization plugins that your
|
||||
organization can purchase or build themselves. You can install one or more
|
||||
|
@ -914,7 +890,7 @@ For information about how to create an authorization plugin, see [authorization
|
|||
plugin](../../extend/plugins_authorization.md) section in the Docker extend section of this documentation.
|
||||
|
||||
|
||||
## Daemon user namespace options
|
||||
#### Daemon user namespace options
|
||||
|
||||
The Linux kernel [user namespace support](http://man7.org/linux/man-pages/man7/user_namespaces.7.html) provides additional security by enabling
|
||||
a process, and therefore a container, to have a unique range of user and
|
||||
|
@ -947,7 +923,7 @@ and provided subordinate uid and gid ranges. This default user will be named
|
|||
> pull`, `docker push`, and container startup as users expect with
|
||||
> user namespaces disabled.
|
||||
|
||||
### Starting the daemon with user namespaces enabled
|
||||
##### Start the daemon with user namespaces enabled
|
||||
|
||||
To enable user namespace support, start the daemon with the
|
||||
`--userns-remap` flag, which accepts values in the following formats:
|
||||
|
@ -994,7 +970,20 @@ with user namespaces enabled or not. If the daemon is configured with user
|
|||
namespaces, the Security Options entry in the response will list "userns" as
|
||||
one of the enabled security features.
|
||||
|
||||
### Detailed information on `subuid`/`subgid` ranges
|
||||
##### Behavior differences when user namespaces are enabled
|
||||
|
||||
When you start the Docker daemon with `--userns-remap`, Docker segregates the graph directory
|
||||
where the images are stored by adding an extra directory with a name corresponding to the
|
||||
remapped UID and GID. For example, if the remapped UID and GID begin with `165536`, all
|
||||
images and containers running with that remap setting are located in `/var/lib/docker/165536.165536`
|
||||
instead of `/var/lib/docker/`.
|
||||
|
||||
In addition, the files and directories within the new directory, which correspond to
|
||||
images and container layers, are also owned by the new UID and GID. To set the ownership
|
||||
correctly, you need to re-pull the images and restart the containers after starting the
|
||||
daemon with `--userns-remap`.
|
||||
|
||||
##### Detailed information on `subuid`/`subgid` ranges
|
||||
|
||||
Given potential advanced use of the subordinate ID ranges by power users, the
|
||||
following paragraphs define how the Docker daemon currently uses the range entries
|
||||
|
@ -1017,7 +1006,7 @@ following algorithm to create the mapping ranges:
|
|||
2. Map segments will be created from each range in increasing value with a length matching the length of each segment. Therefore the range segment with the lowest numeric starting value will be equal to the remapped root, and continue up through host uid/gid equal to the range segment length. As an example, if the lowest segment starts at ID 1000 and has a length of 100, then a map of 1000 -> 0 (the remapped root) up through 1100 -> 100 will be created from this segment. If the next segment starts at ID 10000, then the next map will start with mapping 10000 -> 101 up to the length of this second segment. This will continue until no more segments are found in the subordinate files for this user.
|
||||
3. If more than five range segments exist for a single user, only the first five will be utilized, matching the kernel's limitation of only five entries in `/proc/self/uid_map` and `proc/self/gid_map`.
|
||||
|
||||
### Disable user namespace for a container
|
||||
##### Disable user namespace for a container
|
||||
|
||||
If you enable user namespaces on the daemon, all containers are started
|
||||
with user namespaces enabled. In some situations you might want to disable
|
||||
|
@ -1027,7 +1016,7 @@ To enable those advanced features for a specific container use `--userns=host`
|
|||
in the `run/exec/create` command.
|
||||
This option will completely disable user namespace mapping for the container's user.
|
||||
|
||||
### User namespace known restrictions
|
||||
##### User namespace known restrictions
|
||||
|
||||
The following standard Docker features are currently incompatible when
|
||||
running a Docker daemon with user namespaces enabled:
|
||||
|
@ -1050,7 +1039,7 @@ process. The most notable restriction that we are aware of at this time is the
|
|||
inability to use `mknod`. Permission will be denied for device creation even as
|
||||
container `root` inside a user namespace.
|
||||
|
||||
## Miscellaneous options
|
||||
### Miscellaneous options
|
||||
|
||||
IP masquerading uses address translation to allow containers without a public
|
||||
IP to talk to other machines on the Internet. This may interfere with some
|
||||
|
@ -1065,7 +1054,7 @@ set like this:
|
|||
export DOCKER_TMPDIR=/mnt/disk2/tmp
|
||||
/usr/local/bin/dockerd -D -g /var/lib/docker -H unix:// > /var/lib/docker-machine/docker.log 2>&1
|
||||
|
||||
## Default cgroup parent
|
||||
#### Default cgroup parent
|
||||
|
||||
The `--cgroup-parent` option allows you to set the default cgroup parent
|
||||
to use for containers. If this option is not set, it defaults to `/docker` for
|
||||
|
@ -1092,7 +1081,7 @@ This setting can also be set per container, using the `--cgroup-parent`
|
|||
option on `docker create` and `docker run`, and takes precedence over
|
||||
the `--cgroup-parent` option on the daemon.
|
||||
|
||||
## Daemon Metrics
|
||||
#### Daemon metrics
|
||||
|
||||
The `--metrics-addr` option takes a tcp address to serve the metrics API.
|
||||
This feature is still experimental, therefore, the daemon must be running in experimental
|
||||
|
@ -1106,7 +1095,7 @@ If you are running a prometheus server you can add this address to your scrape c
|
|||
to have prometheus collect metrics on Docker. For more information
|
||||
on prometheus you can view the website [here](https://prometheus.io/).
|
||||
|
||||
```yml
|
||||
```none
|
||||
scrape_configs:
|
||||
- job_name: 'docker'
|
||||
static_configs:
|
||||
|
@ -1117,7 +1106,7 @@ Please note that this feature is still marked as experimental as metrics and met
|
|||
names could change while this feature is still in experimental. Please provide
|
||||
feedback on what you would like to see collected in the API.
|
||||
|
||||
## Daemon configuration file
|
||||
#### Daemon configuration file
|
||||
|
||||
The `--config-file` option allows you to set any configuration option
|
||||
for the daemon in a JSON format. This file uses the same flag names as keys,
|
||||
|
@ -1132,7 +1121,7 @@ For example, the daemon fails to start if you set daemon labels
|
|||
in the configuration file and also set daemon labels via the `--label` flag.
|
||||
Options that are not present in the file are ignored when the daemon starts.
|
||||
|
||||
### Linux configuration file
|
||||
##### On Linux
|
||||
|
||||
The default location of the configuration file on Linux is
|
||||
`/etc/docker/daemon.json`. The `--config-file` flag can be used to specify a
|
||||
|
@ -1216,7 +1205,7 @@ This is a full example of the allowed configuration options on Linux:
|
|||
}
|
||||
```
|
||||
|
||||
### Windows configuration file
|
||||
##### On Windows
|
||||
|
||||
The default location of the configuration file on Windows is
|
||||
`%programdata%\docker\config\daemon.json`. The `--config-file` flag can be
|
||||
|
@ -1263,7 +1252,7 @@ This is a full example of the allowed configuration options on Windows:
|
|||
}
|
||||
```
|
||||
|
||||
### Configuration reloading
|
||||
#### Configuration reload behavior
|
||||
|
||||
Some options can be reconfigured when the daemon is running without requiring
|
||||
to restart the process. We use the `SIGHUP` signal in Linux to reload, and a global event
|
||||
|
@ -1299,7 +1288,7 @@ Configuration reload will log a warning message if it detects a change in
|
|||
previously configured cluster configurations.
|
||||
|
||||
|
||||
## Running multiple daemons
|
||||
### Run multiple daemons
|
||||
|
||||
> **Note:** Running multiple daemons on a single host is considered as "experimental". The user should be aware of
|
||||
> unsolved problems. This solution may not work properly in some cases. Solutions are currently under development
|
||||
|
@ -1312,7 +1301,7 @@ by providing them as flags, or by using a [daemon configuration file](#daemon-co
|
|||
|
||||
The following daemon options must be configured for each daemon:
|
||||
|
||||
```bash
|
||||
```none
|
||||
-b, --bridge= Attach containers to a network bridge
|
||||
--exec-root=/var/run/docker Root of the Docker execdriver
|
||||
-g, --graph=/var/lib/docker Root of the Docker runtime
|
||||
|
|
|
@ -28,29 +28,90 @@ Options:
|
|||
--until string Stream events until this timestamp
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Use `docker events` to get real-time events from the server. These events differ
|
||||
per Docker object type.
|
||||
|
||||
### Object types
|
||||
|
||||
#### Containers
|
||||
|
||||
Docker containers report the following events:
|
||||
|
||||
attach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, health_status, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update
|
||||
- `attach`
|
||||
- `commit`
|
||||
- `copy`
|
||||
- `create`
|
||||
- `destroy`
|
||||
- `detach`
|
||||
- `die`
|
||||
- `exec_create`
|
||||
- `exec_detach`
|
||||
- `exec_start`
|
||||
- `export`
|
||||
- `health_status`
|
||||
- `kill`
|
||||
- `oom`
|
||||
- `pause`
|
||||
- `rename`
|
||||
- `resize`
|
||||
- `restart`
|
||||
- `start`
|
||||
- `stop`
|
||||
- `top`
|
||||
- `unpause`
|
||||
- `update`
|
||||
|
||||
#### Images
|
||||
|
||||
Docker images report the following events:
|
||||
|
||||
delete, import, load, pull, push, save, tag, untag
|
||||
- `delete`
|
||||
- `import`
|
||||
- `load`
|
||||
- `pull`
|
||||
- `push`
|
||||
- `save`
|
||||
- `tag`
|
||||
- `untag`
|
||||
|
||||
#### Plugins
|
||||
|
||||
Docker plugins report the following events:
|
||||
|
||||
install, enable, disable, remove
|
||||
- `install`
|
||||
- `enable`
|
||||
- `disable`
|
||||
- `remove`
|
||||
|
||||
#### Volumes
|
||||
|
||||
Docker volumes report the following events:
|
||||
|
||||
create, mount, unmount, destroy
|
||||
- `create`
|
||||
- `mount`
|
||||
- `unmount`
|
||||
- `destroy`
|
||||
|
||||
#### Networks
|
||||
|
||||
Docker networks report the following events:
|
||||
|
||||
create, connect, disconnect, destroy
|
||||
- `create`
|
||||
- `connect`
|
||||
- `disconnect`
|
||||
- `destroy`
|
||||
|
||||
Docker daemon reports the following events:
|
||||
#### Daemons
|
||||
|
||||
reload
|
||||
Docker daemons report the following events:
|
||||
|
||||
- `reload`
|
||||
|
||||
### Limiting, filtering, and formatting the output
|
||||
|
||||
#### Limit events by time
|
||||
|
||||
The `--since` and `--until` parameters can be Unix timestamps, date formatted
|
||||
timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed
|
||||
|
@ -65,7 +126,7 @@ that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
|
|||
seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
|
||||
fraction of a second no more than nine digits long.
|
||||
|
||||
## Filtering
|
||||
#### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If you would
|
||||
like to use multiple filters, pass multiple flags (e.g.,
|
||||
|
@ -91,7 +152,7 @@ The currently supported filters are:
|
|||
* type (`type=<container or image or volume or network or daemon>`)
|
||||
* volume (`volume=<name or id>`)
|
||||
|
||||
## Format
|
||||
#### Format
|
||||
|
||||
If a format (`--format`) is specified, the given template will be executed
|
||||
instead of the default
|
||||
|
@ -103,132 +164,190 @@ Lines. For information about JSON Lines, please refer to http://jsonlines.org/ .
|
|||
|
||||
## Examples
|
||||
|
||||
### Basic example
|
||||
|
||||
You'll need two shells for this example.
|
||||
|
||||
**Shell 1: Listening for events:**
|
||||
|
||||
$ docker events
|
||||
```bash
|
||||
$ docker events
|
||||
```
|
||||
|
||||
**Shell 2: Start and Stop containers:**
|
||||
|
||||
$ docker create --name test alpine:latest top
|
||||
$ docker start test
|
||||
$ docker stop test
|
||||
```bash
|
||||
$ docker create --name test alpine:latest top
|
||||
$ docker start test
|
||||
$ docker stop test
|
||||
```
|
||||
|
||||
**Shell 1: (Again .. now showing events):**
|
||||
|
||||
2017-01-05T00:35:58.859401177+08:00 container create 0fdb48addc82871eb34eb23a847cfd033dedd1a0a37bef2e6d9eb3870fc7ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:04.703631903+08:00 network connect e2e1f5ceda09d4300f3a846f0acfaa9a8bb0d89e775eb744c5acecd60e0529e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
```none
|
||||
2017-01-05T00:35:58.859401177+08:00 container create 0fdb48addc82871eb34eb23a847cfd033dedd1a0a37bef2e6d9eb3870fc7ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:04.703631903+08:00 network connect e2e1f5ceda09d4300f3a846f0acfaa9a8bb0d89e775eb744c5acecd60e0529e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
```
|
||||
|
||||
**Show events in the past from a specified time:**
|
||||
To exit the `docker events` command, use `CTRL+C`.
|
||||
|
||||
$ docker events --since 1483283804
|
||||
2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)
|
||||
2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
### Filter events by time
|
||||
|
||||
$ docker events --since '2017-01-05'
|
||||
2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)
|
||||
2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
You can filter the output by an absolute timestamp or relative time on the host
|
||||
machine, using the following different time syntaxes:
|
||||
|
||||
$ docker events --since '2013-09-03T15:49:29'
|
||||
2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)
|
||||
2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
```bash
|
||||
$ docker events --since 1483283804
|
||||
2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)
|
||||
2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
|
||||
This example outputs all events that were generated in the last 3 minutes,
|
||||
relative to the current time on the client machine:
|
||||
$ docker events --since '2017-01-05'
|
||||
2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)
|
||||
2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
|
||||
$ docker events --since '10m'
|
||||
2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)
|
||||
2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
$ docker events --since '2013-09-03T15:49:29'
|
||||
2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)
|
||||
2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
|
||||
**Filter events:**
|
||||
$ docker events --since '10m'
|
||||
2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local)
|
||||
2017-01-05T00:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:04.703631903+08:00 network connect e2e1...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:04.795031609+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.830268747+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:36:09.840186338+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:36:09.880113663+08:00 network disconnect e2e...29e2 (container=0fdb...ff37, name=bridge, type=bridge)
|
||||
2017-01-05T00:36:09.890214053+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
```
|
||||
|
||||
$ docker events --filter 'event=stop'
|
||||
2017-01-05T00:40:22.880175420+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:41:17.888104182+08:00 container stop 2a8f...4e78 (image=alpine, name=kickass_brattain)
|
||||
### Filter events by criteria
|
||||
|
||||
$ docker events --filter 'image=alpine'
|
||||
2017-01-05T00:41:55.784240236+08:00 container create d9cd...4d70 (image=alpine, name=happy_meitner)
|
||||
2017-01-05T00:41:55.913156783+08:00 container start d9cd...4d70 (image=alpine, name=happy_meitner)
|
||||
2017-01-05T00:42:01.106875249+08:00 container kill d9cd...4d70 (image=alpine, name=happy_meitner, signal=15)
|
||||
2017-01-05T00:42:11.111934041+08:00 container kill d9cd...4d70 (image=alpine, name=happy_meitner, signal=9)
|
||||
2017-01-05T00:42:11.119578204+08:00 container die d9cd...4d70 (exitCode=137, image=alpine, name=happy_meitner)
|
||||
2017-01-05T00:42:11.173276611+08:00 container stop d9cd...4d70 (image=alpine, name=happy_meitner)
|
||||
The following commands show several different ways to filter the `docker event`
|
||||
output.
|
||||
|
||||
$ docker events --filter 'container=test'
|
||||
2017-01-05T00:43:00.139719934+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:43:09.259951086+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:43:09.270102715+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:43:09.312556440+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
```bash
|
||||
$ docker events --filter 'event=stop'
|
||||
|
||||
$ docker events --filter 'container=test' --filter 'container=d9cdb1525ea8'
|
||||
2017-01-05T00:44:11.517071981+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:44:17.685870901+08:00 container start d9cd...4d70 (image=alpine, name=happy_meitner)
|
||||
2017-01-05T00:44:29.757658470+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=9)
|
||||
2017-01-05T00:44:29.767718510+08:00 container die 0fdb...ff37 (exitCode=137, image=alpine:latest, name=test)
|
||||
2017-01-05T00:44:29.815798344+08:00 container destroy 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:40:22.880175420+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:41:17.888104182+08:00 container stop 2a8f...4e78 (image=alpine, name=kickass_brattain)
|
||||
|
||||
$ docker events --filter 'container=test' --filter 'event=stop'
|
||||
2017-01-05T00:46:13.664099505+08:00 container stop a9d1...e130 (image=alpine, name=test)
|
||||
$ docker events --filter 'image=alpine'
|
||||
|
||||
$ docker events --filter 'type=volume'
|
||||
2015-12-23T21:05:28.136212689Z volume create test-event-volume-local (driver=local)
|
||||
2015-12-23T21:05:28.383462717Z volume mount test-event-volume-local (read/write=true, container=562f...5025, destination=/foo, driver=local, propagation=rprivate)
|
||||
2015-12-23T21:05:28.650314265Z volume unmount test-event-volume-local (container=562f...5025, driver=local)
|
||||
2015-12-23T21:05:28.716218405Z volume destroy test-event-volume-local (driver=local)
|
||||
2017-01-05T00:41:55.784240236+08:00 container create d9cd...4d70 (image=alpine, name=happy_meitner)
|
||||
2017-01-05T00:41:55.913156783+08:00 container start d9cd...4d70 (image=alpine, name=happy_meitner)
|
||||
2017-01-05T00:42:01.106875249+08:00 container kill d9cd...4d70 (image=alpine, name=happy_meitner, signal=15)
|
||||
2017-01-05T00:42:11.111934041+08:00 container kill d9cd...4d70 (image=alpine, name=happy_meitner, signal=9)
|
||||
2017-01-05T00:42:11.119578204+08:00 container die d9cd...4d70 (exitCode=137, image=alpine, name=happy_meitner)
|
||||
2017-01-05T00:42:11.173276611+08:00 container stop d9cd...4d70 (image=alpine, name=happy_meitner)
|
||||
|
||||
$ docker events --filter 'type=network'
|
||||
2015-12-23T21:38:24.705709133Z network create 8b11...2c5b (name=test-event-network-local, type=bridge)
|
||||
2015-12-23T21:38:25.119625123Z network connect 8b11...2c5b (name=test-event-network-local, container=b4be...c54e, type=bridge)
|
||||
$ docker events --filter 'container=test'
|
||||
|
||||
$ docker events --filter 'type=plugin' (experimental)
|
||||
2016-07-25T17:30:14.825557616Z plugin pull ec7b...993f (name=tiborvass/sample-volume-plugin:latest)
|
||||
2016-07-25T17:30:14.888127370Z plugin enable ec7b...993f (name=tiborvass/sample-volume-plugin:latest)
|
||||
2017-01-05T00:43:00.139719934+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:43:09.259951086+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=15)
|
||||
2017-01-05T00:43:09.270102715+08:00 container die 0fdb...ff37 (exitCode=143, image=alpine:latest, name=test)
|
||||
2017-01-05T00:43:09.312556440+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
|
||||
**Format:**
|
||||
$ docker events --filter 'container=test' --filter 'container=d9cdb1525ea8'
|
||||
|
||||
$ docker events --filter 'type=container' --format 'Type={{.Type}} Status={{.Status}} ID={{.ID}}'
|
||||
Type=container Status=create ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
Type=container Status=attach ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
Type=container Status=start ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
Type=container Status=resize ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
Type=container Status=die ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
Type=container Status=destroy ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
2017-01-05T00:44:11.517071981+08:00 container start 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
2017-01-05T00:44:17.685870901+08:00 container start d9cd...4d70 (image=alpine, name=happy_meitner)
|
||||
2017-01-05T00:44:29.757658470+08:00 container kill 0fdb...ff37 (image=alpine:latest, name=test, signal=9)
|
||||
2017-01-05T00:44:29.767718510+08:00 container die 0fdb...ff37 (exitCode=137, image=alpine:latest, name=test)
|
||||
2017-01-05T00:44:29.815798344+08:00 container destroy 0fdb...ff37 (image=alpine:latest, name=test)
|
||||
|
||||
**Format (as JSON Lines):**
|
||||
$ docker events --filter 'container=test' --filter 'event=stop'
|
||||
|
||||
2017-01-05T00:46:13.664099505+08:00 container stop a9d1...e130 (image=alpine, name=test)
|
||||
|
||||
$ docker events --filter 'type=volume'
|
||||
|
||||
2015-12-23T21:05:28.136212689Z volume create test-event-volume-local (driver=local)
|
||||
2015-12-23T21:05:28.383462717Z volume mount test-event-volume-local (read/write=true, container=562f...5025, destination=/foo, driver=local, propagation=rprivate)
|
||||
2015-12-23T21:05:28.650314265Z volume unmount test-event-volume-local (container=562f...5025, driver=local)
|
||||
2015-12-23T21:05:28.716218405Z volume destroy test-event-volume-local (driver=local)
|
||||
|
||||
$ docker events --filter 'type=network'
|
||||
|
||||
2015-12-23T21:38:24.705709133Z network create 8b11...2c5b (name=test-event-network-local, type=bridge)
|
||||
2015-12-23T21:38:25.119625123Z network connect 8b11...2c5b (name=test-event-network-local, container=b4be...c54e, type=bridge)
|
||||
|
||||
$ docker events --filter 'container=container_1' --filter 'container=container_2'
|
||||
|
||||
2014-09-03T15:49:29.999999999Z07:00 container die 4386fb97867d (image=ubuntu-1:14.04)
|
||||
2014-05-10T17:42:14.999999999Z07:00 container stop 4386fb97867d (image=ubuntu-1:14.04)
|
||||
2014-05-10T17:42:14.999999999Z07:00 container die 7805c1d35632 (imager=redis:2.8)
|
||||
2014-09-03T15:49:29.999999999Z07:00 container stop 7805c1d35632 (image=redis:2.8)
|
||||
|
||||
$ docker events --filter 'type=volume'
|
||||
|
||||
2015-12-23T21:05:28.136212689Z volume create test-event-volume-local (driver=local)
|
||||
2015-12-23T21:05:28.383462717Z volume mount test-event-volume-local (read/write=true, container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, destination=/foo, driver=local, propagation=rprivate)
|
||||
2015-12-23T21:05:28.650314265Z volume unmount test-event-volume-local (container=562fe10671e9273da25eed36cdce26159085ac7ee6707105fd534866340a5025, driver=local)
|
||||
2015-12-23T21:05:28.716218405Z volume destroy test-event-volume-local (driver=local)
|
||||
|
||||
$ docker events --filter 'type=network'
|
||||
|
||||
2015-12-23T21:38:24.705709133Z network create 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, type=bridge)
|
||||
2015-12-23T21:38:25.119625123Z network connect 8b111217944ba0ba844a65b13efcd57dc494932ee2527577758f939315ba2c5b (name=test-event-network-local, container=b4be644031a3d90b400f88ab3d4bdf4dc23adb250e696b6328b85441abe2c54e, type=bridge)
|
||||
```
|
||||
|
||||
The `type=plugin` filter is experimental.
|
||||
|
||||
```bash
|
||||
$ docker events --filter 'type=plugin'
|
||||
|
||||
2016-07-25T17:30:14.825557616Z plugin pull ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/sample-volume-plugin:latest)
|
||||
2016-07-25T17:30:14.888127370Z plugin enable ec7b87f2ce84330fe076e666f17dfc049d2d7ae0b8190763de94e1f2d105993f (name=tiborvass/sample-volume-plugin:latest)
|
||||
```
|
||||
|
||||
### Format the output
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker events --filter 'type=container' --format 'Type={{.Type}} Status={{.Status}} ID={{.ID}}'
|
||||
|
||||
Type=container Status=create ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
Type=container Status=attach ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
Type=container Status=start ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
Type=container Status=resize ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
Type=container Status=die ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
Type=container Status=destroy ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
#### Format as JSON
|
||||
|
||||
```none
|
||||
{% raw %}
|
||||
$ docker events --format '{{json .}}'
|
||||
|
||||
{"status":"create","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..
|
||||
{"status":"attach","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..
|
||||
{"Type":"network","Action":"connect","Actor":{"ID":"1b50a5bf755f6021dfa78e..
|
||||
{"status":"start","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f42..
|
||||
{"status":"resize","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..
|
||||
{% endraw %}
|
||||
```
|
||||
|
|
|
@ -31,35 +31,61 @@ Options:
|
|||
-u, --user Username or UID (format: <name|uid>[:<group|gid>])
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `docker exec` command runs a new command in a running container.
|
||||
|
||||
The command started using `docker exec` only runs while the container's primary
|
||||
process (`PID 1`) is running, and it is not restarted if the container is
|
||||
restarted.
|
||||
|
||||
If the container is paused, then the `docker exec` command will fail with an error:
|
||||
|
||||
$ docker pause test
|
||||
test
|
||||
$ docker ps
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
1ae3b36715d2 ubuntu:latest "bash" 17 seconds ago Up 16 seconds (Paused) test
|
||||
$ docker exec test ls
|
||||
FATA[0000] Error response from daemon: Container test is paused, unpause the container before exec
|
||||
$ echo $?
|
||||
1
|
||||
|
||||
## Examples
|
||||
|
||||
$ docker run --name ubuntu_bash --rm -i -t ubuntu bash
|
||||
### Run `docker exec` on a running container
|
||||
|
||||
First, start a container.
|
||||
|
||||
```bash
|
||||
$ docker run --name ubuntu_bash --rm -i -t ubuntu bash
|
||||
```
|
||||
|
||||
This will create a container named `ubuntu_bash` and start a Bash session.
|
||||
|
||||
$ docker exec -d ubuntu_bash touch /tmp/execWorks
|
||||
Next, execute a command on the container.
|
||||
|
||||
```bash
|
||||
$ docker exec -d ubuntu_bash touch /tmp/execWorks
|
||||
```
|
||||
|
||||
This will create a new file `/tmp/execWorks` inside the running container
|
||||
`ubuntu_bash`, in the background.
|
||||
|
||||
$ docker exec -it ubuntu_bash bash
|
||||
Next, execute an interactive `bash` shell on the container.
|
||||
|
||||
```bash
|
||||
$ docker exec -it ubuntu_bash bash
|
||||
```
|
||||
|
||||
This will create a new Bash session in the container `ubuntu_bash`.
|
||||
|
||||
### Try to run `docker exec` on a paused container
|
||||
|
||||
If the container is paused, then the `docker exec` command will fail with an error:
|
||||
|
||||
```bash
|
||||
$ docker pause test
|
||||
|
||||
test
|
||||
|
||||
$ docker ps
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
1ae3b36715d2 ubuntu:latest "bash" 17 seconds ago Up 16 seconds (Paused) test
|
||||
|
||||
$ docker exec test ls
|
||||
|
||||
FATA[0000] Error response from daemon: Container test is paused, unpause the container before exec
|
||||
|
||||
$ echo $?
|
||||
1
|
||||
```
|
||||
|
|
|
@ -25,19 +25,24 @@ Options:
|
|||
-o, --output string Write to a file, instead of STDOUT
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `docker export` command does not export the contents of volumes associated
|
||||
with the container. If a volume is mounted on top of an existing directory in
|
||||
the container, `docker export` will export the contents of the *underlying*
|
||||
directory, not the contents of the volume.
|
||||
|
||||
Refer to [Backup, restore, or migrate data
|
||||
volumes](https://docs.docker.com/engine/tutorials/dockervolumes/#backup-restore-or-migrate-data-volumes) in
|
||||
the user guide for examples on exporting data in a volume.
|
||||
Refer to [Backup, restore, or migrate data volumes](https://docs.docker.com/engine/tutorials/dockervolumes/#backup-restore-or-migrate-data-volumes)
|
||||
in the user guide for examples on exporting data in a volume.
|
||||
|
||||
## Examples
|
||||
|
||||
$ docker export red_panda > latest.tar
|
||||
Each of these commands has the same result.
|
||||
|
||||
Or
|
||||
```bash
|
||||
$ docker export red_panda > latest.tar
|
||||
```
|
||||
|
||||
$ docker export --output="latest.tar" red_panda
|
||||
```bash
|
||||
$ docker export --output="latest.tar" red_panda
|
||||
```
|
||||
|
|
|
@ -27,22 +27,30 @@ Options:
|
|||
-q, --quiet Only show numeric IDs
|
||||
```
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
To see how the `docker:latest` image was built:
|
||||
|
||||
$ docker history docker
|
||||
IMAGE CREATED CREATED BY SIZE COMMENT
|
||||
3e23a5875458 8 days ago /bin/sh -c #(nop) ENV LC_ALL=C.UTF-8 0 B
|
||||
8578938dd170 8 days ago /bin/sh -c dpkg-reconfigure locales && loc 1.245 MB
|
||||
be51b77efb42 8 days ago /bin/sh -c apt-get update && apt-get install 338.3 MB
|
||||
4b137612be55 6 weeks ago /bin/sh -c #(nop) ADD jessie.tar.xz in / 121 MB
|
||||
750d58736b4b 6 weeks ago /bin/sh -c #(nop) MAINTAINER Tianon Gravi <ad 0 B
|
||||
511136ea3c5a 9 months ago 0 B Imported from -
|
||||
```bash
|
||||
$ docker history docker
|
||||
|
||||
IMAGE CREATED CREATED BY SIZE COMMENT
|
||||
3e23a5875458 8 days ago /bin/sh -c #(nop) ENV LC_ALL=C.UTF-8 0 B
|
||||
8578938dd170 8 days ago /bin/sh -c dpkg-reconfigure locales && loc 1.245 MB
|
||||
be51b77efb42 8 days ago /bin/sh -c apt-get update && apt-get install 338.3 MB
|
||||
4b137612be55 6 weeks ago /bin/sh -c #(nop) ADD jessie.tar.xz in / 121 MB
|
||||
750d58736b4b 6 weeks ago /bin/sh -c #(nop) MAINTAINER Tianon Gravi <ad 0 B
|
||||
511136ea3c5a 9 months ago 0 B Imported from -
|
||||
```
|
||||
|
||||
To see how the `docker:apache` image was added to a container's base image:
|
||||
|
||||
$ docker history docker:scm
|
||||
IMAGE CREATED CREATED BY SIZE COMMENT
|
||||
2ac9d1098bf1 3 months ago /bin/bash 241.4 MB Added Apache to Fedora base image
|
||||
88b42ffd1f7c 5 months ago /bin/sh -c #(nop) ADD file:1fd8d7f9f6557cafc7 373.7 MB
|
||||
c69cab00d6ef 5 months ago /bin/sh -c #(nop) MAINTAINER Lokesh Mandvekar 0 B
|
||||
511136ea3c5a 19 months ago 0 B Imported from -
|
||||
```bash
|
||||
$ docker history docker:scm
|
||||
IMAGE CREATED CREATED BY SIZE COMMENT
|
||||
2ac9d1098bf1 3 months ago /bin/bash 241.4 MB Added Apache to Fedora base image
|
||||
88b42ffd1f7c 5 months ago /bin/sh -c #(nop) ADD file:1fd8d7f9f6557cafc7 373.7 MB
|
||||
c69cab00d6ef 5 months ago /bin/sh -c #(nop) MAINTAINER Lokesh Mandvekar 0 B
|
||||
511136ea3c5a 19 months ago 0 B Imported from -
|
||||
```
|
||||
|
|
|
@ -26,12 +26,17 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Remove all dangling images. If `-a` is specified, will also remove all images not referenced by any container.
|
||||
|
||||
## Examples
|
||||
|
||||
Example output:
|
||||
|
||||
```bash
|
||||
$ docker image prune -a
|
||||
|
||||
WARNING! This will remove all images without at least one container associated to them.
|
||||
Are you sure you want to continue? [y/N] y
|
||||
Deleted Images:
|
||||
|
@ -62,7 +67,97 @@ deleted: sha256:2c675ee9ed53425e31a13e3390bf3f539bf8637000e4bcfbb85ee03ef4d910a1
|
|||
Total reclaimed space: 16.43 MB
|
||||
```
|
||||
|
||||
## Related information
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
||||
The currently supported filters are:
|
||||
|
||||
* until (`<timestamp>`) - only remove images created before given timestamp
|
||||
|
||||
The `until` filter can be Unix timestamps, date formatted
|
||||
timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed
|
||||
relative to the daemon machine’s time. Supported formats for date
|
||||
formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`,
|
||||
`2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local
|
||||
timezone on the daemon will be used if you do not provide either a `Z` or a
|
||||
`+-00:00` timezone offset at the end of the timestamp. When providing Unix
|
||||
timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
|
||||
that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
|
||||
seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
|
||||
fraction of a second no more than nine digits long.
|
||||
|
||||
The following removes images created before `2017-01-04T00:00:00`:
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker images --format 'table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Size}}'
|
||||
REPOSITORY TAG IMAGE ID CREATED AT SIZE
|
||||
foo latest 2f287ac753da 2017-01-04 13:42:23 -0800 PST 3.98 MB
|
||||
alpine latest 88e169ea8f46 2016-12-27 10:17:25 -0800 PST 3.98 MB
|
||||
busybox latest e02e811dd08f 2016-10-07 14:03:58 -0700 PDT 1.09 MB
|
||||
|
||||
$ docker image prune -a --force --filter "until=2017-01-04T00:00:00"
|
||||
|
||||
Deleted Images:
|
||||
untagged: alpine:latest
|
||||
untagged: alpine@sha256:dfbd4a3a8ebca874ebd2474f044a0b33600d4523d03b0df76e5c5986cb02d7e8
|
||||
untagged: busybox:latest
|
||||
untagged: busybox@sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912
|
||||
deleted: sha256:e02e811dd08fd49e7f6032625495118e63f597eb150403d02e3238af1df240ba
|
||||
deleted: sha256:e88b3f82283bc59d5e0df427c824e9f95557e661fcb0ea15fb0fb6f97760f9d9
|
||||
|
||||
Total reclaimed space: 1.093 MB
|
||||
|
||||
$ docker images --format 'table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Size}}'
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED AT SIZE
|
||||
foo latest 2f287ac753da 2017-01-04 13:42:23 -0800 PST 3.98 MB
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
The following removes images created more than 10 days (`240h`) ago:
|
||||
|
||||
```bash
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
foo latest 2f287ac753da 14 seconds ago 3.98 MB
|
||||
alpine latest 88e169ea8f46 8 days ago 3.98 MB
|
||||
debian jessie 7b0a06c805e8 2 months ago 123 MB
|
||||
busybox latest e02e811dd08f 2 months ago 1.09 MB
|
||||
golang 1.7.0 138c2e655421 4 months ago 670 MB
|
||||
|
||||
$ docker image prune -a --force --filter "until=240h"
|
||||
|
||||
Deleted Images:
|
||||
untagged: golang:1.7.0
|
||||
untagged: golang@sha256:6765038c2b8f407fd6e3ecea043b44580c229ccfa2a13f6d85866cf2b4a9628e
|
||||
deleted: sha256:138c2e6554219de65614d88c15521bfb2da674cbb0bf840de161f89ff4264b96
|
||||
deleted: sha256:ec353c2e1a673f456c4b78906d0d77f9d9456cfb5229b78c6a960bfb7496b76a
|
||||
deleted: sha256:fe22765feaf3907526b4921c73ea6643ff9e334497c9b7e177972cf22f68ee93
|
||||
deleted: sha256:ff845959c80148421a5c3ae11cc0e6c115f950c89bc949646be55ed18d6a2912
|
||||
deleted: sha256:a4320831346648c03db64149eafc83092e2b34ab50ca6e8c13112388f25899a7
|
||||
deleted: sha256:4c76020202ee1d9709e703b7c6de367b325139e74eebd6b55b30a63c196abaf3
|
||||
deleted: sha256:d7afd92fb07236c8a2045715a86b7d5f0066cef025018cd3ca9a45498c51d1d6
|
||||
deleted: sha256:9e63c5bce4585dd7038d830a1f1f4e44cb1a1515b00e620ac718e934b484c938
|
||||
untagged: debian:jessie
|
||||
untagged: debian@sha256:c1af755d300d0c65bb1194d24bce561d70c98a54fb5ce5b1693beb4f7988272f
|
||||
deleted: sha256:7b0a06c805e8f23807fb8856621c60851727e85c7bcb751012c813f122734c8d
|
||||
deleted: sha256:f96222d75c5563900bc4dd852179b720a0885de8f7a0619ba0ac76e92542bbc8
|
||||
|
||||
Total reclaimed space: 792.6 MB
|
||||
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
foo latest 2f287ac753da About a minute ago 3.98 MB
|
||||
alpine latest 88e169ea8f46 8 days ago 3.98 MB
|
||||
busybox latest e02e811dd08f 2 months ago 1.09 MB
|
||||
```
|
||||
|
||||
## Related commands
|
||||
|
||||
* [system df](system_df.md)
|
||||
* [container prune](container_prune.md)
|
||||
|
|
|
@ -35,6 +35,8 @@ Options:
|
|||
-q, --quiet Only show numeric IDs
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The default `docker images` will show all top level
|
||||
images, their repository and tags, and their size.
|
||||
|
||||
|
@ -51,21 +53,26 @@ An image will be listed more than once if it has multiple repository names
|
|||
or tags. This single image (identifiable by its matching `IMAGE ID`)
|
||||
uses up the `SIZE` listed only once.
|
||||
|
||||
### Listing the most recently created images
|
||||
## Examples
|
||||
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
<none> <none> 77af4d6b9913 19 hours ago 1.089 GB
|
||||
committ latest b6fa739cedf5 19 hours ago 1.089 GB
|
||||
<none> <none> 78a85c484f71 19 hours ago 1.089 GB
|
||||
docker latest 30557a29d5ab 20 hours ago 1.089 GB
|
||||
<none> <none> 5ed6274db6ce 24 hours ago 1.089 GB
|
||||
postgres 9 746b819f315e 4 days ago 213.4 MB
|
||||
postgres 9.3 746b819f315e 4 days ago 213.4 MB
|
||||
postgres 9.3.5 746b819f315e 4 days ago 213.4 MB
|
||||
postgres latest 746b819f315e 4 days ago 213.4 MB
|
||||
### List the most recently created images
|
||||
|
||||
### Listing images by name and tag
|
||||
```bash
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
<none> <none> 77af4d6b9913 19 hours ago 1.089 GB
|
||||
committ latest b6fa739cedf5 19 hours ago 1.089 GB
|
||||
<none> <none> 78a85c484f71 19 hours ago 1.089 GB
|
||||
docker latest 30557a29d5ab 20 hours ago 1.089 GB
|
||||
<none> <none> 5ed6274db6ce 24 hours ago 1.089 GB
|
||||
postgres 9 746b819f315e 4 days ago 213.4 MB
|
||||
postgres 9.3 746b819f315e 4 days ago 213.4 MB
|
||||
postgres 9.3.5 746b819f315e 4 days ago 213.4 MB
|
||||
postgres latest 746b819f315e 4 days ago 213.4 MB
|
||||
```
|
||||
|
||||
### List images by name and tag
|
||||
|
||||
The `docker images` command takes an optional `[REPOSITORY[:TAG]]` argument
|
||||
that restricts the list to images that match the argument. If you specify
|
||||
|
@ -74,11 +81,14 @@ given repository.
|
|||
|
||||
For example, to list all images in the "java" repository, run this command :
|
||||
|
||||
$ docker images java
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
java 8 308e519aac60 6 days ago 824.5 MB
|
||||
java 7 493d82594c15 3 months ago 656.3 MB
|
||||
java latest 2711b1d6f3aa 5 months ago 603.9 MB
|
||||
```bash
|
||||
$ docker images java
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
java 8 308e519aac60 6 days ago 824.5 MB
|
||||
java 7 493d82594c15 3 months ago 656.3 MB
|
||||
java latest 2711b1d6f3aa 5 months ago 603.9 MB
|
||||
```
|
||||
|
||||
The `[REPOSITORY[:TAG]]` value must be an "exact match". This means that, for example,
|
||||
`docker images jav` does not match the image `java`.
|
||||
|
@ -87,46 +97,57 @@ If both `REPOSITORY` and `TAG` are provided, only images matching that
|
|||
repository and tag are listed. To find all local images in the "java"
|
||||
repository with tag "8" you can use:
|
||||
|
||||
$ docker images java:8
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
java 8 308e519aac60 6 days ago 824.5 MB
|
||||
```bash
|
||||
$ docker images java:8
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
java 8 308e519aac60 6 days ago 824.5 MB
|
||||
```
|
||||
|
||||
If nothing matches `REPOSITORY[:TAG]`, the list is empty.
|
||||
|
||||
$ docker images java:0
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
```bash
|
||||
$ docker images java:0
|
||||
|
||||
## Listing the full length image IDs
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
```
|
||||
|
||||
$ docker images --no-trunc
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
<none> <none> sha256:77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB
|
||||
committest latest sha256:b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB
|
||||
<none> <none> sha256:78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB
|
||||
docker latest sha256:30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB
|
||||
<none> <none> sha256:0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 1.089 GB
|
||||
<none> <none> sha256:18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 1.082 GB
|
||||
<none> <none> sha256:f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 1.089 GB
|
||||
tryout latest sha256:2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 131.5 MB
|
||||
<none> <none> sha256:5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 1.089 GB
|
||||
### List the full length image IDs
|
||||
|
||||
## Listing image digests
|
||||
```bash
|
||||
$ docker images --no-trunc
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
<none> <none> sha256:77af4d6b9913e693e8d0b4b294fa62ade6054e6b2f1ffb617ac955dd63fb0182 19 hours ago 1.089 GB
|
||||
committest latest sha256:b6fa739cedf5ea12a620a439402b6004d057da800f91c7524b5086a5e4749c9f 19 hours ago 1.089 GB
|
||||
<none> <none> sha256:78a85c484f71509adeaace20e72e941f6bdd2b25b4c75da8693efd9f61a37921 19 hours ago 1.089 GB
|
||||
docker latest sha256:30557a29d5abc51e5f1d5b472e79b7e296f595abcf19fe6b9199dbbc809c6ff4 20 hours ago 1.089 GB
|
||||
<none> <none> sha256:0124422dd9f9cf7ef15c0617cda3931ee68346455441d66ab8bdc5b05e9fdce5 20 hours ago 1.089 GB
|
||||
<none> <none> sha256:18ad6fad340262ac2a636efd98a6d1f0ea775ae3d45240d3418466495a19a81b 22 hours ago 1.082 GB
|
||||
<none> <none> sha256:f9f1e26352f0a3ba6a0ff68167559f64f3e21ff7ada60366e2d44a04befd1d3a 23 hours ago 1.089 GB
|
||||
tryout latest sha256:2629d1fa0b81b222fca63371ca16cbf6a0772d07759ff80e8d1369b926940074 23 hours ago 131.5 MB
|
||||
<none> <none> sha256:5ed6274db6ceb2397844896966ea239290555e74ef307030ebb01ff91b1914df 24 hours ago 1.089 GB
|
||||
```
|
||||
|
||||
### List image digests
|
||||
|
||||
Images that use the v2 or later format have a content-addressable identifier
|
||||
called a `digest`. As long as the input used to generate the image is
|
||||
unchanged, the digest value is predictable. To list image digest values, use
|
||||
the `--digests` flag:
|
||||
|
||||
$ docker images --digests
|
||||
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
|
||||
localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB
|
||||
```bash
|
||||
$ docker images --digests
|
||||
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
|
||||
localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB
|
||||
```
|
||||
|
||||
When pushing or pulling to a 2.0 registry, the `push` or `pull` command
|
||||
output includes the image digest. You can `pull` using a digest value. You can
|
||||
also reference by digest in `create`, `run`, and `rmi` commands, as well as the
|
||||
`FROM` image reference in a Dockerfile.
|
||||
|
||||
## Filtering
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
@ -138,133 +159,147 @@ The currently supported filters are:
|
|||
* before (`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) - filter images created before given id or references
|
||||
* since (`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`) - filter images created since given id or references
|
||||
|
||||
##### Untagged images (dangling)
|
||||
#### Show untagged images (dangling)
|
||||
|
||||
$ docker images --filter "dangling=true"
|
||||
```bash
|
||||
$ docker images --filter "dangling=true"
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
<none> <none> 8abc22fbb042 4 weeks ago 0 B
|
||||
<none> <none> 48e5f45168b9 4 weeks ago 2.489 MB
|
||||
<none> <none> bf747efa0e2f 4 weeks ago 0 B
|
||||
<none> <none> 980fe10e5736 12 weeks ago 101.4 MB
|
||||
<none> <none> dea752e4e117 12 weeks ago 101.4 MB
|
||||
<none> <none> 511136ea3c5a 8 months ago 0 B
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
<none> <none> 8abc22fbb042 4 weeks ago 0 B
|
||||
<none> <none> 48e5f45168b9 4 weeks ago 2.489 MB
|
||||
<none> <none> bf747efa0e2f 4 weeks ago 0 B
|
||||
<none> <none> 980fe10e5736 12 weeks ago 101.4 MB
|
||||
<none> <none> dea752e4e117 12 weeks ago 101.4 MB
|
||||
<none> <none> 511136ea3c5a 8 months ago 0 B
|
||||
```
|
||||
|
||||
This will display untagged images, that are the leaves of the images tree (not
|
||||
This will display untagged images that are the leaves of the images tree (not
|
||||
intermediary layers). These images occur when a new build of an image takes the
|
||||
`repo:tag` away from the image ID, leaving it as `<none>:<none>` or untagged.
|
||||
A warning will be issued if trying to remove an image when a container is presently
|
||||
using it. By having this flag it allows for batch cleanup.
|
||||
|
||||
Ready for use by `docker rmi ...`, like:
|
||||
You can use this in conjunction with `docker rmi ...`:
|
||||
|
||||
$ docker rmi $(docker images -f "dangling=true" -q)
|
||||
```bash
|
||||
$ docker rmi $(docker images -f "dangling=true" -q)
|
||||
|
||||
8abc22fbb042
|
||||
48e5f45168b9
|
||||
bf747efa0e2f
|
||||
980fe10e5736
|
||||
dea752e4e117
|
||||
511136ea3c5a
|
||||
8abc22fbb042
|
||||
48e5f45168b9
|
||||
bf747efa0e2f
|
||||
980fe10e5736
|
||||
dea752e4e117
|
||||
511136ea3c5a
|
||||
```
|
||||
|
||||
NOTE: Docker will warn you if any containers exist that are using these untagged images.
|
||||
> **Note**: Docker warns you if any containers exist that are using these
|
||||
> untagged images.
|
||||
|
||||
|
||||
##### Labeled images
|
||||
#### Show images with a given label
|
||||
|
||||
The `label` filter matches images based on the presence of a `label` alone or a `label` and a
|
||||
value.
|
||||
|
||||
The following filter matches images with the `com.example.version` label regardless of its value.
|
||||
|
||||
$ docker images --filter "label=com.example.version"
|
||||
```bash
|
||||
$ docker images --filter "label=com.example.version"
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
match-me-1 latest eeae25ada2aa About a minute ago 188.3 MB
|
||||
match-me-2 latest dea752e4e117 About a minute ago 188.3 MB
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
match-me-1 latest eeae25ada2aa About a minute ago 188.3 MB
|
||||
match-me-2 latest dea752e4e117 About a minute ago 188.3 MB
|
||||
```
|
||||
|
||||
The following filter matches images with the `com.example.version` label with the `1.0` value.
|
||||
|
||||
$ docker images --filter "label=com.example.version=1.0"
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
match-me latest 511136ea3c5a About a minute ago 188.3 MB
|
||||
```bash
|
||||
$ docker images --filter "label=com.example.version=1.0"
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
match-me latest 511136ea3c5a About a minute ago 188.3 MB
|
||||
```
|
||||
|
||||
In this example, with the `0.1` value, it returns an empty set because no matches were found.
|
||||
|
||||
$ docker images --filter "label=com.example.version=0.1"
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
```bash
|
||||
$ docker images --filter "label=com.example.version=0.1"
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
```
|
||||
|
||||
#### Before
|
||||
#### Filter images by time
|
||||
|
||||
The `before` filter shows only images created before the image with
|
||||
given id or reference. For example, having these images:
|
||||
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
image1 latest eeae25ada2aa 4 minutes ago 188.3 MB
|
||||
image2 latest dea752e4e117 9 minutes ago 188.3 MB
|
||||
image3 latest 511136ea3c5a 25 minutes ago 188.3 MB
|
||||
```bash
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
image1 latest eeae25ada2aa 4 minutes ago 188.3 MB
|
||||
image2 latest dea752e4e117 9 minutes ago 188.3 MB
|
||||
image3 latest 511136ea3c5a 25 minutes ago 188.3 MB
|
||||
```
|
||||
|
||||
Filtering with `before` would give:
|
||||
|
||||
$ docker images --filter "before=image1"
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
image2 latest dea752e4e117 9 minutes ago 188.3 MB
|
||||
image3 latest 511136ea3c5a 25 minutes ago 188.3 MB
|
||||
```bash
|
||||
$ docker images --filter "before=image1"
|
||||
|
||||
#### Since
|
||||
|
||||
The `since` filter shows only images created after the image with
|
||||
given id or reference. For example, having these images:
|
||||
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
image1 latest eeae25ada2aa 4 minutes ago 188.3 MB
|
||||
image2 latest dea752e4e117 9 minutes ago 188.3 MB
|
||||
image3 latest 511136ea3c5a 25 minutes ago 188.3 MB
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
image2 latest dea752e4e117 9 minutes ago 188.3 MB
|
||||
image3 latest 511136ea3c5a 25 minutes ago 188.3 MB
|
||||
```
|
||||
|
||||
Filtering with `since` would give:
|
||||
|
||||
$ docker images --filter "since=image3"
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
image1 latest eeae25ada2aa 4 minutes ago 188.3 MB
|
||||
image2 latest dea752e4e117 9 minutes ago 188.3 MB
|
||||
```bash
|
||||
$ docker images --filter "since=image3"
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
image1 latest eeae25ada2aa 4 minutes ago 188.3 MB
|
||||
image2 latest dea752e4e117 9 minutes ago 188.3 MB
|
||||
```
|
||||
|
||||
#### Reference
|
||||
#### Filter images by reference
|
||||
|
||||
The `reference` filter shows only images whose reference matches
|
||||
the specified pattern.
|
||||
|
||||
```bash
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
busybox latest e02e811dd08f 5 weeks ago 1.09 MB
|
||||
busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB
|
||||
busybox musl 733eb3059dce 5 weeks ago 1.21 MB
|
||||
busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB
|
||||
```
|
||||
|
||||
Filtering with `reference` would give:
|
||||
|
||||
```bash
|
||||
$ docker images --filter=reference='busy*:*libc'
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
busybox uclibc e02e811dd08f 5 weeks ago 1.09 MB
|
||||
busybox glibc 21c16b6787c6 5 weeks ago 4.19 MB
|
||||
```
|
||||
|
||||
## Formatting
|
||||
### Format the output
|
||||
|
||||
The formatting option (`--format`) will pretty print container output
|
||||
using a Go template.
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
Placeholder | Description
|
||||
---- | ----
|
||||
`.ID` | Image ID
|
||||
`.Repository` | Image repository
|
||||
`.Tag` | Image tag
|
||||
`.Digest` | Image digest
|
||||
`.CreatedSince` | Elapsed time since the image was created
|
||||
`.CreatedAt` | Time when the image was created
|
||||
`.Size` | Image disk size
|
||||
| Placeholder | Description|
|
||||
| ---- | ---- |
|
||||
| `.ID` | Image ID |
|
||||
| `.Repository` | Image repository |
|
||||
| `.Tag` | Image tag |
|
||||
| `.Digest` | Image digest |
|
||||
| `.CreatedSince` | Elapsed time since the image was created |
|
||||
| `.CreatedAt` | Time when the image was created |
|
||||
| `.Size` | Image disk size |
|
||||
|
||||
When using the `--format` option, the `image` command will either
|
||||
output the data exactly as the template declares or, when using the
|
||||
|
@ -273,32 +308,38 @@ output the data exactly as the template declares or, when using the
|
|||
The following example uses a template without headers and outputs the
|
||||
`ID` and `Repository` entries separated by a colon for all images:
|
||||
|
||||
{% raw %}
|
||||
$ docker images --format "{{.ID}}: {{.Repository}}"
|
||||
77af4d6b9913: <none>
|
||||
b6fa739cedf5: committ
|
||||
78a85c484f71: <none>
|
||||
30557a29d5ab: docker
|
||||
5ed6274db6ce: <none>
|
||||
746b819f315e: postgres
|
||||
746b819f315e: postgres
|
||||
746b819f315e: postgres
|
||||
746b819f315e: postgres
|
||||
{% endraw %}
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker images --format "{{.ID}}: {{.Repository}}"
|
||||
|
||||
77af4d6b9913: <none>
|
||||
b6fa739cedf5: committ
|
||||
78a85c484f71: <none>
|
||||
30557a29d5ab: docker
|
||||
5ed6274db6ce: <none>
|
||||
746b819f315e: postgres
|
||||
746b819f315e: postgres
|
||||
746b819f315e: postgres
|
||||
746b819f315e: postgres
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
To list all images with their repository and tag in a table format you
|
||||
can use:
|
||||
|
||||
{% raw %}
|
||||
$ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
|
||||
IMAGE ID REPOSITORY TAG
|
||||
77af4d6b9913 <none> <none>
|
||||
b6fa739cedf5 committ latest
|
||||
78a85c484f71 <none> <none>
|
||||
30557a29d5ab docker latest
|
||||
5ed6274db6ce <none> <none>
|
||||
746b819f315e postgres 9
|
||||
746b819f315e postgres 9.3
|
||||
746b819f315e postgres 9.3.5
|
||||
746b819f315e postgres latest
|
||||
{% endraw %}
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
|
||||
|
||||
IMAGE ID REPOSITORY TAG
|
||||
77af4d6b9913 <none> <none>
|
||||
b6fa739cedf5 committ latest
|
||||
78a85c484f71 <none> <none>
|
||||
30557a29d5ab docker latest
|
||||
5ed6274db6ce <none> <none>
|
||||
746b819f315e postgres 9
|
||||
746b819f315e postgres 9.3
|
||||
746b819f315e postgres 9.3.5
|
||||
746b819f315e postgres latest
|
||||
{% endraw %}
|
||||
```
|
||||
|
|
|
@ -26,6 +26,8 @@ Options:
|
|||
-m, --message string Set commit message for imported image
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
You can specify a `URL` or `-` (dash) to take data directly from `STDIN`. The
|
||||
`URL` can point to an archive (.tar, .tar.gz, .tgz, .bzip, .tar.xz, or .txz)
|
||||
containing a filesystem or to an individual file on the Docker host. If you
|
||||
|
@ -41,33 +43,45 @@ Supported `Dockerfile` instructions:
|
|||
|
||||
## Examples
|
||||
|
||||
**Import from a remote location:**
|
||||
### Import from a remote location
|
||||
|
||||
This will create a new untagged image.
|
||||
|
||||
$ docker import http://example.com/exampleimage.tgz
|
||||
```bash
|
||||
$ docker import http://example.com/exampleimage.tgz
|
||||
```
|
||||
|
||||
**Import from a local file:**
|
||||
### Import from a local file
|
||||
|
||||
Import to docker via pipe and `STDIN`.
|
||||
- Import to docker via pipe and `STDIN`.
|
||||
|
||||
$ cat exampleimage.tgz | docker import - exampleimagelocal:new
|
||||
```bash
|
||||
$ cat exampleimage.tgz | docker import - exampleimagelocal:new
|
||||
```
|
||||
|
||||
Import with a commit message.
|
||||
- Import with a commit message.
|
||||
|
||||
$ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new
|
||||
```bash
|
||||
$ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new
|
||||
```
|
||||
|
||||
Import to docker from a local archive.
|
||||
- Import to docker from a local archive.
|
||||
|
||||
```bash
|
||||
$ docker import /path/to/exampleimage.tgz
|
||||
```
|
||||
|
||||
**Import from a local directory:**
|
||||
### Import from a local directory
|
||||
|
||||
$ sudo tar -c . | docker import - exampleimagedir
|
||||
```bash
|
||||
$ sudo tar -c . | docker import - exampleimagedir
|
||||
```
|
||||
|
||||
**Import from a local directory with new configurations:**
|
||||
### Import from a local directory with new configurations
|
||||
|
||||
$ sudo tar -c . | docker import --change "ENV DEBUG true" - exampleimagedir
|
||||
```bash
|
||||
$ sudo tar -c . | docker import --change "ENV DEBUG true" - exampleimagedir
|
||||
```
|
||||
|
||||
Note the `sudo` in this example – you must preserve
|
||||
the ownership of the files (especially root ownership) during the
|
||||
|
|
|
@ -25,6 +25,8 @@ You start the Docker daemon with the command line. How you start the daemon
|
|||
affects your Docker containers. For that reason you should also make sure to
|
||||
read the [`dockerd`](dockerd.md) reference page.
|
||||
|
||||
## Commands by object
|
||||
|
||||
### Docker management commands
|
||||
|
||||
| Command | Description |
|
||||
|
@ -45,6 +47,7 @@ read the [`dockerd`](dockerd.md) reference page.
|
|||
| [images](images.md) | List images |
|
||||
| [import](import.md) | Import the contents from a tarball to create a filesystem image |
|
||||
| [load](load.md) | Load an image from a tar archive or STDIN |
|
||||
| [image prune](image_prune.md) | Remove unused images |
|
||||
| [rmi](rmi.md) | Remove one or more images |
|
||||
| [save](save.md) | Save images to a tar archive |
|
||||
| [tag](tag.md) | Tag an image into a repository |
|
||||
|
@ -54,6 +57,7 @@ read the [`dockerd`](dockerd.md) reference page.
|
|||
| Command | Description |
|
||||
|:--------|:-------------------------------------------------------------------|
|
||||
| [attach](attach.md) | Attach to a running container |
|
||||
| [container prune](container_prune.md) | Remove all stopped containers |
|
||||
| [cp](cp.md) | Copy files/folders from a container to a HOSTDIR or to STDOUT |
|
||||
| [create](create.md) | Create a new container |
|
||||
| [diff](diff.md) | Inspect changes on a container's filesystem |
|
||||
|
@ -96,9 +100,9 @@ read the [`dockerd`](dockerd.md) reference page.
|
|||
| [network disconnect](network_disconnect.md) | Disconnect a container from a network |
|
||||
| [network inspect](network_inspect.md) | Display information about a network |
|
||||
| [network ls](network_ls.md) | Lists all the networks the Engine `daemon` knows about |
|
||||
| [network prune](network_prune.md) | Remove all unused networks |
|
||||
| [network rm](network_rm.md) | Removes one or more networks |
|
||||
|
||||
|
||||
### Shared data volume commands
|
||||
|
||||
| Command | Description |
|
||||
|
@ -109,28 +113,29 @@ read the [`dockerd`](dockerd.md) reference page.
|
|||
| [volume prune](volume_prune.md) | Remove all unused volumes |
|
||||
| [volume rm](volume_rm.md) | Remove one or more volumes |
|
||||
|
||||
|
||||
### Swarm node commands
|
||||
|
||||
| Command | Description |
|
||||
|:--------|:-------------------------------------------------------------------|
|
||||
| [node promote](node_promote.md) | Promote a node that is pending a promotion to manager |
|
||||
| [node demote](node_demote.md) | Demotes an existing manager so that it is no longer a manager |
|
||||
| [node inspect](node_inspect.md) | Inspect a node in the swarm |
|
||||
| [node update](node_update.md) | Update attributes for a node |
|
||||
| [node ps](node_ps.md) | List tasks running on one or more nodes |
|
||||
| [node ls](node_ls.md) | List nodes in the swarm |
|
||||
| [node promote](node_promote.md) | Promote a node that is pending a promotion to manager |
|
||||
| [node ps](node_ps.md) | List tasks running on one or more nodes |
|
||||
| [node rm](node_rm.md) | Remove one or more nodes from the swarm |
|
||||
| [node update](node_update.md) | Update attributes for a node |
|
||||
|
||||
### Swarm swarm commands
|
||||
### Swarm management commands
|
||||
|
||||
| Command | Description |
|
||||
|:--------|:-------------------------------------------------------------------|
|
||||
| [swarm init](swarm_init.md) | Initialize a swarm |
|
||||
| [swarm join](swarm_join.md) | Join a swarm as a manager node or worker node |
|
||||
| [swarm leave](swarm_leave.md) | Remove the current node from the swarm |
|
||||
| [swarm update](swarm_update.md) | Update attributes of a swarm |
|
||||
| [swarm join-token](swarm_join_token.md) | Display or rotate join tokens |
|
||||
| [swarm unlock](swarm_unlock.md) | Unlock swarm |
|
||||
| [swarm unlock-key](swarm_unlock_key.md) | Manage the unlock key |
|
||||
| [swarm update](swarm_update.md) | Update attributes of a swarm |
|
||||
|
||||
### Swarm service commands
|
||||
|
||||
|
@ -138,10 +143,11 @@ read the [`dockerd`](dockerd.md) reference page.
|
|||
|:--------|:-------------------------------------------------------------------|
|
||||
| [service create](service_create.md) | Create a new service |
|
||||
| [service inspect](service_inspect.md) | Inspect a service |
|
||||
| [service logs](service_logs.md) | Fetch the logs of a service |
|
||||
| [service ls](service_ls.md) | List services in the swarm |
|
||||
| [service ps](service_ps.md) | List the tasks of a service |
|
||||
| [service rm](service_rm.md) | Remove a service from the swarm |
|
||||
| [service scale](service_scale.md) | Set the number of replicas for the desired state of the service |
|
||||
| [service ps](service_ps.md) | List the tasks of a service |
|
||||
| [service update](service_update.md) | Update the attributes of a service |
|
||||
|
||||
### Swarm secret commands
|
||||
|
|
|
@ -25,6 +25,8 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
This command displays system wide information regarding the Docker installation.
|
||||
Information displayed includes the kernel version, number of containers and images.
|
||||
The number of images shown is the number of unique images. The same image tagged
|
||||
|
@ -43,182 +45,201 @@ meta data regarding those images are stored. When run for the first time Docker
|
|||
allocates a certain amount of data space and meta data space from the space
|
||||
available on the volume where `/var/lib/docker` is mounted.
|
||||
|
||||
# Examples
|
||||
## Examples
|
||||
|
||||
## Display Docker system information
|
||||
### Show output
|
||||
|
||||
The example below shows the output for a daemon running on Red Hat Enterprise Linux,
|
||||
using the `devicemapper` storage driver. As can be seen in the output, additional
|
||||
information about the `devicemapper` storage driver is shown:
|
||||
|
||||
```bash
|
||||
$ docker info
|
||||
|
||||
Containers: 14
|
||||
Running: 3
|
||||
Paused: 1
|
||||
Stopped: 10
|
||||
Images: 52
|
||||
Server Version: 1.10.3
|
||||
Storage Driver: devicemapper
|
||||
Pool Name: docker-202:2-25583803-pool
|
||||
Pool Blocksize: 65.54 kB
|
||||
Base Device Size: 10.74 GB
|
||||
Backing Filesystem: xfs
|
||||
Data file: /dev/loop0
|
||||
Metadata file: /dev/loop1
|
||||
Data Space Used: 1.68 GB
|
||||
Data Space Total: 107.4 GB
|
||||
Data Space Available: 7.548 GB
|
||||
Metadata Space Used: 2.322 MB
|
||||
Metadata Space Total: 2.147 GB
|
||||
Metadata Space Available: 2.145 GB
|
||||
Udev Sync Supported: true
|
||||
Deferred Removal Enabled: false
|
||||
Deferred Deletion Enabled: false
|
||||
Deferred Deleted Device Count: 0
|
||||
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
|
||||
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
|
||||
Library Version: 1.02.107-RHEL7 (2015-12-01)
|
||||
Execution Driver: native-0.2
|
||||
Logging Driver: json-file
|
||||
Plugins:
|
||||
Volume: local
|
||||
Network: null host bridge
|
||||
Kernel Version: 3.10.0-327.el7.x86_64
|
||||
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
|
||||
OSType: linux
|
||||
Architecture: x86_64
|
||||
CPUs: 1
|
||||
Total Memory: 991.7 MiB
|
||||
Name: ip-172-30-0-91.ec2.internal
|
||||
ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S
|
||||
Docker Root Dir: /var/lib/docker
|
||||
Debug mode (client): false
|
||||
Debug mode (server): false
|
||||
Username: gordontheturtle
|
||||
Registry: https://index.docker.io/v1/
|
||||
Insecure registries:
|
||||
myinsecurehost:5000
|
||||
127.0.0.0/8
|
||||
```
|
||||
|
||||
### Show debugging output
|
||||
|
||||
Here is a sample output for a daemon running on Ubuntu, using the overlay2
|
||||
storage driver and a node that is part of a 2-node swarm:
|
||||
|
||||
$ docker -D info
|
||||
Containers: 14
|
||||
Running: 3
|
||||
Paused: 1
|
||||
Stopped: 10
|
||||
Images: 52
|
||||
Server Version: 1.13.0
|
||||
Storage Driver: overlay2
|
||||
Backing Filesystem: extfs
|
||||
Supports d_type: true
|
||||
Native Overlay Diff: false
|
||||
Logging Driver: json-file
|
||||
Cgroup Driver: cgroupfs
|
||||
Plugins:
|
||||
Volume: local
|
||||
Network: bridge host macvlan null overlay
|
||||
Swarm: active
|
||||
NodeID: rdjq45w1op418waxlairloqbm
|
||||
Is Manager: true
|
||||
ClusterID: te8kdyw33n36fqiz74bfjeixd
|
||||
Managers: 1
|
||||
Nodes: 2
|
||||
Orchestration:
|
||||
Task History Retention Limit: 5
|
||||
Raft:
|
||||
Snapshot Interval: 10000
|
||||
Number of Old Snapshots to Retain: 0
|
||||
Heartbeat Tick: 1
|
||||
Election Tick: 3
|
||||
Dispatcher:
|
||||
Heartbeat Period: 5 seconds
|
||||
CA Configuration:
|
||||
Expiry Duration: 3 months
|
||||
Node Address: 172.16.66.128 172.16.66.129
|
||||
Manager Addresses:
|
||||
172.16.66.128:2477
|
||||
Runtimes: runc
|
||||
Default Runtime: runc
|
||||
Init Binary: docker-init
|
||||
containerd version: 8517738ba4b82aff5662c97ca4627e7e4d03b531
|
||||
runc version: ac031b5bf1cc92239461125f4c1ffb760522bbf2
|
||||
init version: N/A (expected: v0.13.0)
|
||||
Security Options:
|
||||
apparmor
|
||||
seccomp
|
||||
Profile: default
|
||||
Kernel Version: 4.4.0-31-generic
|
||||
Operating System: Ubuntu 16.04.1 LTS
|
||||
OSType: linux
|
||||
Architecture: x86_64
|
||||
CPUs: 2
|
||||
Total Memory: 1.937 GiB
|
||||
Name: ubuntu
|
||||
ID: H52R:7ZR6:EIIA:76JG:ORIY:BVKF:GSFU:HNPG:B5MK:APSC:SZ3Q:N326
|
||||
Docker Root Dir: /var/lib/docker
|
||||
Debug Mode (client): true
|
||||
Debug Mode (server): true
|
||||
File Descriptors: 30
|
||||
Goroutines: 123
|
||||
System Time: 2016-11-12T17:24:37.955404361-08:00
|
||||
EventsListeners: 0
|
||||
Http Proxy: http://test:test@proxy.example.com:8080
|
||||
Https Proxy: https://test:test@proxy.example.com:8080
|
||||
No Proxy: localhost,127.0.0.1,docker-registry.somecorporation.com
|
||||
Registry: https://index.docker.io/v1/
|
||||
WARNING: No swap limit support
|
||||
Labels:
|
||||
storage=ssd
|
||||
staging=true
|
||||
Experimental: false
|
||||
Insecure Registries:
|
||||
127.0.0.0/8
|
||||
Registry Mirrors:
|
||||
http://192.168.1.2/
|
||||
http://registry-mirror.example.com:5000/
|
||||
Live Restore Enabled: false
|
||||
```bash
|
||||
$ docker -D info
|
||||
|
||||
The global `-D` option tells all `docker` commands to output debug information.
|
||||
Containers: 14
|
||||
Running: 3
|
||||
Paused: 1
|
||||
Stopped: 10
|
||||
Images: 52
|
||||
Server Version: 1.13.0
|
||||
Storage Driver: overlay2
|
||||
Backing Filesystem: extfs
|
||||
Supports d_type: true
|
||||
Native Overlay Diff: false
|
||||
Logging Driver: json-file
|
||||
Cgroup Driver: cgroupfs
|
||||
Plugins:
|
||||
Volume: local
|
||||
Network: bridge host macvlan null overlay
|
||||
Swarm: active
|
||||
NodeID: rdjq45w1op418waxlairloqbm
|
||||
Is Manager: true
|
||||
ClusterID: te8kdyw33n36fqiz74bfjeixd
|
||||
Managers: 1
|
||||
Nodes: 2
|
||||
Orchestration:
|
||||
Task History Retention Limit: 5
|
||||
Raft:
|
||||
Snapshot Interval: 10000
|
||||
Number of Old Snapshots to Retain: 0
|
||||
Heartbeat Tick: 1
|
||||
Election Tick: 3
|
||||
Dispatcher:
|
||||
Heartbeat Period: 5 seconds
|
||||
CA Configuration:
|
||||
Expiry Duration: 3 months
|
||||
Node Address: 172.16.66.128 172.16.66.129
|
||||
Manager Addresses:
|
||||
172.16.66.128:2477
|
||||
Runtimes: runc
|
||||
Default Runtime: runc
|
||||
Init Binary: docker-init
|
||||
containerd version: 8517738ba4b82aff5662c97ca4627e7e4d03b531
|
||||
runc version: ac031b5bf1cc92239461125f4c1ffb760522bbf2
|
||||
init version: N/A (expected: v0.13.0)
|
||||
Security Options:
|
||||
apparmor
|
||||
seccomp
|
||||
Profile: default
|
||||
Kernel Version: 4.4.0-31-generic
|
||||
Operating System: Ubuntu 16.04.1 LTS
|
||||
OSType: linux
|
||||
Architecture: x86_64
|
||||
CPUs: 2
|
||||
Total Memory: 1.937 GiB
|
||||
Name: ubuntu
|
||||
ID: H52R:7ZR6:EIIA:76JG:ORIY:BVKF:GSFU:HNPG:B5MK:APSC:SZ3Q:N326
|
||||
Docker Root Dir: /var/lib/docker
|
||||
Debug Mode (client): true
|
||||
Debug Mode (server): true
|
||||
File Descriptors: 30
|
||||
Goroutines: 123
|
||||
System Time: 2016-11-12T17:24:37.955404361-08:00
|
||||
EventsListeners: 0
|
||||
Http Proxy: http://test:test@proxy.example.com:8080
|
||||
Https Proxy: https://test:test@proxy.example.com:8080
|
||||
No Proxy: localhost,127.0.0.1,docker-registry.somecorporation.com
|
||||
Registry: https://index.docker.io/v1/
|
||||
WARNING: No swap limit support
|
||||
Labels:
|
||||
storage=ssd
|
||||
staging=true
|
||||
Experimental: false
|
||||
Insecure Registries:
|
||||
127.0.0.0/8
|
||||
Registry Mirrors:
|
||||
http://192.168.1.2/
|
||||
http://registry-mirror.example.com:5000/
|
||||
Live Restore Enabled: false
|
||||
```
|
||||
|
||||
The example below shows the output for a daemon running on Red Hat Enterprise Linux,
|
||||
using the devicemapper storage driver. As can be seen in the output, additional
|
||||
information about the devicemapper storage driver is shown:
|
||||
The global `-D` option causes all `docker` commands to output debug information.
|
||||
|
||||
$ docker info
|
||||
Containers: 14
|
||||
Running: 3
|
||||
Paused: 1
|
||||
Stopped: 10
|
||||
Images: 52
|
||||
Server Version: 1.10.3
|
||||
Storage Driver: devicemapper
|
||||
Pool Name: docker-202:2-25583803-pool
|
||||
Pool Blocksize: 65.54 kB
|
||||
Base Device Size: 10.74 GB
|
||||
Backing Filesystem: xfs
|
||||
Data file: /dev/loop0
|
||||
Metadata file: /dev/loop1
|
||||
Data Space Used: 1.68 GB
|
||||
Data Space Total: 107.4 GB
|
||||
Data Space Available: 7.548 GB
|
||||
Metadata Space Used: 2.322 MB
|
||||
Metadata Space Total: 2.147 GB
|
||||
Metadata Space Available: 2.145 GB
|
||||
Udev Sync Supported: true
|
||||
Deferred Removal Enabled: false
|
||||
Deferred Deletion Enabled: false
|
||||
Deferred Deleted Device Count: 0
|
||||
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
|
||||
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
|
||||
Library Version: 1.02.107-RHEL7 (2015-12-01)
|
||||
Execution Driver: native-0.2
|
||||
Logging Driver: json-file
|
||||
Plugins:
|
||||
Volume: local
|
||||
Network: null host bridge
|
||||
Kernel Version: 3.10.0-327.el7.x86_64
|
||||
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
|
||||
OSType: linux
|
||||
Architecture: x86_64
|
||||
CPUs: 1
|
||||
Total Memory: 991.7 MiB
|
||||
Name: ip-172-30-0-91.ec2.internal
|
||||
ID: I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S
|
||||
Docker Root Dir: /var/lib/docker
|
||||
Debug mode (client): false
|
||||
Debug mode (server): false
|
||||
Username: gordontheturtle
|
||||
Registry: https://index.docker.io/v1/
|
||||
Insecure registries:
|
||||
myinsecurehost:5000
|
||||
127.0.0.0/8
|
||||
### Format the output
|
||||
|
||||
You can also specify the output format:
|
||||
|
||||
$ docker info --format '{{json .}}'
|
||||
{"ID":"I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S","Containers":14, ...}
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker info --format '{{json .}}'
|
||||
|
||||
{"ID":"I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S","Containers":14, ...}
|
||||
```
|
||||
|
||||
### Run `docker info` on Windows
|
||||
|
||||
Here is a sample output for a daemon running on Windows Server 2016:
|
||||
|
||||
E:\docker>docker info
|
||||
Containers: 1
|
||||
Running: 0
|
||||
Paused: 0
|
||||
Stopped: 1
|
||||
Images: 17
|
||||
Server Version: 1.13.0
|
||||
Storage Driver: windowsfilter
|
||||
Windows:
|
||||
Logging Driver: json-file
|
||||
Plugins:
|
||||
Volume: local
|
||||
Network: nat null overlay
|
||||
Swarm: inactive
|
||||
Default Isolation: process
|
||||
Kernel Version: 10.0 14393 (14393.206.amd64fre.rs1_release.160912-1937)
|
||||
Operating System: Windows Server 2016 Datacenter
|
||||
OSType: windows
|
||||
Architecture: x86_64
|
||||
CPUs: 8
|
||||
Total Memory: 3.999 GiB
|
||||
Name: WIN-V0V70C0LU5P
|
||||
ID: NYMS:B5VK:UMSL:FVDZ:EWB5:FKVK:LPFL:FJMQ:H6FT:BZJ6:L2TD:XH62
|
||||
Docker Root Dir: C:\control
|
||||
Debug Mode (client): false
|
||||
Debug Mode (server): false
|
||||
Registry: https://index.docker.io/v1/
|
||||
Insecure Registries:
|
||||
127.0.0.0/8
|
||||
Registry Mirrors:
|
||||
http://192.168.1.2/
|
||||
http://registry-mirror.example.com:5000/
|
||||
Live Restore Enabled: false
|
||||
```none
|
||||
E:\docker>docker info
|
||||
|
||||
Containers: 1
|
||||
Running: 0
|
||||
Paused: 0
|
||||
Stopped: 1
|
||||
Images: 17
|
||||
Server Version: 1.13.0
|
||||
Storage Driver: windowsfilter
|
||||
Windows:
|
||||
Logging Driver: json-file
|
||||
Plugins:
|
||||
Volume: local
|
||||
Network: nat null overlay
|
||||
Swarm: inactive
|
||||
Default Isolation: process
|
||||
Kernel Version: 10.0 14393 (14393.206.amd64fre.rs1_release.160912-1937)
|
||||
Operating System: Windows Server 2016 Datacenter
|
||||
OSType: windows
|
||||
Architecture: x86_64
|
||||
CPUs: 8
|
||||
Total Memory: 3.999 GiB
|
||||
Name: WIN-V0V70C0LU5P
|
||||
ID: NYMS:B5VK:UMSL:FVDZ:EWB5:FKVK:LPFL:FJMQ:H6FT:BZJ6:L2TD:XH62
|
||||
Docker Root Dir: C:\control
|
||||
Debug Mode (client): false
|
||||
Debug Mode (server): false
|
||||
Registry: https://index.docker.io/v1/
|
||||
Insecure Registries:
|
||||
127.0.0.0/8
|
||||
Registry Mirrors:
|
||||
http://192.168.1.2/
|
||||
http://registry-mirror.example.com:5000/
|
||||
Live Restore Enabled: false
|
||||
```
|
||||
|
|
|
@ -28,7 +28,9 @@ Options:
|
|||
--type Return JSON for specified type
|
||||
```
|
||||
|
||||
By default, this will render all results in a JSON array. If the container and
|
||||
## Description
|
||||
|
||||
By default, `docker inspect` will render all results in a JSON array. If the container and
|
||||
image have the same name, this will return container JSON for unspecified type.
|
||||
If a format is specified, the given template will be executed for each result.
|
||||
|
||||
|
@ -37,46 +39,53 @@ describes all the details of the format.
|
|||
|
||||
## Examples
|
||||
|
||||
**Get an instance's IP address:**
|
||||
### Get an instance's IP address
|
||||
|
||||
For the most part, you can pick out any field from the JSON in a fairly
|
||||
straightforward manner.
|
||||
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
**Get an instance's MAC address:**
|
||||
### Get an instance's MAC address
|
||||
|
||||
For the most part, you can pick out any field from the JSON in a fairly
|
||||
straightforward manner.
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
### Get an instance's log path
|
||||
|
||||
**Get an instance's log path:**
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
### Get an instance's image name
|
||||
|
||||
**Get a Task's image name:**
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{.Container.Spec.Image}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{.Container.Spec.Image}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
### List all port bindings
|
||||
|
||||
**List all port bindings:**
|
||||
|
||||
One can loop over arrays and maps in the results to produce simple text
|
||||
You can loop over arrays and maps in the results to produce simple text
|
||||
output:
|
||||
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
**Find a specific port mapping:**
|
||||
### Find a specific port mapping
|
||||
|
||||
The `.Field` syntax doesn't work when the field name begins with a
|
||||
number, but the template language's `index` function does. The
|
||||
|
@ -86,17 +95,21 @@ numeric public port, you use `index` to find the specific port map, and
|
|||
then `index` 0 contains the first object inside of that. Then we ask for
|
||||
the `HostPort` field to get the public address.
|
||||
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
**Get a subsection in JSON format:**
|
||||
### Get a subsection in JSON format
|
||||
|
||||
If you request a field which is itself a structure containing other
|
||||
fields, by default you get a Go-style dump of the inner values.
|
||||
Docker adds a template function, `json`, which can be applied to get
|
||||
results in JSON format.
|
||||
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{json .Config}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker inspect --format='{{json .Config}}' $INSTANCE_ID
|
||||
{% endraw %}
|
||||
```
|
||||
|
|
|
@ -25,10 +25,11 @@ Options:
|
|||
-s, --signal string Signal to send to the container (default "KILL")
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The main process inside the container will be sent `SIGKILL`, or any
|
||||
signal specified with option `--signal`.
|
||||
|
||||
> **Note:**
|
||||
> `ENTRYPOINT` and `CMD` in the *shell* form run as a subcommand of `/bin/sh -c`,
|
||||
> which does not pass signals. This means that the executable is not the container’s PID 1
|
||||
> and does not receive Unix signals.
|
||||
> **Note**: `ENTRYPOINT` and `CMD` in the *shell* form run as a subcommand of
|
||||
> `/bin/sh -c`, which does not pass signals. This means that the executable is
|
||||
> not the container’s PID 1 and does not receive Unix signals.
|
||||
|
|
|
@ -26,28 +26,37 @@ Options:
|
|||
The tarball may be compressed with gzip, bzip, or xz
|
||||
-q, --quiet Suppress the load output but still outputs the imported images
|
||||
```
|
||||
## Descriptino
|
||||
|
||||
Loads a tarred repository from a file or the standard input stream.
|
||||
Restores both images and tags.
|
||||
`docker load` loads a tarred repository from a file or the standard input stream.
|
||||
It restores both images and tags.
|
||||
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
$ docker load < busybox.tar.gz
|
||||
# […]
|
||||
Loaded image: busybox:latest
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
busybox latest 769b9341d937 7 weeks ago 2.489 MB
|
||||
$ docker load --input fedora.tar
|
||||
# […]
|
||||
Loaded image: fedora:rawhide
|
||||
# […]
|
||||
Loaded image: fedora:20
|
||||
# […]
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
busybox latest 769b9341d937 7 weeks ago 2.489 MB
|
||||
fedora rawhide 0d20aec6529d 7 weeks ago 387 MB
|
||||
fedora 20 58394af37342 7 weeks ago 385.5 MB
|
||||
fedora heisenbug 58394af37342 7 weeks ago 385.5 MB
|
||||
fedora latest 58394af37342 7 weeks ago 385.5 MB
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
|
||||
$ docker load < busybox.tar.gz
|
||||
|
||||
Loaded image: busybox:latest
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
busybox latest 769b9341d937 7 weeks ago 2.489 MB
|
||||
|
||||
$ docker load --input fedora.tar
|
||||
|
||||
Loaded image: fedora:rawhide
|
||||
|
||||
Loaded image: fedora:20
|
||||
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
busybox latest 769b9341d937 7 weeks ago 2.489 MB
|
||||
fedora rawhide 0d20aec6529d 7 weeks ago 387 MB
|
||||
fedora 20 58394af37342 7 weeks ago 385.5 MB
|
||||
fedora heisenbug 58394af37342 7 weeks ago 385.5 MB
|
||||
fedora latest 58394af37342 7 weeks ago 385.5 MB
|
||||
```
|
||||
|
|
|
@ -27,12 +27,20 @@ Options:
|
|||
-u, --username string Username
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Login to a registry.
|
||||
|
||||
### Login to a self-hosted registry
|
||||
|
||||
If you want to login to a self-hosted registry you can specify this by
|
||||
adding the server name.
|
||||
|
||||
example:
|
||||
$ docker login localhost:8080
|
||||
```bash
|
||||
$ docker login localhost:8080
|
||||
```
|
||||
|
||||
### Privileged user requirement
|
||||
|
||||
`docker login` requires user to use `sudo` or be `root`, except when:
|
||||
|
||||
|
@ -43,7 +51,7 @@ You can log into any public or private repository for which you have
|
|||
credentials. When you log in, the command stores encoded credentials in
|
||||
`$HOME/.docker/config.json` on Linux or `%USERPROFILE%/.docker/config.json` on Windows.
|
||||
|
||||
## Credentials store
|
||||
### Credentials store
|
||||
|
||||
The Docker Engine can keep user credentials in an external credentials store,
|
||||
such as the native keychain of the operating system. Using an external store
|
||||
|
@ -60,8 +68,6 @@ you can download them from:
|
|||
- Apple macOS keychain: https://github.com/docker/docker-credential-helpers/releases
|
||||
- Microsoft Windows Credential Manager: https://github.com/docker/docker-credential-helpers/releases
|
||||
|
||||
### Usage
|
||||
|
||||
You need to specify the credentials store in `$HOME/.docker/config.json`
|
||||
to tell the docker engine to use it:
|
||||
|
||||
|
@ -74,7 +80,7 @@ to tell the docker engine to use it:
|
|||
If you are currently logged in, run `docker logout` to remove
|
||||
the credentials from the file and run `docker login` again.
|
||||
|
||||
### Protocol
|
||||
### Credential helper protocol
|
||||
|
||||
Credential helpers can be any program or script that follows a very simple protocol.
|
||||
This protocol is heavily inspired by Git, but it differs in the information shared.
|
||||
|
@ -120,3 +126,31 @@ an example of that payload: `https://index.docker.io/v1`.
|
|||
|
||||
The `erase` command can write error messages to `STDOUT` that the docker engine
|
||||
will show if there was an issue.
|
||||
|
||||
### Credential helpers
|
||||
|
||||
Credential helpers are similar to the credential store above, but act as the
|
||||
designated programs to handle credentials for *specific registries*. The default
|
||||
credential store (`credsStore` or the config file itself) will not be used for
|
||||
operations concerning credentials of the specified registries.
|
||||
|
||||
### Logging out
|
||||
|
||||
If you are currently logged in, run `docker logout` to remove
|
||||
the credentials from the default store.
|
||||
|
||||
Credential helpers are specified in a similar way to `credsStore`, but
|
||||
allow for multiple helpers to be configured at a time. Keys specify the
|
||||
registry domain, and values specify the suffix of the program to use
|
||||
(i.e. everything after `docker-credential-`).
|
||||
For example:
|
||||
|
||||
```json
|
||||
{
|
||||
"credHelpers": {
|
||||
"registry.example.com": "registryhelper",
|
||||
"awesomereg.example.org": "hip-star",
|
||||
"unicorn.example.io": "vcbait"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
|
@ -25,6 +25,8 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
For example:
|
||||
## Examples
|
||||
|
||||
$ docker logout localhost:8080
|
||||
```bash
|
||||
$ docker logout localhost:8080
|
||||
```
|
||||
|
|
|
@ -24,11 +24,13 @@ Options:
|
|||
--details Show extra details provided to logs
|
||||
-f, --follow Follow log output
|
||||
--help Print usage
|
||||
--since string Show logs since timestamp
|
||||
--since string Show logs since timestamp (e.g. 2013-01-02T13:23:37) or relative (e.g. 42m for 42 minutes)
|
||||
--tail string Number of lines to show from the end of the logs (default "all")
|
||||
-t, --timestamps Show timestamps
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `docker logs` command batch-retrieves logs present at the time of execution.
|
||||
|
||||
> **Note**: this command is only functional for containers that are started with
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
---
|
||||
title: "Command line reference"
|
||||
description: "Docker's CLI command description and usage"
|
||||
keywords: "Docker, Docker documentation, CLI, command line"
|
||||
identifier: "smn_cli"
|
||||
---
|
||||
|
||||
<!-- This file is maintained within the docker/docker Github
|
||||
repository at https://github.com/docker/docker/. Make all
|
||||
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.
|
||||
-->
|
||||
|
||||
# The Docker commands
|
||||
|
||||
This section contains reference information on using Docker's command line
|
||||
client. Each command has a reference page along with samples. If you are
|
||||
unfamiliar with the command line, you should start by reading about how to
|
||||
[Use the Docker command line](cli.md).
|
||||
|
||||
You start the Docker daemon with the command line. How you start the daemon
|
||||
affects your Docker containers. For that reason you should also make sure to
|
||||
read the [`dockerd`](dockerd.md) reference page.
|
||||
|
||||
For a list of Docker commands see [Command line reference guide](index.md).
|
|
@ -29,38 +29,55 @@ Options:
|
|||
--link-local-ip value Add a link-local address for the container (default [])
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Connects a container to a network. You can connect a container by name
|
||||
or by ID. Once connected, the container can communicate with other containers in
|
||||
the same network.
|
||||
|
||||
## Examples
|
||||
|
||||
### Connect a running container to a network
|
||||
|
||||
```bash
|
||||
$ docker network connect multi-host-network container1
|
||||
```
|
||||
|
||||
### Connect a container to a network when it starts
|
||||
|
||||
You can also use the `docker run --network=<network-name>` option to start a container and immediately connect it to a network.
|
||||
|
||||
```bash
|
||||
$ docker run -itd --network=multi-host-network busybox
|
||||
```
|
||||
|
||||
### Specify the IP address a container will use on a given network
|
||||
|
||||
You can specify the IP address you want to be assigned to the container's interface.
|
||||
|
||||
```bash
|
||||
$ docker network connect --ip 10.10.36.122 multi-host-network container2
|
||||
```
|
||||
|
||||
### Use the legacy `--link` option
|
||||
|
||||
You can use `--link` option to link another container with a preferred alias
|
||||
|
||||
```bash
|
||||
$ docker network connect --link container1:c1 multi-host-network container2
|
||||
```
|
||||
|
||||
### Create a network alias for a container
|
||||
|
||||
`--alias` option can be used to resolve the container by another name in the network
|
||||
being connected to.
|
||||
|
||||
```bash
|
||||
$ docker network connect --alias db --alias mysql multi-host-network container2
|
||||
```
|
||||
|
||||
### Network implications of stopping, pausing, or restarting containers
|
||||
|
||||
You can pause, restart, and stop containers that are connected to a network.
|
||||
A container connects to its configured networks when it runs.
|
||||
|
||||
|
@ -88,7 +105,7 @@ network but launched from different Engines can also communicate in this way.
|
|||
|
||||
You can connect a container to one or more networks. The networks need not be the same type. For example, you can connect a single container bridge and overlay networks.
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [network inspect](network_inspect.md)
|
||||
* [network create](network_create.md)
|
||||
|
|
|
@ -38,6 +38,8 @@ Options:
|
|||
network segment (default [])
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Creates a new network. The `DRIVER` accepts `bridge` or `overlay` which are the
|
||||
built-in network drivers. If you have installed a third party or your own custom
|
||||
network driver you can specify that `DRIVER` here also. If you don't specify the
|
||||
|
@ -86,7 +88,9 @@ Network names must be unique. The Docker daemon attempts to identify naming
|
|||
conflicts but this is not guaranteed. It is the user's responsibility to avoid
|
||||
name conflicts.
|
||||
|
||||
## Connect containers
|
||||
## Examples
|
||||
|
||||
### Connect containers
|
||||
|
||||
When you start a container, use the `--network` flag to connect it to a network.
|
||||
This example adds the `busybox` container to the `mynet` network:
|
||||
|
@ -107,7 +111,7 @@ Engines can also communicate in this way.
|
|||
You can disconnect a container from a network using the `docker network
|
||||
disconnect` command.
|
||||
|
||||
## Specifying advanced options
|
||||
### Specify advanced options
|
||||
|
||||
When you create a network, Engine creates a non-overlapping subnetwork for the
|
||||
network by default. This subnetwork is not a subdivision of an existing
|
||||
|
@ -150,7 +154,7 @@ $ docker network create -d overlay \
|
|||
Be sure that your subnetworks do not overlap. If they do, the network create
|
||||
fails and Engine returns an error.
|
||||
|
||||
# Bridge driver options
|
||||
### Bridge driver options
|
||||
|
||||
When creating a custom network, the default network driver (i.e. `bridge`) has
|
||||
additional options that can be passed. The following are those options and the
|
||||
|
@ -191,7 +195,7 @@ connects a bridge network to it to provide external connectivity. If you want
|
|||
to create an externally isolated `overlay` network, you can specify the
|
||||
`--internal` option.
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [network inspect](network_inspect.md)
|
||||
* [network connect](network_connect.md)
|
||||
|
|
|
@ -25,14 +25,19 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
Disconnects a container from a network. The container must be running to disconnect it from the network.
|
||||
## Description
|
||||
|
||||
Disconnects a container from a network. The container must be running to
|
||||
disconnect it from the network.
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker network disconnect multi-host-network container1
|
||||
```
|
||||
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [network inspect](network_inspect.md)
|
||||
* [network connect](network_connect.md)
|
||||
|
|
|
@ -25,7 +25,16 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
Returns information about one or more networks. By default, this command renders all results in a JSON object. For example, if you connect two containers to the default `bridge` network:
|
||||
## Description
|
||||
|
||||
Returns information about one or more networks. By default, this command renders
|
||||
all results in a JSON object.
|
||||
|
||||
## Examples
|
||||
|
||||
## Inspect the `bridge` network
|
||||
|
||||
Connect two containers to the default `bridge` network:
|
||||
|
||||
```bash
|
||||
$ sudo docker run -itd --name=container1 busybox
|
||||
|
@ -47,8 +56,9 @@ template for each result. Go's
|
|||
[text/template](http://golang.org/pkg/text/template/) package describes all the
|
||||
details of the format.
|
||||
|
||||
```bash
|
||||
```none
|
||||
$ sudo docker network inspect bridge
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "bridge",
|
||||
|
@ -95,12 +105,19 @@ $ sudo docker network inspect bridge
|
|||
]
|
||||
```
|
||||
|
||||
Returns the information about the user-defined network:
|
||||
### Inspect a user-defined network
|
||||
|
||||
Create and inspect a user-defined network:
|
||||
|
||||
```bash
|
||||
$ docker network create simple-network
|
||||
|
||||
69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a
|
||||
```
|
||||
|
||||
```none
|
||||
$ docker network inspect simple-network
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "simple-network",
|
||||
|
@ -124,12 +141,15 @@ $ docker network inspect simple-network
|
|||
]
|
||||
```
|
||||
|
||||
For swarm mode overlay networks `network inspect` also shows the IP address and node name
|
||||
of the peers. Peers are the nodes in the swarm cluster which have at least one task attached
|
||||
### Inspect the `ingress` network
|
||||
|
||||
For swarm mode overlay networks `network inspect` also shows the IP address and node name
|
||||
of the peers. Peers are the nodes in the swarm cluster which have at least one task attached
|
||||
to the network. Node name is of the format `<hostname>-<unique ID>`.
|
||||
|
||||
```bash
|
||||
```none
|
||||
$ docker network inspect ingress
|
||||
|
||||
[
|
||||
{
|
||||
"Name": "ingress",
|
||||
|
@ -181,7 +201,7 @@ $ docker network inspect ingress
|
|||
]
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [network disconnect ](network_disconnect.md)
|
||||
* [network connect](network_connect.md)
|
||||
|
|
|
@ -31,8 +31,14 @@ Options:
|
|||
-q, --quiet Only display network IDs
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Lists all the networks the Engine `daemon` knows about. This includes the
|
||||
networks that span across multiple hosts in a cluster, for example:
|
||||
networks that span across multiple hosts in a cluster.
|
||||
|
||||
## Examples
|
||||
|
||||
### List all networks
|
||||
|
||||
```bash
|
||||
$ sudo docker network ls
|
||||
|
@ -55,7 +61,7 @@ c288470c46f6c8949c5f7e5099b5b7947b07eabe8d9a27d79a9cbf111adcbf47 host
|
|||
63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161 dev bridge local
|
||||
```
|
||||
|
||||
## Filtering
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
|
||||
is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
|
||||
|
@ -175,7 +181,7 @@ $ docker network rm `docker network ls --filter type=custom -q`
|
|||
A warning will be issued when trying to remove a network that has containers
|
||||
attached.
|
||||
|
||||
## Formatting
|
||||
### Formatting
|
||||
|
||||
The formatting options (`--format`) pretty-prints networks output
|
||||
using a Go template.
|
||||
|
@ -207,7 +213,7 @@ d1584f8dc718: host
|
|||
391df270dc66: null
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [network disconnect ](network_disconnect.md)
|
||||
* [network connect](network_connect.md)
|
||||
|
|
|
@ -16,12 +16,16 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
Remove all unused networks. Unused networks are those which are not referenced by any containers.
|
||||
## Description
|
||||
|
||||
Example output:
|
||||
Remove all unused networks. Unused networks are those which are not referenced
|
||||
by any containers.
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker network prune
|
||||
|
||||
WARNING! This will remove all networks not used by at least one container.
|
||||
Are you sure you want to continue? [y/N] y
|
||||
Deleted Networks:
|
||||
|
@ -29,7 +33,55 @@ n1
|
|||
n2
|
||||
```
|
||||
|
||||
## Related information
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
||||
The currently supported filters are:
|
||||
|
||||
* until (`<timestamp>`) - only remove networks created before given timestamp
|
||||
|
||||
The `until` filter can be Unix timestamps, date formatted
|
||||
timestamps, or Go duration strings (e.g. `10m`, `1h30m`) computed
|
||||
relative to the daemon machine’s time. Supported formats for date
|
||||
formatted time stamps include RFC3339Nano, RFC3339, `2006-01-02T15:04:05`,
|
||||
`2006-01-02T15:04:05.999999999`, `2006-01-02Z07:00`, and `2006-01-02`. The local
|
||||
timezone on the daemon will be used if you do not provide either a `Z` or a
|
||||
`+-00:00` timezone offset at the end of the timestamp. When providing Unix
|
||||
timestamps enter seconds[.nanoseconds], where seconds is the number of seconds
|
||||
that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap
|
||||
seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
|
||||
fraction of a second no more than nine digits long.
|
||||
|
||||
The following removes networks created more than 5 minutes ago. Note that
|
||||
system networks such as `bridge`, `host`, and `none` will never be pruned:
|
||||
|
||||
```none
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER SCOPE
|
||||
7430df902d7a bridge bridge local
|
||||
ea92373fd499 foo-1-day-ago bridge local
|
||||
ab53663ed3c7 foo-1-min-ago bridge local
|
||||
97b91972bc3b host host local
|
||||
f949d337b1f5 none null local
|
||||
|
||||
$ docker network prune --force --filter until=5m
|
||||
|
||||
Deleted Networks:
|
||||
foo-1-day-ago
|
||||
|
||||
$ docker network ls
|
||||
|
||||
NETWORK ID NAME DRIVER SCOPE
|
||||
7430df902d7a bridge bridge local
|
||||
ab53663ed3c7 foo-1-min-ago bridge local
|
||||
97b91972bc3b host host local
|
||||
f949d337b1f5 none null local
|
||||
```
|
||||
|
||||
## Related commands
|
||||
|
||||
* [network disconnect ](network_disconnect.md)
|
||||
* [network connect](network_connect.md)
|
||||
|
|
|
@ -27,14 +27,23 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Removes one or more networks by name or identifier. To remove a network,
|
||||
you must first disconnect any containers connected to it.
|
||||
|
||||
## Examples
|
||||
|
||||
### Remove a network
|
||||
|
||||
To remove the network named 'my-network':
|
||||
|
||||
```bash
|
||||
$ docker network rm my-network
|
||||
```
|
||||
|
||||
### Remove multiple networks
|
||||
|
||||
To delete multiple networks in a single `docker network rm` command, provide
|
||||
multiple network names or ids. The following example deletes a network with id
|
||||
`3695c422697f` and a network named `my-network`:
|
||||
|
@ -48,7 +57,7 @@ If the deletion of one network fails, the command continues to the next on the
|
|||
list and tries to delete that. The command reports success or failure for each
|
||||
deletion.
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [network disconnect ](network_disconnect.md)
|
||||
* [network connect](network_connect.md)
|
||||
|
|
|
@ -25,14 +25,19 @@ Options:
|
|||
|
||||
```
|
||||
|
||||
Demotes an existing manager so that it is no longer a manager. This command targets a docker engine that is a manager in the swarm.
|
||||
## Description
|
||||
|
||||
Demotes an existing manager so that it is no longer a manager. This command
|
||||
targets a docker engine that is a manager in the swarm.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker node demote <node name>
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [node inspect](node_inspect.md)
|
||||
* [node ls](node_ls.md)
|
||||
|
|
|
@ -26,108 +26,120 @@ Options:
|
|||
--pretty Print the information in a human friendly format.
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns information about a node. By default, this command renders all results
|
||||
in a JSON array. You can specify an alternate format to execute a
|
||||
given template for each result. Go's
|
||||
[text/template](http://golang.org/pkg/text/template/) package describes all the
|
||||
details of the format.
|
||||
|
||||
Example output:
|
||||
## Examples
|
||||
|
||||
$ docker node inspect swarm-manager
|
||||
[
|
||||
{
|
||||
"ID": "e216jshn25ckzbvmwlnh5jr3g",
|
||||
"Version": {
|
||||
"Index": 10
|
||||
### Inspect a node
|
||||
|
||||
```none
|
||||
$ docker node inspect swarm-manager
|
||||
|
||||
[
|
||||
{
|
||||
"ID": "e216jshn25ckzbvmwlnh5jr3g",
|
||||
"Version": {
|
||||
"Index": 10
|
||||
},
|
||||
"CreatedAt": "2016-06-16T22:52:44.9910662Z",
|
||||
"UpdatedAt": "2016-06-16T22:52:45.230878043Z",
|
||||
"Spec": {
|
||||
"Role": "manager",
|
||||
"Availability": "active"
|
||||
},
|
||||
"Description": {
|
||||
"Hostname": "swarm-manager",
|
||||
"Platform": {
|
||||
"Architecture": "x86_64",
|
||||
"OS": "linux"
|
||||
},
|
||||
"CreatedAt": "2016-06-16T22:52:44.9910662Z",
|
||||
"UpdatedAt": "2016-06-16T22:52:45.230878043Z",
|
||||
"Spec": {
|
||||
"Role": "manager",
|
||||
"Availability": "active"
|
||||
"Resources": {
|
||||
"NanoCPUs": 1000000000,
|
||||
"MemoryBytes": 1039843328
|
||||
},
|
||||
"Description": {
|
||||
"Hostname": "swarm-manager",
|
||||
"Platform": {
|
||||
"Architecture": "x86_64",
|
||||
"OS": "linux"
|
||||
},
|
||||
"Resources": {
|
||||
"NanoCPUs": 1000000000,
|
||||
"MemoryBytes": 1039843328
|
||||
},
|
||||
"Engine": {
|
||||
"EngineVersion": "1.12.0",
|
||||
"Plugins": [
|
||||
{
|
||||
"Type": "Volume",
|
||||
"Name": "local"
|
||||
},
|
||||
{
|
||||
"Type": "Network",
|
||||
"Name": "overlay"
|
||||
},
|
||||
{
|
||||
"Type": "Network",
|
||||
"Name": "null"
|
||||
},
|
||||
{
|
||||
"Type": "Network",
|
||||
"Name": "host"
|
||||
},
|
||||
{
|
||||
"Type": "Network",
|
||||
"Name": "bridge"
|
||||
},
|
||||
{
|
||||
"Type": "Network",
|
||||
"Name": "overlay"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Status": {
|
||||
"State": "ready",
|
||||
"Addr": "168.0.32.137"
|
||||
},
|
||||
"ManagerStatus": {
|
||||
"Leader": true,
|
||||
"Reachability": "reachable",
|
||||
"Addr": "168.0.32.137:2377"
|
||||
"Engine": {
|
||||
"EngineVersion": "1.12.0",
|
||||
"Plugins": [
|
||||
{
|
||||
"Type": "Volume",
|
||||
"Name": "local"
|
||||
},
|
||||
{
|
||||
"Type": "Network",
|
||||
"Name": "overlay"
|
||||
},
|
||||
{
|
||||
"Type": "Network",
|
||||
"Name": "null"
|
||||
},
|
||||
{
|
||||
"Type": "Network",
|
||||
"Name": "host"
|
||||
},
|
||||
{
|
||||
"Type": "Network",
|
||||
"Name": "bridge"
|
||||
},
|
||||
{
|
||||
"Type": "Network",
|
||||
"Name": "overlay"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"Status": {
|
||||
"State": "ready",
|
||||
"Addr": "168.0.32.137"
|
||||
},
|
||||
"ManagerStatus": {
|
||||
"Leader": true,
|
||||
"Reachability": "reachable",
|
||||
"Addr": "168.0.32.137:2377"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
```
|
||||
|
||||
{% raw %}
|
||||
$ docker node inspect --format '{{ .ManagerStatus.Leader }}' self
|
||||
false
|
||||
{% endraw %}
|
||||
### Specify an output format
|
||||
|
||||
$ docker node inspect --pretty self
|
||||
ID: e216jshn25ckzbvmwlnh5jr3g
|
||||
Hostname: swarm-manager
|
||||
Joined at: 2016-06-16 22:52:44.9910662 +0000 utc
|
||||
Status:
|
||||
State: Ready
|
||||
Availability: Active
|
||||
Address: 172.17.0.2
|
||||
Manager Status:
|
||||
Address: 172.17.0.2:2377
|
||||
Raft Status: Reachable
|
||||
Leader: Yes
|
||||
Platform:
|
||||
Operating System: linux
|
||||
Architecture: x86_64
|
||||
Resources:
|
||||
CPUs: 4
|
||||
Memory: 7.704 GiB
|
||||
Plugins:
|
||||
Network: overlay, bridge, null, host, overlay
|
||||
Volume: local
|
||||
Engine Version: 1.12.0
|
||||
```none
|
||||
{% raw %}
|
||||
$ docker node inspect --format '{{ .ManagerStatus.Leader }}' self
|
||||
|
||||
## Related information
|
||||
false
|
||||
|
||||
$ docker node inspect --pretty self
|
||||
ID: e216jshn25ckzbvmwlnh5jr3g
|
||||
Hostname: swarm-manager
|
||||
Joined at: 2016-06-16 22:52:44.9910662 +0000 utc
|
||||
Status:
|
||||
State: Ready
|
||||
Availability: Active
|
||||
Address: 172.17.0.2
|
||||
Manager Status:
|
||||
Address: 172.17.0.2:2377
|
||||
Raft Status: Reachable
|
||||
Leader: Yes
|
||||
Platform:
|
||||
Operating System: linux
|
||||
Architecture: x86_64
|
||||
Resources:
|
||||
CPUs: 4
|
||||
Memory: 7.704 GiB
|
||||
Plugins:
|
||||
Network: overlay, bridge, null, host, overlay
|
||||
Volume: local
|
||||
Engine Version: 1.12.0
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Related commands
|
||||
|
||||
* [node demote](node_demote.md)
|
||||
* [node ls](node_ls.md)
|
||||
|
|
|
@ -29,9 +29,13 @@ Options:
|
|||
-q, --quiet Only display IDs
|
||||
```
|
||||
|
||||
Lists all the nodes that the Docker Swarm manager knows about. You can filter using the `-f` or `--filter` flag. Refer to the [filtering](#filtering) section for more information about available filter options.
|
||||
## Description
|
||||
|
||||
Example output:
|
||||
Lists all the nodes that the Docker Swarm manager knows about. You can filter
|
||||
using the `-f` or `--filter` flag. Refer to the [filtering](#filtering) section
|
||||
for more information about available filter options.
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker node ls
|
||||
|
@ -42,7 +46,7 @@ ID HOSTNAME STATUS AVAILABILITY MANAGER STATU
|
|||
e216jshn25ckzbvmwlnh5jr3g * swarm-manager1 Ready Active Leader
|
||||
```
|
||||
|
||||
## Filtering
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
@ -55,7 +59,7 @@ The currently supported filters are:
|
|||
* [name](node_ls.md#name)
|
||||
* [role](node_ls.md#role)
|
||||
|
||||
#### ID
|
||||
#### id
|
||||
|
||||
The `id` filter matches all or part of a node's id.
|
||||
|
||||
|
@ -66,7 +70,7 @@ ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
|
|||
1bcef6utixb0l0ca7gxuivsj0 swarm-worker2 Ready Active
|
||||
```
|
||||
|
||||
#### Label
|
||||
#### label
|
||||
|
||||
The `label` filter matches nodes based on engine labels and on the presence of a `label` alone or a `label` and a value. Node labels are currently not used for filtering.
|
||||
|
||||
|
@ -79,7 +83,7 @@ ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
|
|||
1bcef6utixb0l0ca7gxuivsj0 swarm-worker2 Ready Active
|
||||
```
|
||||
|
||||
#### Membership
|
||||
#### membersip
|
||||
|
||||
The `membership` filter matches nodes based on the presence of a `membership` and a value
|
||||
`accepted` or `pending`.
|
||||
|
@ -94,7 +98,7 @@ ID HOSTNAME STATUS AVAILABILITY MANAGER STATU
|
|||
38ciaotwjuritcdtn9npbnkuz swarm-worker1 Ready Active
|
||||
```
|
||||
|
||||
#### Name
|
||||
#### name
|
||||
|
||||
The `name` filter matches on all or part of a node hostname.
|
||||
|
||||
|
@ -107,7 +111,7 @@ ID HOSTNAME STATUS AVAILABILITY MANAGER STATU
|
|||
e216jshn25ckzbvmwlnh5jr3g * swarm-manager1 Ready Active Leader
|
||||
```
|
||||
|
||||
#### Role
|
||||
#### role
|
||||
|
||||
The `role` filter matches nodes based on the presence of a `role` and a value `worker` or `manager`.
|
||||
|
||||
|
@ -120,7 +124,7 @@ ID HOSTNAME STATUS AVAILABILITY MANAGER STATU
|
|||
e216jshn25ckzbvmwlnh5jr3g * swarm-manager1 Ready Active Leader
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [node demote](node_demote.md)
|
||||
* [node inspect](node_inspect.md)
|
||||
|
|
|
@ -24,14 +24,18 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
Promotes a node to manager. This command targets a docker engine that is a manager in the swarm.
|
||||
## Description
|
||||
|
||||
Promotes a node to manager. This command targets a docker engine that is a
|
||||
manager in the swarm.
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker node promote <node name>
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [node demote](node_demote.md)
|
||||
* [node inspect](node_inspect.md)
|
||||
|
|
|
@ -28,20 +28,23 @@ Options:
|
|||
--no-trunc Do not truncate output
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Lists all the tasks on a Node that Docker knows about. You can filter using the `-f` or `--filter` flag. Refer to the [filtering](#filtering) section for more information about available filter options.
|
||||
|
||||
Example output:
|
||||
## Examples
|
||||
|
||||
$ docker node ps swarm-manager1
|
||||
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
||||
redis.1.7q92v0nr1hcgts2amcjyqg3pq redis:3.0.6 swarm-manager1 Running Running 5 hours
|
||||
redis.6.b465edgho06e318egmgjbqo4o redis:3.0.6 swarm-manager1 Running Running 29 seconds
|
||||
redis.7.bg8c07zzg87di2mufeq51a2qp redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
redis.9.dkkual96p4bb3s6b10r7coxxt redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
redis.10.0tgctg8h8cech4w0k0gwrmr23 redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
```bash
|
||||
$ docker node ps swarm-manager1
|
||||
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
||||
redis.1.7q92v0nr1hcgts2amcjyqg3pq redis:3.0.6 swarm-manager1 Running Running 5 hours
|
||||
redis.6.b465edgho06e318egmgjbqo4o redis:3.0.6 swarm-manager1 Running Running 29 seconds
|
||||
redis.7.bg8c07zzg87di2mufeq51a2qp redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
redis.9.dkkual96p4bb3s6b10r7coxxt redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
redis.10.0tgctg8h8cech4w0k0gwrmr23 redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
```
|
||||
|
||||
|
||||
## Filtering
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
@ -59,23 +62,27 @@ The `name` filter matches on all or part of a task's name.
|
|||
|
||||
The following filter matches all tasks with a name containing the `redis` string.
|
||||
|
||||
$ docker node ps -f name=redis swarm-manager1
|
||||
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
||||
redis.1.7q92v0nr1hcgts2amcjyqg3pq redis:3.0.6 swarm-manager1 Running Running 5 hours
|
||||
redis.6.b465edgho06e318egmgjbqo4o redis:3.0.6 swarm-manager1 Running Running 29 seconds
|
||||
redis.7.bg8c07zzg87di2mufeq51a2qp redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
redis.9.dkkual96p4bb3s6b10r7coxxt redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
redis.10.0tgctg8h8cech4w0k0gwrmr23 redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
```bash
|
||||
$ docker node ps -f name=redis swarm-manager1
|
||||
|
||||
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
||||
redis.1.7q92v0nr1hcgts2amcjyqg3pq redis:3.0.6 swarm-manager1 Running Running 5 hours
|
||||
redis.6.b465edgho06e318egmgjbqo4o redis:3.0.6 swarm-manager1 Running Running 29 seconds
|
||||
redis.7.bg8c07zzg87di2mufeq51a2qp redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
redis.9.dkkual96p4bb3s6b10r7coxxt redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
redis.10.0tgctg8h8cech4w0k0gwrmr23 redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
```
|
||||
|
||||
#### id
|
||||
|
||||
The `id` filter matches a task's id.
|
||||
|
||||
$ docker node ps -f id=bg8c07zzg87di2mufeq51a2qp swarm-manager1
|
||||
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
||||
redis.7.bg8c07zzg87di2mufeq51a2qp redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
```bash
|
||||
$ docker node ps -f id=bg8c07zzg87di2mufeq51a2qp swarm-manager1
|
||||
|
||||
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
||||
redis.7.bg8c07zzg87di2mufeq51a2qp redis:3.0.6 swarm-manager1 Running Running 5 seconds
|
||||
```
|
||||
|
||||
#### label
|
||||
|
||||
|
@ -86,6 +93,7 @@ The following filter matches tasks with the `usage` label regardless of its valu
|
|||
|
||||
```bash
|
||||
$ docker node ps -f "label=usage"
|
||||
|
||||
NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
||||
redis.6.b465edgho06e318egmgjbqo4o redis:3.0.6 swarm-manager1 Running Running 10 minutes
|
||||
redis.7.bg8c07zzg87di2mufeq51a2qp redis:3.0.6 swarm-manager1 Running Running 9 minutes
|
||||
|
@ -97,7 +105,7 @@ redis.7.bg8c07zzg87di2mufeq51a2qp redis:3.0.6 swarm-manager1 Running R
|
|||
The `desired-state` filter can take the values `running`, `shutdown`, and `accepted`.
|
||||
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [node demote](node_demote.md)
|
||||
* [node inspect](node_inspect.md)
|
||||
|
|
|
@ -28,33 +28,40 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
When run from a manager node, removes the specified nodes from a swarm.
|
||||
|
||||
|
||||
Example output:
|
||||
## Examples
|
||||
|
||||
```nohighlight
|
||||
### Remove a stopped node from the swarm
|
||||
|
||||
```bash
|
||||
$ docker node rm swarm-node-02
|
||||
|
||||
Node swarm-node-02 removed from swarm
|
||||
```
|
||||
### Attempt to remove a running node from a swarm
|
||||
|
||||
Removes the specified nodes from the swarm, but only if the nodes are in the
|
||||
down state. If you attempt to remove an active node you will receive an error:
|
||||
|
||||
```nohighlight
|
||||
```non
|
||||
$ docker node rm swarm-node-03
|
||||
|
||||
Error response from daemon: rpc error: code = 9 desc = node swarm-node-03 is not
|
||||
down and can't be removed
|
||||
```
|
||||
|
||||
### Forcibly remove an inaccessible node from a swarm
|
||||
|
||||
If you lose access to a worker node or need to shut it down because it has been
|
||||
compromised or is not behaving as expected, you can use the `--force` option.
|
||||
This may cause transient errors or interruptions, depending on the type of task
|
||||
being run on the node.
|
||||
|
||||
```nohighlight
|
||||
```bash
|
||||
$ docker node rm --force swarm-node-03
|
||||
|
||||
Node swarm-node-03 removed from swarm
|
||||
|
@ -63,7 +70,7 @@ Node swarm-node-03 removed from swarm
|
|||
A manager node must be demoted to a worker node (using `docker node demote`)
|
||||
before you can remove it from the swarm.
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [node demote](node_demote.md)
|
||||
* [node inspect](node_inspect.md)
|
||||
|
|
|
@ -13,7 +13,7 @@ keywords: "resources, update, dynamically"
|
|||
will be rejected.
|
||||
-->
|
||||
|
||||
## update
|
||||
# update
|
||||
|
||||
```markdown
|
||||
Usage: docker node update [OPTIONS] NODE
|
||||
|
@ -28,6 +28,12 @@ Options:
|
|||
--role string Role of the node (worker/manager)
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Update metadata about a node, such as its availability, labels, or roles.
|
||||
|
||||
## Examples
|
||||
|
||||
### Add label metadata to a node
|
||||
|
||||
Add metadata to a swarm node using node labels. You can specify a node label as
|
||||
|
@ -39,7 +45,7 @@ $ docker node update --label-add foo worker1
|
|||
|
||||
To add multiple labels to a node, pass the `--label-add` flag for each label:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
$ docker node update --label-add foo --label-add bar worker1
|
||||
```
|
||||
|
||||
|
@ -61,7 +67,7 @@ entity within the swarm. Do not confuse them with the docker daemon labels for
|
|||
For more information about labels, refer to [apply custom
|
||||
metadata](https://docs.docker.com/engine/userguide/labels-custom-metadata/).
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [node demote](node_demote.md)
|
||||
* [node inspect](node_inspect.md)
|
||||
|
|
|
@ -24,6 +24,8 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `docker pause` command suspends all processes in the specified containers.
|
||||
On Linux, this uses the cgroups freezer. Traditionally, when suspending a process
|
||||
the `SIGSTOP` signal is used, which is observable by the process being suspended.
|
||||
|
@ -35,6 +37,12 @@ See the
|
|||
[cgroups freezer documentation](https://www.kernel.org/doc/Documentation/cgroup-v1/freezer-subsystem.txt)
|
||||
for further details.
|
||||
|
||||
## Related information
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker pause my_container
|
||||
```
|
||||
|
||||
## Related commands
|
||||
|
||||
* [unpause](unpause.md)
|
||||
|
|
|
@ -21,33 +21,38 @@ Usage: docker plugin create [OPTIONS] PLUGIN PLUGIN-DATA-DIR
|
|||
Create a plugin from a rootfs and configuration. Plugin data directory must contain config.json and rootfs directory.
|
||||
|
||||
Options:
|
||||
--compress Compress the context using gzip
|
||||
--compress Compress the context using gzip
|
||||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Creates a plugin. Before creating the plugin, prepare the plugin's root filesystem as well as
|
||||
[the config.json](../../extend/config.md)
|
||||
|
||||
## Examples
|
||||
|
||||
The following example shows how to create a sample `plugin`.
|
||||
|
||||
```bash
|
||||
|
||||
$ ls -ls /home/pluginDir
|
||||
|
||||
4 -rw-r--r-- 1 root root 431 Nov 7 01:40 config.json
|
||||
0 drwxr-xr-x 19 root root 420 Nov 7 01:40 rootfs
|
||||
|
||||
$ docker plugin create plugin /home/pluginDir
|
||||
|
||||
plugin
|
||||
|
||||
NAME TAG DESCRIPTION ENABLED
|
||||
plugin latest A sample plugin for Docker true
|
||||
$ docker plugin ls
|
||||
|
||||
ID NAME TAG DESCRIPTION ENABLED
|
||||
672d8144ec02 plugin latest A sample plugin for Docker false
|
||||
```
|
||||
|
||||
The plugin can subsequently be enabled for local use or pushed to the public registry.
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [plugin disable](plugin_disable.md)
|
||||
* [plugin enable](plugin_enable.md)
|
||||
|
|
|
@ -25,10 +25,13 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Disables a plugin. The plugin must be installed before it can be disabled,
|
||||
see [`docker plugin install`](plugin_install.md). Without the `-f` option,
|
||||
a plugin that has references (eg, volumes, networks) cannot be disabled.
|
||||
|
||||
## Examples
|
||||
|
||||
The following example shows that the `sample-volume-plugin` plugin is installed
|
||||
and enabled:
|
||||
|
@ -53,7 +56,7 @@ ID NAME TAG DESCRIP
|
|||
69553ca1d123 tiborvass/sample-volume-plugin latest A test plugin for Docker false
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [plugin create](plugin_create.md)
|
||||
* [plugin enable](plugin_enable.md)
|
||||
|
|
|
@ -25,9 +25,12 @@ Options:
|
|||
--timeout int HTTP client timeout (in seconds)
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Enables a plugin. The plugin must be installed before it can be enabled,
|
||||
see [`docker plugin install`](plugin_install.md).
|
||||
|
||||
## Examples
|
||||
|
||||
The following example shows that the `sample-volume-plugin` plugin is installed,
|
||||
but disabled:
|
||||
|
@ -52,7 +55,7 @@ ID NAME TAG DESCRIP
|
|||
69553ca1d123 tiborvass/sample-volume-plugin latest A test plugin for Docker true
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [plugin create](plugin_create.md)
|
||||
* [plugin disable](plugin_disable.md)
|
||||
|
|
|
@ -25,15 +25,17 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Returns information about a plugin. By default, this command renders all results
|
||||
in a JSON array.
|
||||
|
||||
Example output:
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
|
||||
```none
|
||||
$ docker plugin inspect tiborvass/sample-volume-plugin:latest
|
||||
```
|
||||
```JSON
|
||||
|
||||
{
|
||||
"Id": "8c74c978c434745c3ade82f1bc0acf38d04990eaf494fa507c16d9f1daa99c21",
|
||||
"Name": "tiborvass/sample-volume-plugin:latest",
|
||||
|
@ -140,18 +142,21 @@ $ docker plugin inspect tiborvass/sample-volume-plugin:latest
|
|||
}
|
||||
}
|
||||
```
|
||||
|
||||
(output formatted for readability)
|
||||
|
||||
### Formatting the output
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker plugin inspect -f '{{.Id}}' tiborvass/sample-volume-plugin:latest
|
||||
```
|
||||
```
|
||||
|
||||
8c74c978c434745c3ade82f1bc0acf38d04990eaf494fa507c16d9f1daa99c21
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [plugin create](plugin_create.md)
|
||||
* [plugin enable](plugin_enable.md)
|
||||
|
|
|
@ -23,20 +23,24 @@ Install a plugin
|
|||
Options:
|
||||
--alias string Local name for plugin
|
||||
--disable Do not enable the plugin on install
|
||||
--disable-content-trust Skip image verification (default true)
|
||||
--grant-all-permissions Grant all permissions necessary to run the plugin
|
||||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Installs and enables a plugin. Docker looks first for the plugin on your Docker
|
||||
host. If the plugin does not exist locally, then the plugin is pulled from
|
||||
the registry. Note that the minimum required registry version to distribute
|
||||
plugins is 2.3.0
|
||||
|
||||
## Examples
|
||||
|
||||
The following example installs `vieus/sshfs` plugin and [set](plugin_set.md) it's env variable
|
||||
`DEBUG` to 1. Install consists of pulling the plugin from Docker Hub, prompting
|
||||
the user to accept the list of privileges that the plugin needs, settings parameters
|
||||
and enabling the plugin.
|
||||
The following example installs `vieus/sshfs` plugin and [sets](plugin_set.md) its
|
||||
`DEBUG` environment variable to `1`. To install, `pull` the plugin from Docker
|
||||
Hub and prompt the user to accept the list of privileges that the plugin needs,
|
||||
set the plugin's parameters and enable the plugin.
|
||||
|
||||
```bash
|
||||
$ docker plugin install vieux/sshfs DEBUG=1
|
||||
|
@ -58,7 +62,7 @@ ID NAME TAG DESCRIPTION
|
|||
69553ca1d123 vieux/sshfs latest sshFS plugin for Docker true
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [plugin create](plugin_create.md)
|
||||
* [plugin disable](plugin_disable.md)
|
||||
|
|
|
@ -28,10 +28,12 @@ Options:
|
|||
--no-trunc Don't truncate output
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Lists all the plugins that are currently installed. You can install plugins
|
||||
using the [`docker plugin install`](plugin_install.md) command.
|
||||
|
||||
Example output:
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker plugin ls
|
||||
|
@ -40,7 +42,69 @@ ID NAME TAG DESCRIP
|
|||
69553ca1d123 tiborvass/sample-volume-plugin latest A test plugin for Docker true
|
||||
```
|
||||
|
||||
## Related information
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
||||
The currently supported filters are:
|
||||
|
||||
* enabled (boolean - true or false, 0 or 1)
|
||||
* capability (string - currently `volumedriver`, `networkdriver`, `ipamdriver`, or `authz`)
|
||||
|
||||
#### enabled
|
||||
|
||||
The `enabled` filter matches on plugins enabled or disabled.
|
||||
|
||||
#### capability
|
||||
|
||||
The `capability` filter matches on plugin capabilities. One plugin
|
||||
might have multiple capabilities. Currently `volumedriver`, `networkdriver`,
|
||||
`ipamdriver`, and `authz` are supported capabilities.
|
||||
|
||||
```bash
|
||||
$ docker plugin install --disable tiborvass/no-remove
|
||||
|
||||
tiborvass/no-remove
|
||||
|
||||
$ docker plugin ls --filter enabled=true
|
||||
|
||||
NAME TAG DESCRIPTION ENABLED
|
||||
```
|
||||
|
||||
|
||||
### Formatting
|
||||
|
||||
The formatting options (`--format`) pretty-prints plugins output
|
||||
using a Go template.
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
Placeholder | Description
|
||||
---------------|------------------------------------------------------------------------------------------
|
||||
`.ID` | Plugin ID
|
||||
`.Name` | Plugin name
|
||||
`.Description` | Plugin description
|
||||
`.Enabled` | Whether plugin is enabled or not
|
||||
`.PluginReference` | The reference used to push/pull from a registry
|
||||
|
||||
When using the `--format` option, the `plugin ls` command will either
|
||||
output the data exactly as the template declares or, when using the
|
||||
`table` directive, includes column headers as well.
|
||||
|
||||
The following example uses a template without headers and outputs the
|
||||
`ID` and `Name` entries separated by a colon for all plugins:
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker plugin ls --format "{{.ID}}: {{.Name}}"
|
||||
|
||||
4be01827a72e: tiborvass/no-remove
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
|
||||
## Related commands
|
||||
|
||||
* [plugin create](plugin_create.md)
|
||||
* [plugin disable](plugin_disable.md)
|
||||
|
|
|
@ -22,22 +22,27 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
Use `docker plugin create` to create the plugin. Once the plugin is ready for distribution,
|
||||
use `docker plugin push` to share your images to the Docker Hub registry or to a self-hosted one.
|
||||
## Description
|
||||
|
||||
After you have created a plugin using `docker plugin create` and the plugin is
|
||||
ready for distribution, use `docker plugin push` to share your images to Docker
|
||||
Hub or a self-hosted registry.
|
||||
|
||||
Registry credentials are managed by [docker login](login.md).
|
||||
|
||||
## Examples
|
||||
|
||||
The following example shows how to push a sample `user/plugin`.
|
||||
|
||||
```bash
|
||||
|
||||
$ docker plugin ls
|
||||
|
||||
ID NAME TAG DESCRIPTION ENABLED
|
||||
69553ca1d456 user/plugin latest A sample plugin for Docker false
|
||||
$ docker plugin push user/plugin
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [plugin create](plugin_create.md)
|
||||
* [plugin disable](plugin_disable.md)
|
||||
|
|
|
@ -28,12 +28,17 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Removes a plugin. You cannot remove a plugin if it is enabled, you must disable
|
||||
a plugin using the [`docker plugin disable`](plugin_disable.md) before removing
|
||||
it (or use --force, use of force is not recommended, since it can affect
|
||||
functioning of running containers using the plugin).
|
||||
|
||||
The following example disables and removes the `sample-volume-plugin:latest` plugin;
|
||||
## Examples
|
||||
|
||||
The following example disables and removes the `sample-volume-plugin:latest`
|
||||
plugin:
|
||||
|
||||
```bash
|
||||
$ docker plugin disable tiborvass/sample-volume-plugin
|
||||
|
@ -43,7 +48,7 @@ $ docker plugin rm tiborvass/sample-volume-plugin:latest
|
|||
tiborvass/sample-volume-plugin
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [plugin create](plugin_create.md)
|
||||
* [plugin disable](plugin_disable.md)
|
||||
|
|
|
@ -24,6 +24,8 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Change settings for a plugin. The plugin must be disabled.
|
||||
|
||||
The settings currently supported are:
|
||||
|
@ -32,23 +34,33 @@ The settings currently supported are:
|
|||
* path of devices
|
||||
* args
|
||||
|
||||
## Examples
|
||||
|
||||
### Change an environment variable
|
||||
|
||||
The following example change the env variable `DEBUG` on the
|
||||
`sample-volume-plugin` plugin.
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker plugin inspect -f {{.Settings.Env}} tiborvass/sample-volume-plugin
|
||||
|
||||
[DEBUG=0]
|
||||
|
||||
$ docker plugin set tiborvass/sample-volume-plugin DEBUG=1
|
||||
|
||||
$ docker plugin inspect -f {{.Settings.Env}} tiborvass/sample-volume-plugin
|
||||
[DEBUG=1]
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
### Change the source of a mount
|
||||
|
||||
The following example change the source of the `mymount` mount on
|
||||
the `myplugin` plugin.
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker plugin inspect -f '{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}' myplugin
|
||||
/foo
|
||||
|
||||
|
@ -56,14 +68,19 @@ $ docker plugins set myplugin mymount.source=/bar
|
|||
|
||||
$ docker plugin inspect -f '{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}' myplugin
|
||||
/bar
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Note: since only `source` is settable in `mymount`, `docker plugins set mymount=/bar myplugin` would work too.
|
||||
> **Note**: Since only `source` is settable in `mymount`,
|
||||
> `docker plugins set mymount=/bar myplugin` would work too.
|
||||
|
||||
### Change a device path
|
||||
|
||||
The following example change the path of the `mydevice` device on
|
||||
the `myplugin` plugin.
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker plugin inspect -f '{{with $device := index .Settings.Devices 0}}{{$device.Path}}{{end}}' myplugin
|
||||
/dev/foo
|
||||
|
||||
|
@ -71,13 +88,18 @@ $ docker plugins set myplugin mydevice.path=/dev/bar
|
|||
|
||||
$ docker plugin inspect -f '{{with $device := index .Settings.Devices 0}}{{$device.Path}}{{end}}' myplugin
|
||||
/dev/bar
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
Note: since only `path` is settable in `mydevice`, `docker plugins set mydevice=/dev/bar myplugin` would work too.
|
||||
> **Note**: Since only `path` is settable in `mydevice`,
|
||||
> `docker plugins set mydevice=/dev/bar myplugin` would work too.
|
||||
|
||||
### Change the source of the arguments
|
||||
|
||||
The following example change the source of the args on the `myplugin` plugin.
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker plugin inspect -f '{{.Settings.Args}}' myplugin
|
||||
["foo", "bar"]
|
||||
|
||||
|
@ -85,9 +107,10 @@ $ docker plugins set myplugin args="foo bar baz"
|
|||
|
||||
$ docker plugin inspect -f '{{.Settings.Args}}' myplugin
|
||||
["foo", "bar", "baz"]
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [plugin create](plugin_create.md)
|
||||
* [plugin disable](plugin_disable.md)
|
||||
|
|
|
@ -27,11 +27,15 @@ Options:
|
|||
--skip-remote-check Do not check if specified remote plugin matches existing plugin image
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Upgrades an existing plugin to the specified remote plugin image. If no remote
|
||||
is specified, Docker will re-pull the current image and use the updated version.
|
||||
All existing references to the plugin will continue to work.
|
||||
The plugin must be disabled before running the upgrade.
|
||||
|
||||
## Examples
|
||||
|
||||
The following example installs `vieus/sshfs` plugin, uses it to create and use
|
||||
a volume, then upgrades the plugin.
|
||||
|
||||
|
@ -71,7 +75,7 @@ $ docker run -it -v sshvolume:/data alpine sh -c "ls /data"
|
|||
hello
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [plugin create](plugin_create.md)
|
||||
* [plugin disable](plugin_disable.md)
|
||||
|
|
|
@ -24,18 +24,24 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Show all mapped ports
|
||||
|
||||
You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or
|
||||
just a specific mapping:
|
||||
|
||||
$ docker ps
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
b650456536c7 busybox:latest top 54 minutes ago Up 54 minutes 0.0.0.0:1234->9876/tcp, 0.0.0.0:4321->7890/tcp test
|
||||
$ docker port test
|
||||
7890/tcp -> 0.0.0.0:4321
|
||||
9876/tcp -> 0.0.0.0:1234
|
||||
$ docker port test 7890/tcp
|
||||
0.0.0.0:4321
|
||||
$ docker port test 7890/udp
|
||||
2014/06/24 11:53:36 Error: No public port '7890/udp' published for test
|
||||
$ docker port test 7890
|
||||
0.0.0.0:4321
|
||||
```bash
|
||||
$ docker ps
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
b650456536c7 busybox:latest top 54 minutes ago Up 54 minutes 0.0.0.0:1234->9876/tcp, 0.0.0.0:4321->7890/tcp test
|
||||
$ docker port test
|
||||
7890/tcp -> 0.0.0.0:4321
|
||||
9876/tcp -> 0.0.0.0:1234
|
||||
$ docker port test 7890/tcp
|
||||
0.0.0.0:4321
|
||||
$ docker port test 7890/udp
|
||||
2014/06/24 11:53:36 Error: No public port '7890/udp' published for test
|
||||
$ docker port test 7890
|
||||
0.0.0.0:4321
|
||||
```
|
||||
|
|
|
@ -46,6 +46,10 @@ Options:
|
|||
-s, --size Display total file sizes
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Prevent truncating output
|
||||
|
||||
Running `docker ps --no-trunc` showing 2 linked containers.
|
||||
|
||||
```bash
|
||||
|
@ -56,6 +60,8 @@ CONTAINER ID IMAGE COMMAND CREATED
|
|||
d7886598dbe2 crosbymichael/redis:latest /redis-server --dir 33 minutes ago Up 33 minutes 6379/tcp redis,webapp/db
|
||||
```
|
||||
|
||||
### Show both running and stopped containers
|
||||
|
||||
The `docker ps` command only shows running containers by default. To see all
|
||||
containers, use the `-a` (or `--all`) flag:
|
||||
|
||||
|
@ -67,7 +73,7 @@ $ docker ps -a
|
|||
container that exposes TCP ports `100, 101, 102` displays `100-102/tcp` in
|
||||
the `PORTS` column.
|
||||
|
||||
## Filtering
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there is more
|
||||
than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
@ -87,7 +93,7 @@ The currently supported filters are:
|
|||
* network (network id or name) - filters containers connected to the provided network
|
||||
* health (starting|healthy|unhealthy|none) - filters containers based on healthcheck status
|
||||
|
||||
#### Label
|
||||
#### label
|
||||
|
||||
The `label` filter matches containers based on the presence of a `label` alone or a `label` and a
|
||||
value.
|
||||
|
@ -111,7 +117,7 @@ CONTAINER ID IMAGE COMMAND CREATED
|
|||
d85756f57265 busybox "top" About a minute ago Up About a minute high_albattani
|
||||
```
|
||||
|
||||
#### Name
|
||||
#### name
|
||||
|
||||
The `name` filter matches on all or part of a container's name.
|
||||
|
||||
|
@ -135,7 +141,7 @@ CONTAINER ID IMAGE COMMAND CREATED
|
|||
673394ef1d4c busybox "top" 38 minutes ago Up 38 minutes nostalgic_shockley
|
||||
```
|
||||
|
||||
#### Exited
|
||||
#### exited
|
||||
|
||||
The `exited` filter matches containers by exist status code. For example, to
|
||||
filter for containers that have exited successfully:
|
||||
|
@ -149,13 +155,14 @@ ea09c3c82f6e registry:latest /srv/run.sh 2 weeks ago
|
|||
48ee228c9464 fedora:20 bash 2 weeks ago Exited (0) 2 weeks ago tender_torvalds
|
||||
```
|
||||
|
||||
#### Killed containers
|
||||
#### Filter by exit signal
|
||||
|
||||
You can use a filter to locate containers that exited with status of `137`
|
||||
meaning a `SIGKILL(9)` killed them.
|
||||
|
||||
```bash
|
||||
```none
|
||||
$ docker ps -a --filter 'exited=137'
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
b3e1c0ed5bfe ubuntu:latest "sleep 1000" 12 seconds ago Exited (137) 5 seconds ago grave_kowalevski
|
||||
a2eb5558d669 redis:latest "/entrypoint.sh redi 2 hours ago Exited (137) 2 hours ago sharp_lalande
|
||||
|
@ -167,7 +174,7 @@ Any of these events result in a `137` status:
|
|||
* `docker kill` kills the container
|
||||
* Docker daemon restarts which kills all running containers
|
||||
|
||||
#### Status
|
||||
#### status
|
||||
|
||||
The `status` filter matches containers by status. You can filter using
|
||||
`created`, `restarting`, `running`, `removing`, `paused`, `exited` and `dead`. For example,
|
||||
|
@ -191,7 +198,7 @@ CONTAINER ID IMAGE COMMAND CREATED
|
|||
673394ef1d4c busybox "top" About an hour ago Up About an hour (Paused) nostalgic_shockley
|
||||
```
|
||||
|
||||
#### Ancestor
|
||||
#### ancestor
|
||||
|
||||
The `ancestor` filter matches containers based on its image or a descendant of
|
||||
it. The filter supports the following image representation:
|
||||
|
@ -244,7 +251,9 @@ CONTAINER ID IMAGE COMMAND CREATED
|
|||
82a598284012 ubuntu:12.04.5 "top" 3 minutes ago Up 3 minutes sleepy_bose
|
||||
```
|
||||
|
||||
#### Before
|
||||
#### Create time
|
||||
|
||||
##### before
|
||||
|
||||
The `before` filter shows only containers created before the container with
|
||||
given id or name. For example, having these containers created:
|
||||
|
@ -268,7 +277,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
|
|||
6e63f6ff38b0 busybox "top" About a minute ago Up About a minute distracted_fermat
|
||||
```
|
||||
|
||||
#### Since
|
||||
##### since
|
||||
|
||||
The `since` filter shows only containers created since the container with given
|
||||
id or name. For example, with the same containers as in `before` filter:
|
||||
|
@ -281,12 +290,13 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
|
|||
4aace5031105 busybox "top" 10 minutes ago Up 10 minutes focused_hamilton
|
||||
```
|
||||
|
||||
#### Volume
|
||||
#### volume
|
||||
|
||||
The `volume` filter shows only containers that mount a specific volume or have
|
||||
a volume mounted in a specific path:
|
||||
|
||||
```bash{% raw %}
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker ps --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}"
|
||||
CONTAINER ID MOUNTS
|
||||
9c3527ed70ce remote-volume
|
||||
|
@ -294,9 +304,10 @@ CONTAINER ID MOUNTS
|
|||
$ docker ps --filter volume=/data --format "table {{.ID}}\t{{.Mounts}}"
|
||||
CONTAINER ID MOUNTS
|
||||
9c3527ed70ce remote-volume
|
||||
{% endraw %}```
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
#### Network
|
||||
#### network
|
||||
|
||||
The `network` filter shows only containers that are connected to a network with
|
||||
a given name or id.
|
||||
|
@ -331,7 +342,45 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
|
|||
9d4893ed80fe ubuntu "top" 10 minutes ago Up 10 minutes test1
|
||||
```
|
||||
|
||||
## Formatting
|
||||
#### publish and expose
|
||||
|
||||
The `publish` and `expose` filters show only containers that have published or exposed port with a given port
|
||||
number, port range, and/or protocol. The default protocol is `tcp` when not specified.
|
||||
|
||||
The following filter matches all containers that have published port of 80:
|
||||
|
||||
```bash
|
||||
$ docker run -d --publish=80 busybox top
|
||||
$ docker run -d --expose=8080 busybox top
|
||||
|
||||
$ docker ps -a
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
9833437217a5 busybox "top" 5 seconds ago Up 4 seconds 8080/tcp dreamy_mccarthy
|
||||
fc7e477723b7 busybox "top" 50 seconds ago Up 50 seconds 0.0.0.0:32768->80/tcp admiring_roentgen
|
||||
|
||||
$ docker ps --filter publish=80
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
fc7e477723b7 busybox "top" About a minute ago Up About a minute 0.0.0.0:32768->80/tcp admiring_roentgen
|
||||
```
|
||||
|
||||
The following filter matches all containers that have exposed TCP port in the range of `8000-8080`:
|
||||
```bash
|
||||
$ docker ps --filter expose=8000-8080/tcp
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
9833437217a5 busybox "top" 21 seconds ago Up 19 seconds 8080/tcp dreamy_mccarthy
|
||||
```
|
||||
|
||||
The following filter matches all containers that have exposed UDP port `80`:
|
||||
```bash
|
||||
$ docker ps --filter publish=80/udp
|
||||
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
```
|
||||
|
||||
### Formatting
|
||||
|
||||
The formatting option (`--format`) pretty-prints container output using a Go
|
||||
template.
|
||||
|
|
|
@ -26,6 +26,8 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Most of your images will be created on top of a base image from the
|
||||
[Docker Hub](https://hub.docker.com) registry.
|
||||
|
||||
|
@ -35,7 +37,7 @@ can `pull` and try without needing to define and configure your own.
|
|||
To download a particular image, or set of images (i.e., a repository),
|
||||
use `docker pull`.
|
||||
|
||||
## Proxy configuration
|
||||
### Proxy configuration
|
||||
|
||||
If you are behind an HTTP proxy server, for example in corporate settings,
|
||||
before open a connect to registry, you may need to configure the Docker
|
||||
|
@ -44,7 +46,7 @@ environment variables. To set these environment variables on a host using
|
|||
`systemd`, refer to the [control and configure Docker with systemd](https://docs.docker.com/engine/admin/systemd/#http-proxy)
|
||||
for variables configuration.
|
||||
|
||||
## Concurrent downloads
|
||||
### Concurrent downloads
|
||||
|
||||
By default the Docker daemon will pull three layers of an image at a time.
|
||||
If you are on a low bandwidth connection this may cause timeout issues and you may want to lower
|
||||
|
@ -110,7 +112,7 @@ For more information about images, layers, and the content-addressable store,
|
|||
refer to [understand images, containers, and storage drivers](https://docs.docker.com/engine/userguide/storagedriver/imagesandcontainers/).
|
||||
|
||||
|
||||
## Pull an image by digest (immutable identifier)
|
||||
### Pull an image by digest (immutable identifier)
|
||||
|
||||
So far, you've pulled images by their name (and "tag"). Using names and tags is
|
||||
a convenient way to work with images. When using tags, you can `docker pull` an
|
||||
|
@ -175,7 +177,7 @@ MAINTAINER some maintainer <maintainer@example.com>
|
|||
> digest accordingly.
|
||||
|
||||
|
||||
## Pulling from a different registry
|
||||
### Pull from a different registry
|
||||
|
||||
By default, `docker pull` pulls images from [Docker Hub](https://hub.docker.com). It is also possible to
|
||||
manually specify the path of a registry to pull from. For example, if you have
|
||||
|
@ -196,7 +198,7 @@ registry is allowed to be accessed over an insecure connection. Refer to the
|
|||
[insecure registries](dockerd.md#insecure-registries) section for more information.
|
||||
|
||||
|
||||
## Pull a repository with multiple images
|
||||
### Pull a repository with multiple images
|
||||
|
||||
By default, `docker pull` pulls a *single* image from the registry. A repository
|
||||
can contain multiple images. To pull all images from a repository, provide the
|
||||
|
@ -231,7 +233,7 @@ fedora heisenbug 105182bb5e8b 5 days ago 372.7 MB
|
|||
fedora latest 105182bb5e8b 5 days ago 372.7 MB
|
||||
```
|
||||
|
||||
## Canceling a pull
|
||||
### Cancel a pull
|
||||
|
||||
Killing the `docker pull` process, for example by pressing `CTRL-c` while it is
|
||||
running in a terminal, will terminate the pull operation.
|
||||
|
|
|
@ -25,6 +25,8 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Use `docker push` to share your images to the [Docker Hub](https://hub.docker.com)
|
||||
registry or to a self-hosted one.
|
||||
|
||||
|
@ -36,7 +38,7 @@ running in a terminal, terminates the push operation.
|
|||
|
||||
Registry credentials are managed by [docker login](login.md).
|
||||
|
||||
## Concurrent uploads
|
||||
### Concurrent uploads
|
||||
|
||||
By default the Docker daemon will push five layers of an image at a time.
|
||||
If you are on a low bandwidth connection this may cause timeout issues and you may want to lower
|
||||
|
@ -45,7 +47,7 @@ this via the `--max-concurrent-uploads` daemon option. See the
|
|||
|
||||
## Examples
|
||||
|
||||
### Pushing a new image to a registry
|
||||
### Push a new image to a registry
|
||||
|
||||
First save the new image by finding the container ID (using [`docker ps`](ps.md))
|
||||
and then committing it to a new image name. Note that only `a-z0-9-_.` are
|
||||
|
@ -62,6 +64,7 @@ registry:
|
|||
|
||||
```bash
|
||||
$ docker tag rhel-httpd registry-host:5000/myadmin/rhel-httpd
|
||||
|
||||
$ docker push registry-host:5000/myadmin/rhel-httpd
|
||||
```
|
||||
|
||||
|
|
|
@ -24,4 +24,12 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
The `docker rename` command allows the container to be renamed to a different name.
|
||||
## Description
|
||||
|
||||
The `docker rename` command renames a container.
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker rename my_container my_new_container
|
||||
```
|
||||
|
|
|
@ -24,3 +24,9 @@ Options:
|
|||
--help Print usage
|
||||
-t, --time int Seconds to wait for stop before killing the container (default 10)
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker restart my_container
|
||||
```
|
||||
|
|
|
@ -29,40 +29,71 @@ Options:
|
|||
|
||||
## Examples
|
||||
|
||||
$ docker rm /redis
|
||||
/redis
|
||||
### Remove a container
|
||||
|
||||
This will remove the container referenced under the link
|
||||
`/redis`.
|
||||
|
||||
$ docker rm --link /webapp/redis
|
||||
/webapp/redis
|
||||
```bash
|
||||
$ docker rm /redis
|
||||
|
||||
/redis
|
||||
```
|
||||
|
||||
### Remove a link specified with `--link` on the default bridge network
|
||||
|
||||
This will remove the underlying link between `/webapp` and the `/redis`
|
||||
containers removing all network communication.
|
||||
containers on the default bridge network, removing all network communication
|
||||
between the two containers. This does not apply when `--link` is used with
|
||||
user-specified networks.
|
||||
|
||||
$ docker rm --force redis
|
||||
redis
|
||||
```bash
|
||||
$ docker rm --link /webapp/redis
|
||||
|
||||
The main process inside the container referenced under the link `/redis` will receive
|
||||
/webapp/redis
|
||||
```
|
||||
|
||||
### Force-remove a running container
|
||||
|
||||
This command will force-remove a running container.
|
||||
|
||||
```bash
|
||||
$ docker rm --force redis
|
||||
|
||||
redis
|
||||
```
|
||||
|
||||
The main process inside the container referenced under the link `redis` will receive
|
||||
`SIGKILL`, then the container will be removed.
|
||||
|
||||
$ docker rm $(docker ps -a -q)
|
||||
### Remove all stopped containers
|
||||
|
||||
```bash
|
||||
$ docker rm $(docker ps -a -q)
|
||||
```
|
||||
|
||||
This command will delete all stopped containers. The command
|
||||
`docker ps -a -q` will return all existing container IDs and pass them to
|
||||
the `rm` command which will delete them. Any running containers will not be
|
||||
deleted.
|
||||
|
||||
$ docker rm -v redis
|
||||
redis
|
||||
### Remove a container and its volumes
|
||||
|
||||
```bash
|
||||
$ docker rm -v redis
|
||||
redis
|
||||
```
|
||||
|
||||
This command will remove the container and any volumes associated with it.
|
||||
Note that if a volume was specified with a name, it will not be removed.
|
||||
|
||||
$ docker create -v awesome:/foo -v /bar --name hello redis
|
||||
hello
|
||||
$ docker rm -v hello
|
||||
### Remove a container and selectively remove volumes
|
||||
|
||||
```bash
|
||||
$ docker create -v awesome:/foo -v /bar --name hello redis
|
||||
hello
|
||||
$ docker rm -v hello
|
||||
```
|
||||
|
||||
In this example, the volume for `/foo` will remain intact, but the volume for
|
||||
`/bar` will be removed. The same behavior holds for volumes inherited with
|
||||
|
|
|
@ -26,58 +26,80 @@ Options:
|
|||
--no-prune Do not delete untagged parents
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
You can remove an image using its short or long ID, its tag, or its digest. If
|
||||
an image has one or more tag referencing it, you must remove all of them before
|
||||
the image is removed. Digest references are removed automatically when an image
|
||||
is removed by tag.
|
||||
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
```bash
|
||||
$ docker images
|
||||
|
||||
$ docker rmi fd484f19954f
|
||||
Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force
|
||||
2013/12/11 05:47:16 Error: failed to remove one or more images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
|
||||
$ docker rmi test1
|
||||
Untagged: test1:latest
|
||||
$ docker rmi test2
|
||||
Untagged: test2:latest
|
||||
$ docker rmi fd484f19954f
|
||||
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
$ docker rmi test
|
||||
Untagged: test:latest
|
||||
Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
|
||||
Error: Conflict, cannot delete image fd484f19954f because it is tagged in multiple repositories, use -f to force
|
||||
2013/12/11 05:47:16 Error: failed to remove one or more images
|
||||
|
||||
$ docker rmi test1
|
||||
|
||||
Untagged: test1:latest
|
||||
|
||||
$ docker rmi test2
|
||||
|
||||
Untagged: test2:latest
|
||||
|
||||
|
||||
$ docker images
|
||||
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
|
||||
$ docker rmi test
|
||||
|
||||
Untagged: test:latest
|
||||
Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
|
||||
```
|
||||
|
||||
If you use the `-f` flag and specify the image's short or long ID, then this
|
||||
command untags and removes all images that match the specified ID.
|
||||
|
||||
$ docker images
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
```bash
|
||||
$ docker images
|
||||
|
||||
$ docker rmi -f fd484f19954f
|
||||
Untagged: test1:latest
|
||||
Untagged: test:latest
|
||||
Untagged: test2:latest
|
||||
Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
|
||||
REPOSITORY TAG IMAGE ID CREATED SIZE
|
||||
test1 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
test latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
test2 latest fd484f19954f 23 seconds ago 7 B (virtual 4.964 MB)
|
||||
|
||||
$ docker rmi -f fd484f19954f
|
||||
|
||||
Untagged: test1:latest
|
||||
Untagged: test:latest
|
||||
Untagged: test2:latest
|
||||
Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
|
||||
```
|
||||
|
||||
An image pulled by digest has no tag associated with it:
|
||||
|
||||
$ docker images --digests
|
||||
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
|
||||
localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB
|
||||
```bash
|
||||
$ docker images --digests
|
||||
|
||||
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
|
||||
localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB
|
||||
```
|
||||
|
||||
To remove an image using its digest:
|
||||
|
||||
$ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
|
||||
Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
|
||||
Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
|
||||
Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2
|
||||
Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b
|
||||
```bash
|
||||
$ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
|
||||
Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
|
||||
Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125
|
||||
Deleted: ea13149945cb6b1e746bf28032f02e9b5a793523481a0a18645fc77ad53c4ea2
|
||||
Deleted: df7546f9f060a2268024c8a230d8639878585defcc1bc6f79d2728a13957871b
|
||||
```
|
||||
|
|
|
@ -144,6 +144,8 @@ Options:
|
|||
-w, --workdir string Working directory inside the container
|
||||
```
|
||||
|
||||
## Descriptino
|
||||
|
||||
The `docker run` command first `creates` a writeable container layer over the
|
||||
specified image, and then `starts` it using the specified command. That is,
|
||||
`docker run` is equivalent to the API `/containers/create` then
|
||||
|
@ -160,12 +162,15 @@ For information on connecting a container to a network, see the ["*Docker networ
|
|||
|
||||
### Assign name and allocate pseudo-TTY (--name, -it)
|
||||
|
||||
$ docker run --name test -it debian
|
||||
root@d6c0fe130dba:/# exit 13
|
||||
$ echo $?
|
||||
13
|
||||
$ docker ps -a | grep test
|
||||
d6c0fe130dba debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test
|
||||
```bash
|
||||
$ docker run --name test -it debian
|
||||
|
||||
root@d6c0fe130dba:/# exit 13
|
||||
$ echo $?
|
||||
13
|
||||
$ docker ps -a | grep test
|
||||
d6c0fe130dba debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test
|
||||
```
|
||||
|
||||
This example runs a container named `test` using the `debian:latest`
|
||||
image. The `-it` instructs Docker to allocate a pseudo-TTY connected to
|
||||
|
@ -176,7 +181,9 @@ In the example, the `bash` shell is quit by entering
|
|||
|
||||
### Capture container ID (--cidfile)
|
||||
|
||||
$ docker run --cidfile /tmp/docker_test.cid ubuntu echo "test"
|
||||
```bash
|
||||
$ docker run --cidfile /tmp/docker_test.cid ubuntu echo "test"
|
||||
```
|
||||
|
||||
This will create a container and print `test` to the console. The `cidfile`
|
||||
flag makes Docker attempt to create a new file and write the container ID to it.
|
||||
|
@ -185,19 +192,23 @@ file when `docker run` exits.
|
|||
|
||||
### Full container capabilities (--privileged)
|
||||
|
||||
$ docker run -t -i --rm ubuntu bash
|
||||
root@bc338942ef20:/# mount -t tmpfs none /mnt
|
||||
mount: permission denied
|
||||
```bash
|
||||
$ docker run -t -i --rm ubuntu bash
|
||||
root@bc338942ef20:/# mount -t tmpfs none /mnt
|
||||
mount: permission denied
|
||||
```
|
||||
|
||||
This will *not* work, because by default, most potentially dangerous kernel
|
||||
capabilities are dropped; including `cap_sys_admin` (which is required to mount
|
||||
filesystems). However, the `--privileged` flag will allow it to run:
|
||||
|
||||
$ docker run -t -i --privileged ubuntu bash
|
||||
root@50e3f57e16e6:/# mount -t tmpfs none /mnt
|
||||
root@50e3f57e16e6:/# df -h
|
||||
Filesystem Size Used Avail Use% Mounted on
|
||||
none 1.9G 0 1.9G 0% /mnt
|
||||
```bash
|
||||
$ docker run -t -i --privileged ubuntu bash
|
||||
root@50e3f57e16e6:/# mount -t tmpfs none /mnt
|
||||
root@50e3f57e16e6:/# df -h
|
||||
Filesystem Size Used Avail Use% Mounted on
|
||||
none 1.9G 0 1.9G 0% /mnt
|
||||
```
|
||||
|
||||
The `--privileged` flag gives *all* capabilities to the container, and it also
|
||||
lifts all the limitations enforced by the `device` cgroup controller. In other
|
||||
|
@ -206,14 +217,18 @@ flag exists to allow special use-cases, like running Docker within Docker.
|
|||
|
||||
### Set working directory (-w)
|
||||
|
||||
$ docker run -w /path/to/dir/ -i -t ubuntu pwd
|
||||
```bash
|
||||
$ docker run -w /path/to/dir/ -i -t ubuntu pwd
|
||||
```
|
||||
|
||||
The `-w` lets the command being executed inside directory given, here
|
||||
`/path/to/dir/`. If the path does not exist it is created inside the container.
|
||||
|
||||
### Set storage driver options per container
|
||||
|
||||
$ docker run -it --storage-opt size=120G fedora /bin/bash
|
||||
```bash
|
||||
$ docker run -it --storage-opt size=120G fedora /bin/bash
|
||||
```
|
||||
|
||||
This (size) will allow to set the container rootfs size to 120G at creation time.
|
||||
This option is only available for the `devicemapper`, `btrfs`, `overlay2`,
|
||||
|
@ -226,14 +241,18 @@ Under these conditions, user can pass any size less then the backing fs size.
|
|||
|
||||
### Mount tmpfs (--tmpfs)
|
||||
|
||||
$ docker run -d --tmpfs /run:rw,noexec,nosuid,size=65536k my_image
|
||||
```bash
|
||||
$ docker run -d --tmpfs /run:rw,noexec,nosuid,size=65536k my_image
|
||||
```
|
||||
|
||||
The `--tmpfs` flag mounts an empty tmpfs into the container with the `rw`,
|
||||
`noexec`, `nosuid`, `size=65536k` options.
|
||||
|
||||
### Mount volume (-v, --read-only)
|
||||
|
||||
$ docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd
|
||||
```bash
|
||||
$ docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd
|
||||
```
|
||||
|
||||
The `-v` flag mounts the current working directory into the container. The `-w`
|
||||
lets the command being executed inside the current working directory, by
|
||||
|
@ -241,21 +260,27 @@ changing into the directory to the value returned by `pwd`. So this
|
|||
combination executes the command using the container, but inside the
|
||||
current working directory.
|
||||
|
||||
$ docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash
|
||||
```bash
|
||||
$ docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash
|
||||
```
|
||||
|
||||
When the host directory of a bind-mounted volume doesn't exist, Docker
|
||||
will automatically create this directory on the host for you. In the
|
||||
example above, Docker will create the `/doesnt/exist`
|
||||
folder before starting your container.
|
||||
|
||||
$ docker run --read-only -v /icanwrite busybox touch /icanwrite/here
|
||||
```bash
|
||||
$ docker run --read-only -v /icanwrite busybox touch /icanwrite/here
|
||||
```
|
||||
|
||||
Volumes can be used in combination with `--read-only` to control where
|
||||
a container writes files. The `--read-only` flag mounts the container's root
|
||||
filesystem as read only prohibiting writes to locations other than the
|
||||
specified volumes for the container.
|
||||
|
||||
$ docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v /path/to/static-docker-binary:/usr/bin/docker busybox sh
|
||||
```bash
|
||||
$ docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v /path/to/static-docker-binary:/usr/bin/docker busybox sh
|
||||
```
|
||||
|
||||
By bind-mounting the docker unix socket and statically linked docker
|
||||
binary (refer to [get the linux binary](
|
||||
|
@ -263,45 +288,55 @@ https://docs.docker.com/engine/installation/binaries/#/get-the-linux-binary)),
|
|||
you give the container the full access to create and manipulate the host's
|
||||
Docker daemon.
|
||||
|
||||
On Windows, the paths must be specified using Windows-style semantics.
|
||||
On Windows, the paths must be specified using Windows-style semantics.
|
||||
|
||||
PS C:\> docker run -v c:\foo:c:\dest microsoft/nanoserver cmd /s /c type c:\dest\somefile.txt
|
||||
Contents of file
|
||||
|
||||
PS C:\> docker run -v c:\foo:d: microsoft/nanoserver cmd /s /c type d:\somefile.txt
|
||||
Contents of file
|
||||
```powershell
|
||||
PS C:\> docker run -v c:\foo:c:\dest microsoft/nanoserver cmd /s /c type c:\dest\somefile.txt
|
||||
Contents of file
|
||||
|
||||
The following examples will fail when using Windows-based containers, as the
|
||||
destination of a volume or bind-mount inside the container must be one of:
|
||||
PS C:\> docker run -v c:\foo:d: microsoft/nanoserver cmd /s /c type d:\somefile.txt
|
||||
Contents of file
|
||||
```
|
||||
|
||||
The following examples will fail when using Windows-based containers, as the
|
||||
destination of a volume or bind-mount inside the container must be one of:
|
||||
a non-existing or empty directory; or a drive other than C:. Further, the source
|
||||
of a bind mount must be a local directory, not a file.
|
||||
|
||||
net use z: \\remotemachine\share
|
||||
docker run -v z:\foo:c:\dest ...
|
||||
docker run -v \\uncpath\to\directory:c:\dest ...
|
||||
docker run -v c:\foo\somefile.txt:c:\dest ...
|
||||
docker run -v c:\foo:c: ...
|
||||
docker run -v c:\foo:c:\existing-directory-with-contents ...
|
||||
```powershell
|
||||
net use z: \\remotemachine\share
|
||||
docker run -v z:\foo:c:\dest ...
|
||||
docker run -v \\uncpath\to\directory:c:\dest ...
|
||||
docker run -v c:\foo\somefile.txt:c:\dest ...
|
||||
docker run -v c:\foo:c: ...
|
||||
docker run -v c:\foo:c:\existing-directory-with-contents ...
|
||||
```
|
||||
|
||||
For in-depth information about volumes, refer to [manage data in containers](https://docs.docker.com/engine/tutorials/dockervolumes/)
|
||||
|
||||
### Publish or expose port (-p, --expose)
|
||||
|
||||
$ docker run -p 127.0.0.1:80:8080 ubuntu bash
|
||||
```bash
|
||||
$ docker run -p 127.0.0.1:80:8080 ubuntu bash
|
||||
```
|
||||
|
||||
This binds port `8080` of the container to port `80` on `127.0.0.1` of the host
|
||||
machine. The [Docker User
|
||||
Guide](https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/)
|
||||
explains in detail how to manipulate ports in Docker.
|
||||
|
||||
$ docker run --expose 80 ubuntu bash
|
||||
```bash
|
||||
$ docker run --expose 80 ubuntu bash
|
||||
```
|
||||
|
||||
This exposes port `80` of the container without publishing the port to the host
|
||||
system's interfaces.
|
||||
|
||||
### Set environment variables (-e, --env, --env-file)
|
||||
|
||||
$ docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash
|
||||
```bash
|
||||
$ docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash
|
||||
```
|
||||
|
||||
This sets simple (non-array) environmental variables in the container. For
|
||||
illustration all three
|
||||
|
@ -317,10 +352,12 @@ Regardless of the order of these three flags, the `--env-file` are processed
|
|||
first, and then `-e`, `--env` flags. This way, the `-e` or `--env` will
|
||||
override variables as needed.
|
||||
|
||||
$ cat ./env.list
|
||||
TEST_FOO=BAR
|
||||
$ docker run --env TEST_FOO="This is a test" --env-file ./env.list busybox env | grep TEST_FOO
|
||||
TEST_FOO=This is a test
|
||||
```bash
|
||||
$ cat ./env.list
|
||||
TEST_FOO=BAR
|
||||
$ docker run --env TEST_FOO="This is a test" --env-file ./env.list busybox env | grep TEST_FOO
|
||||
TEST_FOO=This is a test
|
||||
```
|
||||
|
||||
The `--env-file` flag takes a filename as an argument and expects each line
|
||||
to be in the `VAR=VAL` format, mimicking the argument passed to `--env`. Comment
|
||||
|
@ -328,53 +365,57 @@ lines need only be prefixed with `#`
|
|||
|
||||
An example of a file passed with `--env-file`
|
||||
|
||||
$ cat ./env.list
|
||||
TEST_FOO=BAR
|
||||
```bash
|
||||
$ cat ./env.list
|
||||
TEST_FOO=BAR
|
||||
|
||||
# this is a comment
|
||||
TEST_APP_DEST_HOST=10.10.0.127
|
||||
TEST_APP_DEST_PORT=8888
|
||||
_TEST_BAR=FOO
|
||||
TEST_APP_42=magic
|
||||
helloWorld=true
|
||||
123qwe=bar
|
||||
org.spring.config=something
|
||||
# this is a comment
|
||||
TEST_APP_DEST_HOST=10.10.0.127
|
||||
TEST_APP_DEST_PORT=8888
|
||||
_TEST_BAR=FOO
|
||||
TEST_APP_42=magic
|
||||
helloWorld=true
|
||||
123qwe=bar
|
||||
org.spring.config=something
|
||||
|
||||
# pass through this variable from the caller
|
||||
TEST_PASSTHROUGH
|
||||
$ TEST_PASSTHROUGH=howdy docker run --env-file ./env.list busybox env
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
HOSTNAME=5198e0745561
|
||||
TEST_FOO=BAR
|
||||
TEST_APP_DEST_HOST=10.10.0.127
|
||||
TEST_APP_DEST_PORT=8888
|
||||
_TEST_BAR=FOO
|
||||
TEST_APP_42=magic
|
||||
helloWorld=true
|
||||
TEST_PASSTHROUGH=howdy
|
||||
HOME=/root
|
||||
123qwe=bar
|
||||
org.spring.config=something
|
||||
# pass through this variable from the caller
|
||||
TEST_PASSTHROUGH
|
||||
$ TEST_PASSTHROUGH=howdy docker run --env-file ./env.list busybox env
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
HOSTNAME=5198e0745561
|
||||
TEST_FOO=BAR
|
||||
TEST_APP_DEST_HOST=10.10.0.127
|
||||
TEST_APP_DEST_PORT=8888
|
||||
_TEST_BAR=FOO
|
||||
TEST_APP_42=magic
|
||||
helloWorld=true
|
||||
TEST_PASSTHROUGH=howdy
|
||||
HOME=/root
|
||||
123qwe=bar
|
||||
org.spring.config=something
|
||||
|
||||
$ docker run --env-file ./env.list busybox env
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
HOSTNAME=5198e0745561
|
||||
TEST_FOO=BAR
|
||||
TEST_APP_DEST_HOST=10.10.0.127
|
||||
TEST_APP_DEST_PORT=8888
|
||||
_TEST_BAR=FOO
|
||||
TEST_APP_42=magic
|
||||
helloWorld=true
|
||||
TEST_PASSTHROUGH=
|
||||
HOME=/root
|
||||
123qwe=bar
|
||||
org.spring.config=something
|
||||
$ docker run --env-file ./env.list busybox env
|
||||
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
HOSTNAME=5198e0745561
|
||||
TEST_FOO=BAR
|
||||
TEST_APP_DEST_HOST=10.10.0.127
|
||||
TEST_APP_DEST_PORT=8888
|
||||
_TEST_BAR=FOO
|
||||
TEST_APP_42=magic
|
||||
helloWorld=true
|
||||
TEST_PASSTHROUGH=
|
||||
HOME=/root
|
||||
123qwe=bar
|
||||
org.spring.config=something
|
||||
```
|
||||
|
||||
### Set metadata on container (-l, --label, --label-file)
|
||||
|
||||
A label is a `key=value` pair that applies metadata to a container. To label a container with two labels:
|
||||
|
||||
$ docker run -l my-label --label com.example.foo=bar ubuntu bash
|
||||
```bash
|
||||
$ docker run -l my-label --label com.example.foo=bar ubuntu bash
|
||||
```
|
||||
|
||||
The `my-label` key doesn't specify a value so the label defaults to an empty
|
||||
string(`""`). To add multiple labels, repeat the label flag (`-l` or `--label`).
|
||||
|
@ -387,18 +428,22 @@ Use the `--label-file` flag to load multiple labels from a file. Delimit each
|
|||
label in the file with an EOL mark. The example below loads labels from a
|
||||
labels file in the current directory:
|
||||
|
||||
$ docker run --label-file ./labels ubuntu bash
|
||||
```bash
|
||||
$ docker run --label-file ./labels ubuntu bash
|
||||
```
|
||||
|
||||
The label-file format is similar to the format for loading environment
|
||||
variables. (Unlike environment variables, labels are not visible to processes
|
||||
running inside a container.) The following example illustrates a label-file
|
||||
format:
|
||||
|
||||
com.example.label1="a label"
|
||||
```none
|
||||
com.example.label1="a label"
|
||||
|
||||
# this is a comment
|
||||
com.example.label2=another\ label
|
||||
com.example.label3
|
||||
# this is a comment
|
||||
com.example.label2=another\ label
|
||||
com.example.label3
|
||||
```
|
||||
|
||||
You can load multiple label-files by supplying multiple `--label-file` flags.
|
||||
|
||||
|
@ -430,16 +475,18 @@ or name. For `overlay` networks or custom plugins that support multi-host
|
|||
connectivity, containers connected to the same multi-host network but launched
|
||||
from different Engines can also communicate in this way.
|
||||
|
||||
**Note**: Service discovery is unavailable on the default bridge network.
|
||||
Containers can communicate via their IP addresses by default. To communicate
|
||||
by name, they must be linked.
|
||||
> **Note**: Service discovery is unavailable on the default bridge network.
|
||||
> Containers can communicate via their IP addresses by default. To communicate
|
||||
> by name, they must be linked.
|
||||
|
||||
You can disconnect a container from a network using the `docker network
|
||||
disconnect` command.
|
||||
|
||||
### Mount volumes from container (--volumes-from)
|
||||
|
||||
$ docker run --volumes-from 777f7dc92da7 --volumes-from ba8c0c54f0f2:ro -i -t ubuntu pwd
|
||||
```bash
|
||||
$ docker run --volumes-from 777f7dc92da7 --volumes-from ba8c0c54f0f2:ro -i -t ubuntu pwd
|
||||
```
|
||||
|
||||
The `--volumes-from` flag mounts all the defined volumes from the referenced
|
||||
containers. Containers can be specified by repetitions of the `--volumes-from`
|
||||
|
@ -467,18 +514,24 @@ The `-a` flag tells `docker run` to bind to the container's `STDIN`, `STDOUT`
|
|||
or `STDERR`. This makes it possible to manipulate the output and input as
|
||||
needed.
|
||||
|
||||
$ echo "test" | docker run -i -a stdin ubuntu cat -
|
||||
```bash
|
||||
$ echo "test" | docker run -i -a stdin ubuntu cat -
|
||||
```
|
||||
|
||||
This pipes data into a container and prints the container's ID by attaching
|
||||
only to the container's `STDIN`.
|
||||
|
||||
$ docker run -a stderr ubuntu echo test
|
||||
```bash
|
||||
$ docker run -a stderr ubuntu echo test
|
||||
```
|
||||
|
||||
This isn't going to print anything unless there's an error because we've
|
||||
only attached to the `STDERR` of the container. The container's logs
|
||||
still store what's been written to `STDERR` and `STDOUT`.
|
||||
|
||||
$ cat somefile | docker run -i -a stdin mybuilder dobuild
|
||||
```bash
|
||||
$ cat somefile | docker run -i -a stdin mybuilder dobuild
|
||||
```
|
||||
|
||||
This is how piping a file into a container could be done for a build.
|
||||
The container's ID will be printed after the build is done and the build
|
||||
|
@ -488,10 +541,18 @@ retrieve the container's ID once the container has finished running.
|
|||
|
||||
### Add host device to container (--device)
|
||||
|
||||
$ docker run --device=/dev/sdc:/dev/xvdc --device=/dev/sdd --device=/dev/zero:/dev/nulo -i -t ubuntu ls -l /dev/{xvdc,sdd,nulo}
|
||||
brw-rw---- 1 root disk 8, 2 Feb 9 16:05 /dev/xvdc
|
||||
brw-rw---- 1 root disk 8, 3 Feb 9 16:05 /dev/sdd
|
||||
crw-rw-rw- 1 root root 1, 5 Feb 9 16:05 /dev/nulo
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker run --device=/dev/sdc:/dev/xvdc \
|
||||
--device=/dev/sdd --device=/dev/zero:/dev/nulo \
|
||||
-i -t \
|
||||
ubuntu ls -l /dev/{xvdc,sdd,nulo}
|
||||
|
||||
brw-rw---- 1 root disk 8, 2 Feb 9 16:05 /dev/xvdc
|
||||
brw-rw---- 1 root disk 8, 3 Feb 9 16:05 /dev/sdd
|
||||
crw-rw-rw- 1 root root 1, 5 Feb 9 16:05 /dev/nulo
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
It is often necessary to directly expose devices to a container. The `--device`
|
||||
option enables that. For example, a specific block storage device or loop
|
||||
|
@ -502,24 +563,24 @@ By default, the container will be able to `read`, `write` and `mknod` these devi
|
|||
This can be overridden using a third `:rwm` set of options to each `--device`
|
||||
flag:
|
||||
|
||||
```bash
|
||||
$ docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc
|
||||
|
||||
$ docker run --device=/dev/sda:/dev/xvdc --rm -it ubuntu fdisk /dev/xvdc
|
||||
Command (m for help): q
|
||||
$ docker run --device=/dev/sda:/dev/xvdc:r --rm -it ubuntu fdisk /dev/xvdc
|
||||
You will not be able to write the partition table.
|
||||
|
||||
Command (m for help): q
|
||||
$ docker run --device=/dev/sda:/dev/xvdc:r --rm -it ubuntu fdisk /dev/xvdc
|
||||
You will not be able to write the partition table.
|
||||
Command (m for help): q
|
||||
|
||||
Command (m for help): q
|
||||
$ docker run --device=/dev/sda:/dev/xvdc:rw --rm -it ubuntu fdisk /dev/xvdc
|
||||
|
||||
$ docker run --device=/dev/sda:/dev/xvdc:rw --rm -it ubuntu fdisk /dev/xvdc
|
||||
Command (m for help): q
|
||||
|
||||
Command (m for help): q
|
||||
$ docker run --device=/dev/sda:/dev/xvdc:m --rm -it ubuntu fdisk /dev/xvdc
|
||||
fdisk: unable to open /dev/xvdc: Operation not permitted
|
||||
```
|
||||
|
||||
$ docker run --device=/dev/sda:/dev/xvdc:m --rm -it ubuntu fdisk /dev/xvdc
|
||||
fdisk: unable to open /dev/xvdc: Operation not permitted
|
||||
|
||||
> **Note:**
|
||||
> `--device` cannot be safely used with ephemeral devices. Block devices
|
||||
> **Note**: `--device` cannot be safely used with ephemeral devices. Block devices
|
||||
> that may be removed should not be added to untrusted containers with
|
||||
> `--device`.
|
||||
|
||||
|
@ -529,54 +590,15 @@ Use Docker's `--restart` to specify a container's *restart policy*. A restart
|
|||
policy controls whether the Docker daemon restarts a container after exit.
|
||||
Docker supports the following restart policies:
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Policy</th>
|
||||
<th>Result</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><strong>no</strong></td>
|
||||
<td>
|
||||
Do not automatically restart the container when it exits. This is the
|
||||
default.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span style="white-space: nowrap">
|
||||
<strong>on-failure</strong>[:max-retries]
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
Restart only if the container exits with a non-zero exit status.
|
||||
Optionally, limit the number of restart retries the Docker
|
||||
daemon attempts.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>always</strong></td>
|
||||
<td>
|
||||
Always restart the container regardless of the exit status.
|
||||
When you specify always, the Docker daemon will try to restart
|
||||
the container indefinitely. The container will also always start
|
||||
on daemon startup, regardless of the current state of the container.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>unless-stopped</strong></td>
|
||||
<td>
|
||||
Always restart the container regardless of the exit status, but
|
||||
do not start it on daemon startup if the container has been put
|
||||
to a stopped state before.
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
| Policy | Result |
|
||||
|-------------------|-----------------------------------------|
|
||||
| `no` | Do not automatically restart the container when it exits. This is the default. |
|
||||
| `failure` | Restart only if the container exits with a non-zero exit status. Optionally, limit the number of restart retries the Docker daemon attempts. |
|
||||
| `always` | Always restart the container regardless of the exit status. When you specify always, the Docker daemon will try to restart the container indefinitely. The container will also always start on daemon startup, regardless of the current state of the container. |
|
||||
|
||||
$ docker run --restart=always redis
|
||||
```bash
|
||||
$ docker run --restart=always redis
|
||||
```
|
||||
|
||||
This will run the `redis` container with a restart policy of **always**
|
||||
so that if the container exits, Docker will restart it.
|
||||
|
@ -591,14 +613,17 @@ You can add other hosts into a container's `/etc/hosts` file by using one or
|
|||
more `--add-host` flags. This example adds a static address for a host named
|
||||
`docker`:
|
||||
|
||||
$ docker run --add-host=docker:10.180.0.1 --rm -it debian
|
||||
root@f38c87f2a42d:/# ping docker
|
||||
PING docker (10.180.0.1): 48 data bytes
|
||||
56 bytes from 10.180.0.1: icmp_seq=0 ttl=254 time=7.600 ms
|
||||
56 bytes from 10.180.0.1: icmp_seq=1 ttl=254 time=30.705 ms
|
||||
^C--- docker ping statistics ---
|
||||
2 packets transmitted, 2 packets received, 0% packet loss
|
||||
round-trip min/avg/max/stddev = 7.600/19.152/30.705/11.553 ms
|
||||
```bash
|
||||
$ docker run --add-host=docker:10.180.0.1 --rm -it debian
|
||||
|
||||
root@f38c87f2a42d:/# ping docker
|
||||
PING docker (10.180.0.1): 48 data bytes
|
||||
56 bytes from 10.180.0.1: icmp_seq=0 ttl=254 time=7.600 ms
|
||||
56 bytes from 10.180.0.1: icmp_seq=1 ttl=254 time=30.705 ms
|
||||
^C--- docker ping statistics ---
|
||||
2 packets transmitted, 2 packets received, 0% packet loss
|
||||
round-trip min/avg/max/stddev = 7.600/19.152/30.705/11.553 ms
|
||||
```
|
||||
|
||||
Sometimes you need to connect to the Docker host from within your
|
||||
container. To enable this, pass the Docker host's IP address to
|
||||
|
@ -609,8 +634,12 @@ The flags you pass to `ip addr show` depend on whether you are
|
|||
using IPv4 or IPv6 networking in your containers. Use the following
|
||||
flags for IPv4 address retrieval for a network device named `eth0`:
|
||||
|
||||
$ HOSTIP=`ip -4 addr show scope global dev eth0 | grep inet | awk '{print \$2}' | cut -d / -f 1`
|
||||
$ docker run --add-host=docker:${HOSTIP} --rm -it debian
|
||||
```bash
|
||||
{% raw %}
|
||||
$ HOSTIP=`ip -4 addr show scope global dev eth0 | grep inet | awk '{print \$2}' | cut -d / -f 1`
|
||||
$ docker run --add-host=docker:${HOSTIP} --rm -it debian
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
For IPv6 use the `-6` flag instead of the `-4` flag. For other network
|
||||
devices, replace `eth0` with the correct device name (for example `docker0`
|
||||
|
@ -623,15 +652,19 @@ available in the default container, you can set these using the `--ulimit` flag.
|
|||
`--ulimit` is specified with a soft and hard limit as such:
|
||||
`<type>=<soft limit>[:<hard limit>]`, for example:
|
||||
|
||||
$ docker run --ulimit nofile=1024:1024 --rm debian sh -c "ulimit -n"
|
||||
1024
|
||||
```bash
|
||||
$ docker run --ulimit nofile=1024:1024 --rm debian sh -c "ulimit -n"
|
||||
1024
|
||||
```
|
||||
|
||||
> **Note:**
|
||||
> If you do not provide a `hard limit`, the `soft limit` will be used
|
||||
> **Note**: If you do not provide a `hard limit`, the `soft limit` will be used
|
||||
> for both values. If no `ulimits` are set, they will be inherited from
|
||||
> the default `ulimits` set on the daemon. `as` option is disabled now.
|
||||
> In other words, the following script is not supported:
|
||||
> `$ docker run -it --ulimit as=1024 fedora /bin/bash`
|
||||
>
|
||||
> ```bash
|
||||
> $ docker run -it --ulimit as=1024 fedora /bin/bash`
|
||||
> ```
|
||||
|
||||
The values are sent to the appropriate `syscall` as they are set.
|
||||
Docker doesn't perform any byte conversion. Take this into account when setting the values.
|
||||
|
@ -642,10 +675,15 @@ Be careful setting `nproc` with the `ulimit` flag as `nproc` is designed by Linu
|
|||
maximum number of processes available to a user, not to a container. For example, start four
|
||||
containers with `daemon` user:
|
||||
|
||||
docker run -d -u daemon --ulimit nproc=3 busybox top
|
||||
docker run -d -u daemon --ulimit nproc=3 busybox top
|
||||
docker run -d -u daemon --ulimit nproc=3 busybox top
|
||||
docker run -d -u daemon --ulimit nproc=3 busybox top
|
||||
```bash
|
||||
$ docker run -d -u daemon --ulimit nproc=3 busybox top
|
||||
|
||||
$ docker run -d -u daemon --ulimit nproc=3 busybox top
|
||||
|
||||
$ docker run -d -u daemon --ulimit nproc=3 busybox top
|
||||
|
||||
$ docker run -d -u daemon --ulimit nproc=3 busybox top
|
||||
```
|
||||
|
||||
The 4th container fails and reports "[8] System error: resource temporarily unavailable" error.
|
||||
This fails because the caller set `nproc=3` resulting in the first three containers using up
|
||||
|
@ -710,8 +748,9 @@ The `--sysctl` sets namespaced kernel parameters (sysctls) in the
|
|||
container. For example, to turn on IP forwarding in the containers
|
||||
network namespace, run this command:
|
||||
|
||||
$ docker run --sysctl net.ipv4.ip_forward=1 someimage
|
||||
|
||||
```bash
|
||||
$ docker run --sysctl net.ipv4.ip_forward=1 someimage
|
||||
```
|
||||
|
||||
> **Note**: Not all sysctls are namespaced. Docker does not support changing sysctls
|
||||
> inside of a container that also modify the host system. As the kernel
|
||||
|
@ -719,14 +758,17 @@ network namespace, run this command:
|
|||
|
||||
#### Currently supported sysctls
|
||||
|
||||
`IPC Namespace`:
|
||||
- `IPC Namespace`:
|
||||
|
||||
```none
|
||||
kernel.msgmax, kernel.msgmnb, kernel.msgmni, kernel.sem, kernel.shmall, kernel.shmmax, kernel.shmmni, kernel.shm_rmid_forced
|
||||
Sysctls beginning with fs.mqueue.*
|
||||
```
|
||||
|
||||
If you use the `--ipc=host` option these sysctls will not be allowed.
|
||||
|
||||
`Network Namespace`:
|
||||
Sysctls beginning with net.*
|
||||
- `Network Namespace`:
|
||||
|
||||
Sysctls beginning with net.*
|
||||
|
||||
If you use the `--network=host` option using these sysctls will not be allowed.
|
||||
|
|
|
@ -25,21 +25,38 @@ Options:
|
|||
-o, --output string Write to a file, instead of STDOUT
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Produces a tarred repository to the standard output stream.
|
||||
Contains all parent layers, and all tags + versions, or specified `repo:tag`, for
|
||||
each argument provided.
|
||||
|
||||
It is used to create a backup that can then be used with `docker load`
|
||||
## Examples
|
||||
|
||||
$ docker save busybox > busybox.tar
|
||||
$ ls -sh busybox.tar
|
||||
2.7M busybox.tar
|
||||
$ docker save --output busybox.tar busybox
|
||||
$ ls -sh busybox.tar
|
||||
2.7M busybox.tar
|
||||
$ docker save -o fedora-all.tar fedora
|
||||
$ docker save -o fedora-latest.tar fedora:latest
|
||||
### Create a backup that can then be used with `docker load`.
|
||||
|
||||
It is even useful to cherry-pick particular tags of an image repository
|
||||
```bash
|
||||
$ docker save busybox > busybox.tar
|
||||
|
||||
$ docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy
|
||||
$ ls -sh busybox.tar
|
||||
|
||||
2.7M busybox.tar
|
||||
|
||||
$ docker save --output busybox.tar busybox
|
||||
|
||||
$ ls -sh busybox.tar
|
||||
|
||||
2.7M busybox.tar
|
||||
|
||||
$ docker save -o fedora-all.tar fedora
|
||||
|
||||
$ docker save -o fedora-latest.tar fedora:latest
|
||||
```
|
||||
|
||||
### Cherry-pick particular tags
|
||||
|
||||
You can even cherry-pick particular tags of an image repository.
|
||||
|
||||
```bash
|
||||
$ docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy
|
||||
```
|
||||
|
|
|
@ -30,13 +30,14 @@ Options:
|
|||
--no-trunc Don't truncate output
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Search [Docker Hub](https://hub.docker.com) for images
|
||||
|
||||
See [*Find Public Images on Docker Hub*](https://docs.docker.com/engine/tutorials/dockerrepos/#searching-for-images) for
|
||||
more details on finding shared images from the command line.
|
||||
|
||||
> **Note:**
|
||||
> Search queries will only return up to 25 results
|
||||
> **Note**: Search queries return a maximum of 25 results.
|
||||
|
||||
## Examples
|
||||
|
||||
|
@ -44,52 +45,57 @@ more details on finding shared images from the command line.
|
|||
|
||||
This example displays images with a name containing 'busybox':
|
||||
|
||||
$ docker search busybox
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
busybox Busybox base image. 316 [OK]
|
||||
progrium/busybox 50 [OK]
|
||||
radial/busyboxplus Full-chain, Internet enabled, busybox made... 8 [OK]
|
||||
odise/busybox-python 2 [OK]
|
||||
azukiapp/busybox This image is meant to be used as the base... 2 [OK]
|
||||
ofayau/busybox-jvm Prepare busybox to install a 32 bits JVM. 1 [OK]
|
||||
shingonoide/archlinux-busybox Arch Linux, a lightweight and flexible Lin... 1 [OK]
|
||||
odise/busybox-curl 1 [OK]
|
||||
ofayau/busybox-libc32 Busybox with 32 bits (and 64 bits) libs 1 [OK]
|
||||
peelsky/zulu-openjdk-busybox 1 [OK]
|
||||
skomma/busybox-data Docker image suitable for data volume cont... 1 [OK]
|
||||
elektritter/busybox-teamspeak Lightweight teamspeak3 container based on... 1 [OK]
|
||||
socketplane/busybox 1 [OK]
|
||||
oveits/docker-nginx-busybox This is a tiny NginX docker image based on... 0 [OK]
|
||||
ggtools/busybox-ubuntu Busybox ubuntu version with extra goodies 0 [OK]
|
||||
nikfoundas/busybox-confd Minimal busybox based distribution of confd 0 [OK]
|
||||
openshift/busybox-http-app 0 [OK]
|
||||
jllopis/busybox 0 [OK]
|
||||
swyckoff/busybox 0 [OK]
|
||||
powellquiring/busybox 0 [OK]
|
||||
williamyeh/busybox-sh Docker image for BusyBox's sh 0 [OK]
|
||||
simplexsys/busybox-cli-powered Docker busybox images, with a few often us... 0 [OK]
|
||||
fhisamoto/busybox-java Busybox java 0 [OK]
|
||||
scottabernethy/busybox 0 [OK]
|
||||
marclop/busybox-solr
|
||||
```none
|
||||
$ docker search busybox
|
||||
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
busybox Busybox base image. 316 [OK]
|
||||
progrium/busybox 50 [OK]
|
||||
radial/busyboxplus Full-chain, Internet enabled, busybox made... 8 [OK]
|
||||
odise/busybox-python 2 [OK]
|
||||
azukiapp/busybox This image is meant to be used as the base... 2 [OK]
|
||||
ofayau/busybox-jvm Prepare busybox to install a 32 bits JVM. 1 [OK]
|
||||
shingonoide/archlinux-busybox Arch Linux, a lightweight and flexible Lin... 1 [OK]
|
||||
odise/busybox-curl 1 [OK]
|
||||
ofayau/busybox-libc32 Busybox with 32 bits (and 64 bits) libs 1 [OK]
|
||||
peelsky/zulu-openjdk-busybox 1 [OK]
|
||||
skomma/busybox-data Docker image suitable for data volume cont... 1 [OK]
|
||||
elektritter/busybox-teamspeak Lightweight teamspeak3 container based on... 1 [OK]
|
||||
socketplane/busybox 1 [OK]
|
||||
oveits/docker-nginx-busybox This is a tiny NginX docker image based on... 0 [OK]
|
||||
ggtools/busybox-ubuntu Busybox ubuntu version with extra goodies 0 [OK]
|
||||
nikfoundas/busybox-confd Minimal busybox based distribution of confd 0 [OK]
|
||||
openshift/busybox-http-app 0 [OK]
|
||||
jllopis/busybox 0 [OK]
|
||||
swyckoff/busybox 0 [OK]
|
||||
powellquiring/busybox 0 [OK]
|
||||
williamyeh/busybox-sh Docker image for BusyBox's sh 0 [OK]
|
||||
simplexsys/busybox-cli-powered Docker busybox images, with a few often us... 0 [OK]
|
||||
fhisamoto/busybox-java Busybox java 0 [OK]
|
||||
scottabernethy/busybox 0 [OK]
|
||||
marclop/busybox-solr
|
||||
```
|
||||
|
||||
### Display non-truncated description (--no-trunc)
|
||||
|
||||
This example displays images with a name containing 'busybox',
|
||||
at least 3 stars and the description isn't truncated in the output:
|
||||
|
||||
$ docker search --stars=3 --no-trunc busybox
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
busybox Busybox base image. 325 [OK]
|
||||
progrium/busybox 50 [OK]
|
||||
radial/busyboxplus Full-chain, Internet enabled, busybox made from scratch. Comes in git and cURL flavors. 8 [OK]
|
||||
```bash
|
||||
$ docker search --stars=3 --no-trunc busybox
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
busybox Busybox base image. 325 [OK]
|
||||
progrium/busybox 50 [OK]
|
||||
radial/busyboxplus Full-chain, Internet enabled, busybox made from scratch. Comes in git and cURL flavors. 8 [OK]
|
||||
```
|
||||
|
||||
## Limit search results (--limit)
|
||||
### Limit search results (--limit)
|
||||
|
||||
The flag `--limit` is the maximum number of results returned by a search. This value could
|
||||
be in the range between 1 and 100. The default value of `--limit` is 25.
|
||||
|
||||
|
||||
## Filtering
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there is more
|
||||
than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
@ -101,34 +107,43 @@ The currently supported filters are:
|
|||
* is-official (true|false) - is the image official or not
|
||||
|
||||
|
||||
### stars
|
||||
#### stars
|
||||
|
||||
This example displays images with a name containing 'busybox' and at
|
||||
least 3 stars:
|
||||
|
||||
$ docker search --filter stars=3 busybox
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
busybox Busybox base image. 325 [OK]
|
||||
progrium/busybox 50 [OK]
|
||||
radial/busyboxplus Full-chain, Internet enabled, busybox made... 8 [OK]
|
||||
```bash
|
||||
$ docker search --filter stars=3 busybox
|
||||
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
busybox Busybox base image. 325 [OK]
|
||||
progrium/busybox 50 [OK]
|
||||
radial/busyboxplus Full-chain, Internet enabled, busybox made... 8 [OK]
|
||||
```
|
||||
|
||||
|
||||
### is-automated
|
||||
#### is-automated
|
||||
|
||||
This example displays images with a name containing 'busybox'
|
||||
and are automated builds:
|
||||
|
||||
$ docker search --filter is-automated busybox
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
progrium/busybox 50 [OK]
|
||||
radial/busyboxplus Full-chain, Internet enabled, busybox made... 8 [OK]
|
||||
```bash
|
||||
$ docker search --filter is-automated busybox
|
||||
|
||||
### is-official
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
progrium/busybox 50 [OK]
|
||||
radial/busyboxplus Full-chain, Internet enabled, busybox made... 8 [OK]
|
||||
```
|
||||
|
||||
#### is-official
|
||||
|
||||
This example displays images with a name containing 'busybox', at least
|
||||
3 stars and are official builds:
|
||||
|
||||
$ docker search --filter "is-official=true" --filter "stars=3" busybox
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
progrium/busybox 50 [OK]
|
||||
radial/busyboxplus Full-chain, Internet enabled, busybox made... 8 [OK]
|
||||
```bash
|
||||
$ docker search --filter "is-official=true" --filter "stars=3" busybox
|
||||
|
||||
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
|
||||
progrium/busybox 50 [OK]
|
||||
radial/busyboxplus Full-chain, Internet enabled, busybox made... 8 [OK]
|
||||
```
|
||||
|
|
|
@ -25,6 +25,8 @@ Options:
|
|||
-l, --label list Secret labels (default [])
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Creates a secret using standard input or from a file for the secret content. You must run this
|
||||
command on a manager node.
|
||||
|
||||
|
@ -45,9 +47,11 @@ mhv17xfe3gh6xc4rij5orpfds my_secret 2016-10-27 23:25:43.90918108
|
|||
|
||||
```bash
|
||||
$ docker secret create my_secret ./secret.json
|
||||
|
||||
mhv17xfe3gh6xc4rij5orpfds
|
||||
|
||||
$ docker secret ls
|
||||
|
||||
ID NAME CREATED UPDATED SIZE
|
||||
mhv17xfe3gh6xc4rij5orpfds my_secret 2016-10-27 23:25:43.909181089 +0000 UTC 2016-10-27 23:25:43.909181089 +0000 UTC 1679
|
||||
```
|
||||
|
@ -55,10 +59,16 @@ mhv17xfe3gh6xc4rij5orpfds my_secret 2016-10-27 23:25:43.90918108
|
|||
### Create a secret with labels
|
||||
|
||||
```bash
|
||||
$ docker secret create --label env=dev --label rev=20161102 my_secret ./secret.json
|
||||
jtn7g6aukl5ky7nr9gvwafoxh
|
||||
$ docker secret create --label env=dev \
|
||||
--label rev=20161102 \
|
||||
my_secret ./secret.json
|
||||
|
||||
jtn7g6aukl5ky7nr9gvwafoxh
|
||||
```
|
||||
|
||||
```none
|
||||
$ docker secret inspect my_secret
|
||||
|
||||
[
|
||||
{
|
||||
"ID": "jtn7g6aukl5ky7nr9gvwafoxh",
|
||||
|
@ -79,11 +89,10 @@ $ docker secret inspect my_secret
|
|||
"SecretSize": 1679
|
||||
}
|
||||
]
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [secret inspect](secret_inspect.md)
|
||||
* [secret ls](secret_ls.md)
|
||||
|
|
|
@ -25,6 +25,7 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Inspects the specified secret. This command has to be run targeting a manager
|
||||
node.
|
||||
|
@ -37,7 +38,7 @@ describes all the details of the format.
|
|||
|
||||
## Examples
|
||||
|
||||
### Inspecting a secret by name or ID
|
||||
### Inspect a secret by name or ID
|
||||
|
||||
You can inspect a secret, either by its *name*, or *ID*
|
||||
|
||||
|
@ -49,8 +50,9 @@ ID NAME CREATED
|
|||
mhv17xfe3gh6xc4rij5orpfds secret.json 2016-10-27 23:25:43.909181089 +0000 UTC 2016-10-27 23:25:43.909181089 +0000 UTC
|
||||
```
|
||||
|
||||
```bash
|
||||
```none
|
||||
$ docker secret inspect secret.json
|
||||
|
||||
[
|
||||
{
|
||||
"ID": "mhv17xfe3gh6xc4rij5orpfds",
|
||||
|
@ -66,19 +68,22 @@ $ docker secret inspect secret.json
|
|||
]
|
||||
```
|
||||
|
||||
### Formatting secret output
|
||||
### Formatting
|
||||
|
||||
You can use the --format option to obtain specific information about a
|
||||
secret. The following example command outputs the creation time of the
|
||||
secret.
|
||||
|
||||
```bash{% raw %}
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker secret inspect --format='{{.CreatedAt}}' mhv17xfe3gh6xc4rij5orpfds
|
||||
|
||||
2016-10-27 23:25:43.909181089 +0000 UTC
|
||||
{% endraw %}```
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [secret create](secret_create.md)
|
||||
* [secret ls](secret_ls.md)
|
||||
|
|
|
@ -27,16 +27,20 @@ Options:
|
|||
-q, --quiet Only display IDs
|
||||
```
|
||||
|
||||
Run this command on a manager node to list the secrets in the Swarm.
|
||||
## Description
|
||||
|
||||
Run this command on a manager node to list the secrets in the swarm.
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker secret ls
|
||||
|
||||
ID NAME CREATED UPDATED
|
||||
mhv17xfe3gh6xc4rij5orpfds secret.json 2016-10-27 23:25:43.909181089 +0000 UTC 2016-10-27 23:25:43.909181089 +0000 UTC
|
||||
```
|
||||
## Related information
|
||||
|
||||
## Related commands
|
||||
|
||||
* [secret create](secret_create.md)
|
||||
* [secret inspect](secret_inspect.md)
|
||||
|
|
|
@ -27,9 +27,13 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Removes the specified secrets from the swarm. This command has to be run
|
||||
targeting a manager node.
|
||||
|
||||
## Examples
|
||||
|
||||
This example removes a secret:
|
||||
|
||||
```bash
|
||||
|
@ -41,7 +45,7 @@ sapth4csdo5b6wz2p5uimh5xg
|
|||
> before removing a secret.
|
||||
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [secret create](secret_create.md)
|
||||
* [secret inspect](secret_inspect.md)
|
||||
|
|
|
@ -68,6 +68,8 @@ Options:
|
|||
-w, --workdir string Working directory inside the container
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Creates a service as described by the specified parameters. You must run this
|
||||
command on a manager node.
|
||||
|
||||
|
@ -77,12 +79,15 @@ command on a manager node.
|
|||
|
||||
```bash
|
||||
$ docker service create --name redis redis:3.0.6
|
||||
|
||||
dmu1ept4cxcfe8k8lhtux3ro3
|
||||
|
||||
$ docker service create --mode global --name redis2 redis:3.0.6
|
||||
|
||||
a8q9dasaafudfs8q8w32udass
|
||||
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
dmu1ept4cxcf redis replicated 1/1 redis:3.0.6
|
||||
a8q9dasaafud redis2 global 1/1 redis:3.0.6
|
||||
|
@ -95,6 +100,7 @@ service. The following command creates a `redis` service with `5` replica tasks:
|
|||
|
||||
```bash
|
||||
$ docker service create --name redis --replicas=5 redis:3.0.6
|
||||
|
||||
4cdgfyky7ozwh3htjfw0d12qv
|
||||
```
|
||||
|
||||
|
@ -108,6 +114,7 @@ number of `RUNNING` tasks is `3`:
|
|||
|
||||
```bash
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
4cdgfyky7ozw redis replicated 3/5 redis:3.0.7
|
||||
```
|
||||
|
@ -117,11 +124,13 @@ equal to the desired number:
|
|||
|
||||
```bash
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
4cdgfyky7ozw redis replicated 5/5 redis:3.0.7
|
||||
```
|
||||
|
||||
### Create a service with secrets
|
||||
|
||||
Use the `--secret` flag to give a container access to a
|
||||
[secret](secret_create.md).
|
||||
|
||||
|
@ -129,6 +138,7 @@ Create a service specifying a secret:
|
|||
|
||||
```bash
|
||||
$ docker service create --name redis --secret secret.json redis:3.0.6
|
||||
|
||||
4cdgfyky7ozwh3htjfw0d12qv
|
||||
```
|
||||
|
||||
|
@ -139,6 +149,7 @@ $ docker service create --name redis \
|
|||
--secret source=ssh-key,target=ssh \
|
||||
--secret source=app-key,target=app,uid=1000,gid=1001,mode=0400 \
|
||||
redis:3.0.6
|
||||
|
||||
4cdgfyky7ozwh3htjfw0d12qv
|
||||
```
|
||||
|
||||
|
@ -172,12 +183,15 @@ This sets environmental variables for all tasks in a service. For example:
|
|||
$ docker service create --name redis_2 --replicas 5 --env MYVAR=foo redis:3.0.6
|
||||
```
|
||||
|
||||
### Create a docker service with specific hostname (--hostname)
|
||||
### Create a service with specific hostname (--hostname)
|
||||
|
||||
This option sets the docker service containers hostname to a specific string.
|
||||
For example:
|
||||
|
||||
This option sets the docker service containers hostname to a specific string. For example:
|
||||
```bash
|
||||
$ docker service create --name redis --hostname myredis redis:3.0.6
|
||||
```
|
||||
|
||||
### Set metadata on a service (-l, --label)
|
||||
|
||||
A label is a `key=value` pair that applies metadata to a service. To label a
|
||||
|
@ -201,7 +215,7 @@ or write from files or directories on other containers or the host operating
|
|||
system. These types are _data volumes_ (often referred to simply as volumes) and
|
||||
_bind-mounts_.
|
||||
|
||||
Additionally, Docker also supports tmpfs mounts.
|
||||
Additionally, Docker supports `tmpfs` mounts.
|
||||
|
||||
A **bind-mount** makes a file or directory on the host available to the
|
||||
container it is mounted within. A bind-mount may be either read-only or
|
||||
|
@ -303,19 +317,19 @@ The `--mount` flag supports most options that are supported by the `-v`
|
|||
or `--volume` flag for `docker run`, with some important exceptions:
|
||||
|
||||
- The `--mount` flag allows you to specify a volume driver and volume driver
|
||||
options *per volume*, without creating the volumes in advance. In contrast,
|
||||
`docker run` allows you to specify a single volume driver which is shared
|
||||
by all volumes, using the `--volume-driver` flag.
|
||||
options *per volume*, without creating the volumes in advance. In contrast,
|
||||
`docker run` allows you to specify a single volume driver which is shared
|
||||
by all volumes, using the `--volume-driver` flag.
|
||||
|
||||
- The `--mount` flag allows you to specify custom metadata ("labels") for a volume,
|
||||
before the volume is created.
|
||||
before the volume is created.
|
||||
|
||||
- When you use `--mount` with `type=bind`, the host-path must refer to an *existing*
|
||||
path on the host. The path will not be created for you and the service will fail
|
||||
with an error if the path does not exist.
|
||||
path on the host. The path will not be created for you and the service will fail
|
||||
with an error if the path does not exist.
|
||||
|
||||
- The `--mount` flag does not allow you to relabel a volume with `Z` or `z` flags,
|
||||
which are used for `selinux` labeling.
|
||||
which are used for `selinux` labeling.
|
||||
|
||||
#### Create a service using a named volume
|
||||
|
||||
|
@ -506,7 +520,7 @@ $ docker service create --name dns-cache -p 53:53/udp dns-cache
|
|||
### Create services using templates
|
||||
|
||||
You can use templates for some flags of `service create`, using the syntax
|
||||
provided by the Go's [text/template](http://golange.org/pkg/text/template/) package.
|
||||
provided by the Go's [text/template](http://golang.org/pkg/text/template/) package.
|
||||
|
||||
The supported flags are the following :
|
||||
|
||||
|
@ -532,18 +546,25 @@ In this example, we are going to set the template of the created containers base
|
|||
service's name and the node's ID where it sits.
|
||||
|
||||
```bash
|
||||
$ docker service create --name hosttempl --hostname={% raw %}"{{.Node.ID}}-{{.Service.Name}}"{% endraw %} busybox top
|
||||
{% raw %}
|
||||
$ docker service create --name hosttempl \
|
||||
--hostname={% raw %}"{{.Node.ID}}-{{.Service.Name}}"\
|
||||
busybox top
|
||||
|
||||
va8ew30grofhjoychbr6iot8c
|
||||
|
||||
$ docker service ps va8ew30grofhjoychbr6iot8c
|
||||
|
||||
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
|
||||
wo41w8hg8qan hosttempl.1 busybox:latest@sha256:29f5d56d12684887bdfa50dcd29fc31eea4aaf4ad3bec43daf19026a7ce69912 2e7a8a9c4da2 Running Running about a minute ago
|
||||
|
||||
$ docker inspect --format={% raw %}"{{.Config.Hostname}}"{% endraw %} hosttempl.1.wo41w8hg8qanxwjwsg4kxpprj
|
||||
$ docker inspect --format="{{.Config.Hostname}}" hosttempl.1.wo41w8hg8qanxwjwsg4kxpprj
|
||||
|
||||
x3ti0erg11rjpg64m75kej2mz-hosttempl
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [service inspect](service_inspect.md)
|
||||
* [service logs](service_logs.md)
|
||||
|
|
|
@ -26,6 +26,7 @@ Options:
|
|||
--pretty Print the information in a human friendly format.
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Inspects the specified service. This command has to be run targeting a manager
|
||||
node.
|
||||
|
@ -38,7 +39,7 @@ describes all the details of the format.
|
|||
|
||||
## Examples
|
||||
|
||||
### Inspecting a service by name or ID
|
||||
### Inspect a service by name or ID
|
||||
|
||||
You can inspect a service, either by its *name*, or *ID*
|
||||
|
||||
|
@ -53,8 +54,9 @@ dmu1ept4cxcf redis replicated 3/3 redis:3.0.6
|
|||
Both `docker service inspect redis`, and `docker service inspect dmu1ept4cxcf`
|
||||
produce the same result:
|
||||
|
||||
```bash
|
||||
```none
|
||||
$ docker service inspect redis
|
||||
|
||||
[
|
||||
{
|
||||
"ID": "dmu1ept4cxcfe8k8lhtux3ro3",
|
||||
|
@ -98,6 +100,7 @@ $ docker service inspect redis
|
|||
|
||||
```bash
|
||||
$ docker service inspect dmu1ept4cxcf
|
||||
|
||||
[
|
||||
{
|
||||
"ID": "dmu1ept4cxcfe8k8lhtux3ro3",
|
||||
|
@ -109,13 +112,14 @@ $ docker service inspect dmu1ept4cxcf
|
|||
]
|
||||
```
|
||||
|
||||
### Inspect a service using pretty-print
|
||||
### Formatting
|
||||
|
||||
You can print the inspect output in a human-readable format instead of the default
|
||||
JSON output, by using the `--pretty` option:
|
||||
|
||||
```bash
|
||||
$ docker service inspect --pretty frontend
|
||||
|
||||
ID: c8wgl7q4ndfd52ni6qftkvnnp
|
||||
Name: frontend
|
||||
Labels:
|
||||
|
@ -139,19 +143,22 @@ Ports:
|
|||
You can also use `--format pretty` for the same effect.
|
||||
|
||||
|
||||
### Finding the number of tasks running as part of a service
|
||||
#### Find the number of tasks running as part of a service
|
||||
|
||||
The `--format` option can be used to obtain specific information about a
|
||||
service. For example, the following command outputs the number of replicas
|
||||
of the "redis" service.
|
||||
|
||||
```bash{% raw %}
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis
|
||||
|
||||
10
|
||||
{% endraw %}```
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [service create](service_create.md)
|
||||
* [service logs](service_logs.md)
|
||||
|
|
|
@ -30,9 +30,11 @@ Options:
|
|||
-t, --timestamps Show timestamps
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `docker service logs` command batch-retrieves logs present at the time of execution.
|
||||
|
||||
> **Note**: this command is only functional for services that are started with
|
||||
> **Note**: This command is only functional for services that are started with
|
||||
> the `json-file` or `journald` logging driver.
|
||||
|
||||
For more information about selecting and configuring logging drivers, refer to
|
||||
|
@ -66,7 +68,7 @@ seconds (aka Unix epoch or Unix time), and the optional .nanoseconds field is a
|
|||
fraction of a second no more than nine digits long. You can combine the
|
||||
`--since` option with either or both of the `--follow` or `--tail` options.
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [service create](service_create.md)
|
||||
* [service inspect](service_inspect.md)
|
||||
|
|
|
@ -29,12 +29,18 @@ Options:
|
|||
-q, --quiet Only display IDs
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
This command when run targeting a manager, lists services are running in the
|
||||
swarm.
|
||||
|
||||
## Examples
|
||||
|
||||
On a manager node:
|
||||
|
||||
```bash
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
c8wgl7q4ndfd frontend replicated 5/5 nginx:alpine
|
||||
dmu1ept4cxcf redis replicated 3/3 redis:3.0.6
|
||||
|
@ -44,7 +50,7 @@ iwe3278osahj mongo global 7/7 mongo:3.3
|
|||
The `REPLICAS` column shows both the *actual* and *desired* number of tasks for
|
||||
the service.
|
||||
|
||||
## Filtering
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
|
||||
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
|
||||
|
@ -55,7 +61,7 @@ The currently supported filters are:
|
|||
* [label](service_ls.md#label)
|
||||
* [name](service_ls.md#name)
|
||||
|
||||
#### ID
|
||||
#### id
|
||||
|
||||
The `id` filter matches all or part of a service's id.
|
||||
|
||||
|
@ -65,7 +71,7 @@ ID NAME MODE REPLICAS IMAGE
|
|||
0bcjwfh8ychr redis replicated 1/1 redis:3.0.6
|
||||
```
|
||||
|
||||
#### Label
|
||||
#### label
|
||||
|
||||
The `label` filter matches services based on the presence of a `label` alone or
|
||||
a `label` and a value.
|
||||
|
@ -91,7 +97,7 @@ ID NAME MODE REPLICAS IMAGE
|
|||
74nzcxxjv6fq backend replicated 3/3 redis:3.0.6
|
||||
```
|
||||
|
||||
#### Name
|
||||
#### name
|
||||
|
||||
The `name` filter matches on all or part of a service's name.
|
||||
|
||||
|
@ -103,7 +109,42 @@ ID NAME MODE REPLICAS IMAGE
|
|||
0bcjwfh8ychr redis replicated 1/1 redis:3.0.6
|
||||
```
|
||||
|
||||
<<<<<<< HEAD
|
||||
## Related information
|
||||
=======
|
||||
### Formatting
|
||||
|
||||
The formatting options (`--format`) pretty-prints services output
|
||||
using a Go template.
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
Placeholder | Description
|
||||
------------|------------------------------------------------------------------------------------------
|
||||
`.ID` | Service ID
|
||||
`.Name` | Service name
|
||||
`.Mode` | Service mode (replicated, global)
|
||||
`.Replicas` | Service replicas
|
||||
`.Image` | Service image
|
||||
|
||||
When using the `--format` option, the `service ls` command will either
|
||||
output the data exactly as the template declares or, when using the
|
||||
`table` directive, includes column headers as well.
|
||||
|
||||
The following example uses a template without headers and outputs the
|
||||
`ID`, `Mode`, and `Replicas` entries separated by a colon for all services:
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker service ls --format "{{.ID}}: {{.Mode}} {{.Replicas}}"
|
||||
|
||||
0zmvwuiu3vue: replicated 10/10
|
||||
fm6uf97exkul: global 5/5
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
## Related commands
|
||||
>>>>>>> 40dbbd3... Merge pull request #30804 from mstanleyjones/cli_fixups
|
||||
|
||||
* [service create](service_create.md)
|
||||
* [service inspect](service_inspect.md)
|
||||
|
|
|
@ -29,12 +29,14 @@ Options:
|
|||
-q, --quiet Only display task IDs
|
||||
```
|
||||
|
||||
Lists the tasks that are running as part of the specified service. This command
|
||||
## Description
|
||||
|
||||
Lists the tasks that are running as part of the specified services. This command
|
||||
has to be run targeting a manager node.
|
||||
|
||||
## Examples
|
||||
|
||||
### Listing the tasks that are part of a service
|
||||
### List the tasks that are part of a service
|
||||
|
||||
The following command shows all the tasks that are part of the `redis` service:
|
||||
|
||||
|
@ -93,7 +95,7 @@ bk658fpbex0d57cqcwoe3jthu redis.2 redis:3.0.6@sha256:6a692a76c2081888b589
|
|||
nvjljf7rmor4htv7l8rwcx7i7 \_ redis.2 redis:3.0.6@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842 worker2 Shutdown Rejected 5 minutes ago "No such image: redis@sha256:6a692a76c2081888b589e26e6ec835743119fe453d67ecf03df7de5b73d69842"
|
||||
```
|
||||
|
||||
## Filtering
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
|
||||
is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
|
||||
|
@ -108,7 +110,7 @@ The currently supported filters are:
|
|||
* [desired-state](#desired-state)
|
||||
|
||||
|
||||
#### ID
|
||||
#### id
|
||||
|
||||
The `id` filter matches on all or a prefix of a task's ID.
|
||||
|
||||
|
@ -120,7 +122,7 @@ ID NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
|||
8eaxrb2fqpbn redis.10 redis:3.0.6 manager1 Running Running 8 seconds
|
||||
```
|
||||
|
||||
#### Name
|
||||
#### name
|
||||
|
||||
The `name` filter matches on task names.
|
||||
|
||||
|
@ -131,7 +133,7 @@ qihejybwf1x5 redis.1 redis:3.0.6 manager1 Running Running 8 seconds
|
|||
```
|
||||
|
||||
|
||||
#### Node
|
||||
#### node
|
||||
|
||||
The `node` filter matches on a node name or a node ID.
|
||||
|
||||
|
@ -150,7 +152,7 @@ ID NAME IMAGE NODE DESIRED STATE CURRENT STATE
|
|||
The `desired-state` filter can take the values `running`, `shutdown`, and `accepted`.
|
||||
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [service create](service_create.md)
|
||||
* [service inspect](service_inspect.md)
|
||||
|
|
|
@ -27,24 +27,29 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Removes the specified services from the swarm. This command has to be run
|
||||
targeting a manager node.
|
||||
|
||||
For example, to remove the redis service:
|
||||
## Examples
|
||||
|
||||
Remove the `redis` service:
|
||||
|
||||
```bash
|
||||
$ docker service rm redis
|
||||
|
||||
redis
|
||||
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
```
|
||||
|
||||
> **Warning**: Unlike `docker rm`, this command does not ask for confirmation
|
||||
> before removing a running service.
|
||||
|
||||
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [service create](service_create.md)
|
||||
* [service inspect](service_inspect.md)
|
||||
|
|
|
@ -24,9 +24,7 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Scale a service
|
||||
## Description
|
||||
|
||||
The scale command enables you to scale one or more replicated services either up
|
||||
or down to the desired number of replicas. This command cannot be applied on
|
||||
|
@ -34,19 +32,27 @@ services which are global mode. The command will return immediately, but the
|
|||
actual scaling of the service may take some time. To stop all replicas of a
|
||||
service while keeping the service active in the swarm you can set the scale to 0.
|
||||
|
||||
For example, the following command scales the "frontend" service to 50 tasks.
|
||||
## Examples
|
||||
|
||||
### Scale a single service
|
||||
|
||||
The following command scales the "frontend" service to 50 tasks.
|
||||
|
||||
```bash
|
||||
$ docker service scale frontend=50
|
||||
|
||||
frontend scaled to 50
|
||||
```
|
||||
|
||||
The following command tries to scale a global service to 10 tasks and returns an error.
|
||||
|
||||
```
|
||||
```bash
|
||||
$ docker service create --mode global --name backend backend:latest
|
||||
|
||||
b4g08uwuairexjub6ome6usqh
|
||||
|
||||
$ docker service scale backend=10
|
||||
|
||||
backend: scale can only be used with replicated mode
|
||||
```
|
||||
|
||||
|
@ -76,16 +82,18 @@ backend and frontend services:
|
|||
|
||||
```bash
|
||||
$ docker service scale backend=3 frontend=5
|
||||
|
||||
backend scaled to 3
|
||||
frontend scaled to 5
|
||||
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
3pr5mlvu3fh9 frontend replicated 5/5 nginx:alpine
|
||||
74nzcxxjv6fq backend replicated 3/3 redis:3.0.6
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [service create](service_create.md)
|
||||
* [service inspect](service_inspect.md)
|
||||
|
|
|
@ -80,6 +80,8 @@ Options:
|
|||
-w, --workdir string Working directory inside the container
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Updates a service as described by the specified parameters. This command has to be run targeting a manager node.
|
||||
The parameters are the same as [`docker service create`](service_create.md). Please look at the description there
|
||||
for further information.
|
||||
|
@ -111,7 +113,7 @@ that only one task is replaced at a time (this is the default behavior). The
|
|||
`--update-delay 30s` setting introduces a 30 second delay between tasks, so
|
||||
that the rolling restart happens gradually.
|
||||
|
||||
### Adding and removing mounts
|
||||
### Add or remove mounts
|
||||
|
||||
Use the `--mount-add` or `--mount-rm` options add or remove a service's bind-mounts
|
||||
or volumes.
|
||||
|
@ -151,7 +153,52 @@ $ docker service update --mount-rm /somewhere myservice
|
|||
myservice
|
||||
```
|
||||
|
||||
### Adding and removing secrets
|
||||
### Rolling back to the previous version of a service
|
||||
|
||||
Use the `--rollback` option to roll back to the previous version of the service.
|
||||
|
||||
This will revert the service to the configuration that was in place before the most recent `docker service update` command.
|
||||
|
||||
The following example updates the number of replicas for the service from 4 to 5, and then rolls back to the previous configuration.
|
||||
|
||||
```bash
|
||||
$ docker service update --replicas=5 web
|
||||
|
||||
web
|
||||
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
80bvrzp6vxf3 web replicated 0/5 nginx:alpine
|
||||
|
||||
```
|
||||
Roll back the `web` service...
|
||||
|
||||
```bash
|
||||
$ docker service update --rollback web
|
||||
|
||||
web
|
||||
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
80bvrzp6vxf3 web replicated 0/4 nginx:alpine
|
||||
|
||||
```
|
||||
|
||||
Other options can be combined with `--rollback` as well, for example, `--update-delay 0s` to execute the rollback without a delay between tasks:
|
||||
|
||||
```bash
|
||||
$ docker service update \
|
||||
--rollback \
|
||||
--update-delay 0s
|
||||
web
|
||||
|
||||
web
|
||||
|
||||
```
|
||||
|
||||
### Add or remove secrets
|
||||
|
||||
Use the `--secret-add` or `--secret-rm` options add or remove a service's
|
||||
secrets.
|
||||
|
@ -170,7 +217,7 @@ $ docker service update \
|
|||
Some flags of `service update` support the use of templating.
|
||||
See [`service create`](./service_create.md#templating) for the reference.
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [service create](service_create.md)
|
||||
* [service inspect](service_inspect.md)
|
||||
|
|
|
@ -30,15 +30,20 @@ Options:
|
|||
--with-registry-auth Send registry authentication details to Swarm agents
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Create and update a stack from a `compose` or a `dab` file on the swarm. This command
|
||||
has to be run targeting a manager node.
|
||||
|
||||
## Compose file
|
||||
## Examples
|
||||
|
||||
### Compose file
|
||||
|
||||
The `deploy` command supports compose file version `3.0` and above."
|
||||
|
||||
```bash
|
||||
$ docker stack deploy --compose-file docker-compose.yml vossibility
|
||||
|
||||
Ignoring unsupported options: links
|
||||
|
||||
Creating network vossibility_vossibility
|
||||
|
@ -53,8 +58,9 @@ Creating service vossibility_lookupd
|
|||
|
||||
You can verify that the services were correctly created
|
||||
|
||||
```
|
||||
```bash
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
29bv0vnlm903 vossibility_lookupd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
|
||||
4awt47624qwh vossibility_nsqd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
|
||||
|
@ -64,10 +70,11 @@ ID NAME MODE REPLICAS IMAGE
|
|||
axqh55ipl40h vossibility_vossibility-collector replicated 1/1 icecrime/vossibility-collector@sha256:f03f2977203ba6253988c18d04061c5ec7aab46bca9dfd89a9a1fa4500989fba
|
||||
```
|
||||
|
||||
## DAB file
|
||||
### DAB file
|
||||
|
||||
```bash
|
||||
$ docker stack deploy --bundle-file vossibility-stack.dab vossibility
|
||||
|
||||
Loading bundle from vossibility-stack.dab
|
||||
Creating service vossibility_elasticsearch
|
||||
Creating service vossibility_kibana
|
||||
|
@ -81,6 +88,7 @@ You can verify that the services were correctly created:
|
|||
|
||||
```bash
|
||||
$ docker service ls
|
||||
|
||||
ID NAME MODE REPLICAS IMAGE
|
||||
29bv0vnlm903 vossibility_lookupd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
|
||||
4awt47624qwh vossibility_nsqd replicated 1/1 nsqio/nsq@sha256:eeba05599f31eba418e96e71e0984c3dc96963ceb66924dd37a47bf7ce18a662
|
||||
|
@ -90,7 +98,7 @@ ID NAME MODE REPLICAS IMAGE
|
|||
axqh55ipl40h vossibility_vossibility-collector replicated 1/1 icecrime/vossibility-collector@sha256:f03f2977203ba6253988c18d04061c5ec7aab46bca9dfd89a9a1fa4500989fba
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [stack ls](stack_ls.md)
|
||||
* [stack ps](stack_ps.md)
|
||||
|
|
|
@ -27,9 +27,13 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Descriptino
|
||||
|
||||
Lists the stacks.
|
||||
|
||||
For example, the following command shows all stacks and some additional information:
|
||||
## Examples
|
||||
|
||||
The following command shows all stacks and some additional information:
|
||||
|
||||
```bash
|
||||
$ docker stack ls
|
||||
|
@ -39,7 +43,7 @@ vossibility-stack 6
|
|||
myapp 2
|
||||
```
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [stack deploy](stack_deploy.md)
|
||||
* [stack ps](stack_ps.md)
|
||||
|
|
|
@ -27,10 +27,18 @@ Options:
|
|||
--no-trunc Do not truncate output
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Lists the tasks that are running as part of the specified stack. This
|
||||
command has to be run targeting a manager node.
|
||||
|
||||
## Filtering
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker stack ps
|
||||
```
|
||||
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
|
||||
is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
|
||||
|
@ -43,7 +51,7 @@ The currently supported filters are:
|
|||
* name
|
||||
* desired-state
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [stack deploy](stack_deploy.md)
|
||||
* [stack ls](stack_ls.md)
|
||||
|
|
|
@ -27,10 +27,12 @@ Options:
|
|||
--help Print usage
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
Remove the stack from the swarm. This command has to be run targeting
|
||||
a manager node.
|
||||
|
||||
## Related information
|
||||
## Related commands
|
||||
|
||||
* [stack deploy](stack_deploy.md)
|
||||
* [stack ls](stack_ls.md)
|
||||
|
|
|
@ -27,10 +27,14 @@ Options:
|
|||
-q, --quiet Only display IDs
|
||||
```
|
||||
|
||||
### Description
|
||||
|
||||
Lists the services that are running as part of the specified stack. This
|
||||
command has to be run targeting a manager node.
|
||||
|
||||
For example, the following command shows all services in the `myapp` stack:
|
||||
### Examples
|
||||
|
||||
The following command shows all services in the `myapp` stack:
|
||||
|
||||
```bash
|
||||
$ docker stack services myapp
|
||||
|
@ -40,7 +44,7 @@ ID NAME REPLICAS IMAGE
|
|||
dn7m7nhhfb9y myapp_db 1/1 mysql@sha256:a9a5b559f8821fe73d58c3606c812d1c044868d42c63817fa5125fd9d8b7b539
|
||||
```
|
||||
|
||||
## Filtering
|
||||
### Filtering
|
||||
|
||||
The filtering flag (`-f` or `--filter`) format is a `key=value` pair. If there
|
||||
is more than one filter, then pass multiple flags (e.g. `--filter "foo=bar" --filter "bif=baz"`).
|
||||
|
@ -62,7 +66,39 @@ The currently supported filters are:
|
|||
* name (`--filter name=myapp_web`)
|
||||
* label (`--filter label=key=value`)
|
||||
|
||||
## Related information
|
||||
### Formatting
|
||||
|
||||
The formatting options (`--format`) pretty-prints services output
|
||||
using a Go template.
|
||||
|
||||
Valid placeholders for the Go template are listed below:
|
||||
|
||||
Placeholder | Description
|
||||
------------|------------------------------------------------------------------------------------------
|
||||
`.ID` | Service ID
|
||||
`.Name` | Service name
|
||||
`.Mode` | Service mode (replicated, global)
|
||||
`.Replicas` | Service replicas
|
||||
`.Image` | Service image
|
||||
|
||||
When using the `--format` option, the `stack services` command will either
|
||||
output the data exactly as the template declares or, when using the
|
||||
`table` directive, includes column headers as well.
|
||||
|
||||
The following example uses a template without headers and outputs the
|
||||
`ID`, `Mode`, and `Replicas` entries separated by a colon for all services:
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker stack services --format "{{.ID}}: {{.Mode}} {{.Replicas}}"
|
||||
|
||||
0zmvwuiu3vue: replicated 10/10
|
||||
fm6uf97exkul: global 5/5
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
|
||||
## Related commands
|
||||
|
||||
* [stack deploy](stack_deploy.md)
|
||||
* [stack ls](stack_ls.md)
|
||||
|
|
|
@ -26,3 +26,9 @@ Options:
|
|||
--help Print usage
|
||||
-i, --interactive Attach container's STDIN
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker start my_container
|
||||
```
|
||||
|
|
|
@ -27,6 +27,8 @@ Options:
|
|||
--no-stream Disable streaming stats and only pull the first result
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The `docker stats` command returns a live data stream for running containers. To limit data to one or more specific containers, specify a list of container names or ids separated by a space. You can specify a stopped container but stopped containers do not return any data.
|
||||
|
||||
If you want more detailed information about a container's resource usage, use the `/containers/(id)/stats` API endpoint.
|
||||
|
@ -35,41 +37,49 @@ If you want more detailed information about a container's resource usage, use th
|
|||
|
||||
Running `docker stats` on all running containers against a Linux daemon.
|
||||
|
||||
$ docker stats
|
||||
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O
|
||||
1285939c1fd3 0.07% 796 KiB / 64 MiB 1.21% 788 B / 648 B 3.568 MB / 512 KB
|
||||
9c76f7834ae2 0.07% 2.746 MiB / 64 MiB 4.29% 1.266 KB / 648 B 12.4 MB / 0 B
|
||||
d1ea048f04e4 0.03% 4.583 MiB / 64 MiB 6.30% 2.854 KB / 648 B 27.7 MB / 0 B
|
||||
```bash
|
||||
$ docker stats
|
||||
CONTAINER CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O
|
||||
1285939c1fd3 0.07% 796 KiB / 64 MiB 1.21% 788 B / 648 B 3.568 MB / 512 KB
|
||||
9c76f7834ae2 0.07% 2.746 MiB / 64 MiB 4.29% 1.266 KB / 648 B 12.4 MB / 0 B
|
||||
d1ea048f04e4 0.03% 4.583 MiB / 64 MiB 6.30% 2.854 KB / 648 B 27.7 MB / 0 B
|
||||
```
|
||||
|
||||
Running `docker stats` on multiple containers by name and id against a Linux daemon.
|
||||
|
||||
$ docker stats fervent_panini 5acfcb1b4fd1
|
||||
CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O
|
||||
5acfcb1b4fd1 0.00% 115.2 MiB/1.045 GiB 11.03% 1.422 kB/648 B
|
||||
fervent_panini 0.02% 11.08 MiB/1.045 GiB 1.06% 648 B/648 B
|
||||
```bash
|
||||
$ docker stats fervent_panini 5acfcb1b4fd1
|
||||
CONTAINER CPU % MEM USAGE/LIMIT MEM % NET I/O
|
||||
5acfcb1b4fd1 0.00% 115.2 MiB/1.045 GiB 11.03% 1.422 kB/648 B
|
||||
fervent_panini 0.02% 11.08 MiB/1.045 GiB 1.06% 648 B/648 B
|
||||
```
|
||||
|
||||
Running `docker stats` on all running containers against a Windows daemon.
|
||||
|
||||
PS E:\> docker stats
|
||||
CONTAINER CPU % PRIV WORKING SET NET I/O BLOCK I/O
|
||||
09d3bb5b1604 6.61% 38.21 MiB 17.1 kB / 7.73 kB 10.7 MB / 3.57 MB
|
||||
9db7aa4d986d 9.19% 38.26 MiB 15.2 kB / 7.65 kB 10.6 MB / 3.3 MB
|
||||
3f214c61ad1d 0.00% 28.64 MiB 64 kB / 6.84 kB 4.42 MB / 6.93 MB
|
||||
```powershell
|
||||
PS E:\> docker stats
|
||||
CONTAINER CPU % PRIV WORKING SET NET I/O BLOCK I/O
|
||||
09d3bb5b1604 6.61% 38.21 MiB 17.1 kB / 7.73 kB 10.7 MB / 3.57 MB
|
||||
9db7aa4d986d 9.19% 38.26 MiB 15.2 kB / 7.65 kB 10.6 MB / 3.3 MB
|
||||
3f214c61ad1d 0.00% 28.64 MiB 64 kB / 6.84 kB 4.42 MB / 6.93 MB
|
||||
```
|
||||
|
||||
Running `docker stats` on multiple containers by name and id against a Windows daemon.
|
||||
|
||||
PS E:\> docker ps -a
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
3f214c61ad1d nanoserver "cmd" 2 minutes ago Up 2 minutes big_minsky
|
||||
9db7aa4d986d windowsservercore "cmd" 2 minutes ago Up 2 minutes mad_wilson
|
||||
09d3bb5b1604 windowsservercore "cmd" 2 minutes ago Up 2 minutes affectionate_easley
|
||||
```powershell
|
||||
PS E:\> docker ps -a
|
||||
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
|
||||
3f214c61ad1d nanoserver "cmd" 2 minutes ago Up 2 minutes big_minsky
|
||||
9db7aa4d986d windowsservercore "cmd" 2 minutes ago Up 2 minutes mad_wilson
|
||||
09d3bb5b1604 windowsservercore "cmd" 2 minutes ago Up 2 minutes affectionate_easley
|
||||
|
||||
PS E:\> docker stats 3f214c61ad1d mad_wilson
|
||||
CONTAINER CPU % PRIV WORKING SET NET I/O BLOCK I/O
|
||||
3f214c61ad1d 0.00% 46.25 MiB 76.3 kB / 7.92 kB 10.3 MB / 14.7 MB
|
||||
mad_wilson 9.59% 40.09 MiB 27.6 kB / 8.81 kB 17 MB / 20.1 MB
|
||||
PS E:\> docker stats 3f214c61ad1d mad_wilson
|
||||
CONTAINER CPU % PRIV WORKING SET NET I/O BLOCK I/O
|
||||
3f214c61ad1d 0.00% 46.25 MiB 76.3 kB / 7.92 kB 10.3 MB / 14.7 MB
|
||||
mad_wilson 9.59% 40.09 MiB 27.6 kB / 8.81 kB 17 MB / 20.1 MB
|
||||
```
|
||||
|
||||
## Formatting
|
||||
### Formatting
|
||||
|
||||
The formatting option (`--format`) pretty prints container output
|
||||
using a Go template.
|
||||
|
@ -97,21 +107,25 @@ The following example uses a template without headers and outputs the
|
|||
`Container` and `CPUPerc` entries separated by a colon for all images:
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker stats --format "{{.Container}}: {{.CPUPerc}}"
|
||||
|
||||
09d3bb5b1604: 6.61%
|
||||
9db7aa4d986d: 9.19%
|
||||
3f214c61ad1d: 0.00%
|
||||
{% endraw %}
|
||||
```
|
||||
|
||||
To list all containers statistics with their name, CPU percentage and memory
|
||||
usage in a table format you can use:
|
||||
|
||||
```bash
|
||||
{% raw %}
|
||||
$ docker stats --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}"
|
||||
|
||||
CONTAINER CPU % PRIV WORKING SET
|
||||
1285939c1fd3 0.07% 796 KiB / 64 MiB
|
||||
9c76f7834ae2 0.07% 2.746 MiB / 64 MiB
|
||||
d1ea048f04e4 0.03% 4.583 MiB / 64 MiB
|
||||
{% endraw %}
|
||||
```
|
||||
|
|
|
@ -25,5 +25,13 @@ Options:
|
|||
-t, --time int Seconds to wait for stop before killing it (default 10)
|
||||
```
|
||||
|
||||
## Description
|
||||
|
||||
The main process inside the container will receive `SIGTERM`, and after a grace
|
||||
period, `SIGKILL`.
|
||||
|
||||
## Examples
|
||||
|
||||
```bash
|
||||
$ docker stop my_container
|
||||
```
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue