Merge pull request #3261 from thaJeztah/docs_rewrite_and_codehints

docs: rewrite reference docs for --stop-signal and --stop-timeout, and use "console" hints
This commit is contained in:
Sebastiaan van Stijn 2021-08-25 09:49:26 +02:00 committed by GitHub
commit 1fdafcd162
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
129 changed files with 933 additions and 830 deletions

View File

@ -589,9 +589,9 @@ 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 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. `fluentd-tag` have been deprecated in favor of the generic `tag` option.
```bash ```console
{% raw %} {% raw %}
docker --log-driver=syslog --log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}" $ docker --log-driver=syslog --log-opt tag="{{.ImageName}}/{{.Name}}/{{.ID}}"
{% endraw %} {% endraw %}
``` ```

View File

@ -55,7 +55,7 @@ enabled, and use it to create a volume.
1. Install the `sshfs` plugin. 1. Install the `sshfs` plugin.
```bash ```console
$ docker plugin install vieux/sshfs $ docker plugin install vieux/sshfs
Plugin "vieux/sshfs" is requesting the following privileges: Plugin "vieux/sshfs" is requesting the following privileges:
@ -74,7 +74,7 @@ enabled, and use it to create a volume.
2. Check that the plugin is enabled in the output of `docker plugin ls`. 2. Check that the plugin is enabled in the output of `docker plugin ls`.
```bash ```console
$ docker plugin ls $ docker plugin ls
ID NAME TAG DESCRIPTION ENABLED ID NAME TAG DESCRIPTION ENABLED
@ -87,7 +87,7 @@ enabled, and use it to create a volume.
This volume can now be mounted into containers. This volume can now be mounted into containers.
```bash ```console
$ docker volume create \ $ docker volume create \
-d vieux/sshfs \ -d vieux/sshfs \
--name sshvolume \ --name sshvolume \
@ -96,9 +96,10 @@ enabled, and use it to create a volume.
sshvolume sshvolume
``` ```
4. Verify that the volume was created successfully. 4. Verify that the volume was created successfully.
```bash ```console
$ docker volume ls $ docker volume ls
DRIVER NAME DRIVER NAME
@ -107,18 +108,19 @@ enabled, and use it to create a volume.
5. Start a container that uses the volume `sshvolume`. 5. Start a container that uses the volume `sshvolume`.
```bash ```console
$ docker run --rm -v sshvolume:/data busybox ls /data $ docker run --rm -v sshvolume:/data busybox ls /data
<content of /remote on machine 1.2.3.4> <content of /remote on machine 1.2.3.4>
``` ```
6. Remove the volume `sshvolume` 6. Remove the volume `sshvolume`
```bash ```console
docker volume rm sshvolume $ docker volume rm sshvolume
sshvolume sshvolume
``` ```
To disable a plugin, use the `docker plugin disable` command. To completely To disable a plugin, use the `docker plugin disable` command. To completely
remove it, use the `docker plugin remove` command. For other available remove it, use the `docker plugin remove` command. For other available
commands and options, see the commands and options, see the
@ -134,7 +136,7 @@ example, it was created from a Dockerfile:
>**Note:** The `/run/docker/plugins` directory is mandatory inside of the >**Note:** The `/run/docker/plugins` directory is mandatory inside of the
plugin's filesystem for docker to communicate with the plugin. plugin's filesystem for docker to communicate with the plugin.
```bash ```console
$ git clone https://github.com/vieux/docker-volume-sshfs $ git clone https://github.com/vieux/docker-volume-sshfs
$ cd docker-volume-sshfs $ cd docker-volume-sshfs
$ docker build -t rootfsimage . $ docker build -t rootfsimage .
@ -193,13 +195,13 @@ Stdout of a plugin is redirected to dockerd logs. Such entries have a
`f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62` and their `f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62` and their
corresponding log entries in the docker daemon logs. corresponding log entries in the docker daemon logs.
```bash ```console
$ docker plugin install tiborvass/sample-volume-plugin $ docker plugin install tiborvass/sample-volume-plugin
INFO[0036] Starting... Found 0 volumes on startup plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62 INFO[0036] Starting... Found 0 volumes on startup plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
``` ```
```bash ```console
$ docker volume create -d tiborvass/sample-volume-plugin samplevol $ docker volume create -d tiborvass/sample-volume-plugin samplevol
INFO[0193] Create Called... Ensuring directory /data/samplevol exists on host... plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62 INFO[0193] Create Called... Ensuring directory /data/samplevol exists on host... plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
@ -208,7 +210,7 @@ INFO[0193] Created volume samplevol with mountpoint /data/samp
INFO[0193] Path Called... Returned path /data/samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62 INFO[0193] Path Called... Returned path /data/samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
``` ```
```bash ```console
$ docker run -v samplevol:/tmp busybox sh $ docker run -v samplevol:/tmp busybox sh
INFO[0421] Get Called... Found samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62 INFO[0421] Get Called... Found samplevol plugin=f52a3df433b9aceee436eaada0752f5797aab1de47e5485f1690a073b860ff62
@ -223,7 +225,7 @@ INFO[0421] Unmount Called... Unmounted samplevol plugin=f52a3df433b9a
plugins. This is specifically useful to collect plugin logs if they are plugins. This is specifically useful to collect plugin logs if they are
redirected to a file. redirected to a file.
```bash ```console
$ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins list $ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins list
ID PID STATUS BUNDLE CREATED OWNER ID PID STATUS BUNDLE CREATED OWNER
@ -232,13 +234,14 @@ ID PID S
c5bb4b90941efcaccca999439ed06d6a6affdde7081bb34dc84126b57b3e793d 14984 running /run/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby-plugins/c5bb4b90941efcaccca999439ed06d6a6affdde7081bb34dc84126b57b3e793d 2018-02-08T21:35:12.321288966Z root c5bb4b90941efcaccca999439ed06d6a6affdde7081bb34dc84126b57b3e793d 14984 running /run/docker/containerd/daemon/io.containerd.runtime.v1.linux/moby-plugins/c5bb4b90941efcaccca999439ed06d6a6affdde7081bb34dc84126b57b3e793d 2018-02-08T21:35:12.321288966Z root
``` ```
```bash ```console
$ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins exec 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 cat /var/log/plugin.log $ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins exec 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 cat /var/log/plugin.log
``` ```
If the plugin has a built-in shell, then exec into the plugin can be done as If the plugin has a built-in shell, then exec into the plugin can be done as
follows: follows:
```bash
```console
$ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins exec -t 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 sh $ sudo docker-runc --root /var/run/docker/plugins/runtime-root/moby-plugins exec -t 93f1e7dbfe11c938782c2993628c895cf28e2274072c4a346a6002446c949b25 sh
``` ```
@ -251,17 +254,18 @@ 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>` these basic requests should work. Note that plugin sockets are available on the host under `/var/run/docker/plugins/<pluginID>`
```bash ```console
curl -H "Content-Type: application/json" -XPOST -d '{}' --unix-socket /var/run/docker/plugins/e8a37ba56fc879c991f7d7921901723c64df6b42b87e6a0b055771ecf8477a6d/plugin.sock http:/VolumeDriver.List $ 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} {"Mountpoint":"","Err":"","Volumes":[{"Name":"myvol1","Mountpoint":"/data/myvol1"},{"Name":"myvol2","Mountpoint":"/data/myvol2"}],"Volume":null}
``` ```
```bash ```console
curl -H "Content-Type: application/json" -XPOST -d '{}' --unix-socket /var/run/docker/plugins/45e00a7ce6185d6e365904c8bcf62eb724b1fe307e0d4e7ecc9f6c1eb7bcdb70/plugin.sock http:/NetworkDriver.GetCapabilities $ curl -H "Content-Type: application/json" -XPOST -d '{}' --unix-socket /var/run/docker/plugins/45e00a7ce6185d6e365904c8bcf62eb724b1fe307e0d4e7ecc9f6c1eb7bcdb70/plugin.sock http:/NetworkDriver.GetCapabilities
{"Scope":"local"} {"Scope":"local"}
``` ```
When using curl 7.5 and above, the URL should be of the form 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 `http://hostname/APICall`, where `hostname` is the valid hostname where the
plugin is installed and `APICall` is the call to the plugin API. plugin is installed and `APICall` is the call to the plugin API.

View File

@ -114,7 +114,7 @@ a `service` file and a `socket` file.
The `service` file (for example `/lib/systemd/system/your-plugin.service`): The `service` file (for example `/lib/systemd/system/your-plugin.service`):
``` ```systemd
[Unit] [Unit]
Description=Your plugin Description=Your plugin
Before=docker.service Before=docker.service
@ -127,9 +127,10 @@ ExecStart=/usr/lib/docker/your-plugin
[Install] [Install]
WantedBy=multi-user.target WantedBy=multi-user.target
``` ```
The `socket` file (for example `/lib/systemd/system/your-plugin.socket`): The `socket` file (for example `/lib/systemd/system/your-plugin.socket`):
``` ```systemd
[Unit] [Unit]
Description=Your plugin Description=Your plugin
@ -166,7 +167,8 @@ Plugins are activated via the following "handshake" API call.
**Request:** empty body **Request:** empty body
**Response:** **Response:**
```
```json
{ {
"Implements": ["VolumeDriver"] "Implements": ["VolumeDriver"]
} }

View File

@ -116,7 +116,7 @@ value. This value can be the plugins socket or a path to a specification file
Authorization plugins can be loaded without restarting the daemon. Refer Authorization plugins can be loaded without restarting the daemon. Refer
to the [`dockerd` documentation](../reference/commandline/dockerd.md#configuration-reloading) for more information. to the [`dockerd` documentation](../reference/commandline/dockerd.md#configuration-reloading) for more information.
```bash ```console
$ dockerd --authorization-plugin=plugin1 --authorization-plugin=plugin2,... $ dockerd --authorization-plugin=plugin1 --authorization-plugin=plugin2,...
``` ```
@ -124,26 +124,26 @@ Docker's authorization subsystem supports multiple `--authorization-plugin` para
### Calling authorized command (allow) ### Calling authorized command (allow)
```bash ```console
$ docker pull centos $ docker pull centos
... <...>
f1b10cd84249: Pull complete f1b10cd84249: Pull complete
... <...>
``` ```
### Calling unauthorized command (deny) ### Calling unauthorized command (deny)
```bash ```console
$ docker pull centos $ docker pull centos
... <...>
docker: Error response from daemon: authorization denied by plugin PLUGIN_NAME: volumes are not allowed. docker: Error response from daemon: authorization denied by plugin PLUGIN_NAME: volumes are not allowed.
``` ```
### Error from plugins ### Error from plugins
```bash ```console
$ docker pull centos $ docker pull centos
... <...>
docker: Error response from daemon: plugin PLUGIN_NAME failed with error: AuthZPlugin.AuthZReq: Cannot connect to the Docker daemon. Is the docker daemon running on this host?. docker: Error response from daemon: plugin PLUGIN_NAME failed with error: AuthZPlugin.AuthZReq: Cannot connect to the Docker daemon. Is the docker daemon running on this host?.
``` ```
@ -180,6 +180,7 @@ should implement the following two methods:
"Err": "The error message if things go wrong" "Err": "The error message if things go wrong"
} }
``` ```
#### /AuthZPlugin.AuthZRes #### /AuthZPlugin.AuthZRes
**Request**: **Request**:

View File

@ -31,7 +31,7 @@ You need to install and enable the plugin and then restart the Docker daemon
before using the plugin. See the following example for the correct ordering before using the plugin. See the following example for the correct ordering
of steps. of steps.
``` ```console
$ docker plugin install cpuguy83/docker-overlay2-graphdriver-plugin # this command also enables the driver $ docker plugin install cpuguy83/docker-overlay2-graphdriver-plugin # this command also enables the driver
<output suppressed> <output suppressed>
$ pkill dockerd $ pkill dockerd
@ -309,6 +309,7 @@ Get an archive of the changes between the filesystem layers specified by the `ID
and `Parent`. `Parent` may be an empty string, in which case there is no parent. and `Parent`. `Parent` may be an empty string, in which case there is no parent.
**Response**: **Response**:
``` ```
{% raw %} {% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}
@ -354,6 +355,7 @@ Respond with a non-empty string error if an error occurred.
### /GraphDriver.ApplyDiff ### /GraphDriver.ApplyDiff
**Request**: **Request**:
``` ```
{% raw %} {% raw %}
{{ TAR STREAM }} {{ TAR STREAM }}

View File

@ -211,6 +211,7 @@ as they come in once the existing logs have been read.
to determine what set of logs to read. to determine what set of logs to read.
**Response**: **Response**:
``` ```
{% raw %}{{ log stream }}{% endraw %} {% raw %}{{ log stream }}{% endraw %}
``` ```

View File

@ -42,7 +42,7 @@ Once running however, network driver plugins are used just like the built-in
network drivers: by being mentioned as a driver in network-oriented Docker network drivers: by being mentioned as a driver in network-oriented Docker
commands. For example, commands. For example,
```bash ```console
$ docker network create --driver weave mynet $ docker network create --driver weave mynet
``` ```
@ -51,7 +51,7 @@ Some network driver plugins are listed in [plugins](legacy_plugins.md)
The `mynet` network is now owned by `weave`, so subsequent commands The `mynet` network is now owned by `weave`, so subsequent commands
referring to that network will be sent to the plugin, referring to that network will be sent to the plugin,
```bash ```console
$ docker run --network=mynet busybox top $ docker run --network=mynet busybox top
``` ```

View File

@ -29,20 +29,20 @@ node1 is the manager and node2 is the worker.
1. Prepare manager. In node 1: 1. Prepare manager. In node 1:
```bash ```console
$ docker swarm init $ docker swarm init
Swarm initialized: current node (dxn1zf6l61qsb1josjja83ngz) is now a manager. Swarm initialized: current node (dxn1zf6l61qsb1josjja83ngz) is now a manager.
``` ```
2. Join swarm, install plugin and create volume on worker. In node 2: 2. Join swarm, install plugin and create volume on worker. In node 2:
```bash ```console
$ docker swarm join \ $ docker swarm join \
--token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \ --token SWMTKN-1-49nj1cmql0jkz5s954yi3oex3nedyz0fb0xx14ie39trti4wxv-8vxv8rssmk743ojnwacrr2e7c \
192.168.99.100:2377 192.168.99.100:2377
``` ```
```bash ```console
$ docker plugin install tiborvass/sample-volume-plugin $ docker plugin install tiborvass/sample-volume-plugin
latest: Pulling from tiborvass/sample-volume-plugin latest: Pulling from tiborvass/sample-volume-plugin
eb9c16fbdc53: Download complete eb9c16fbdc53: Download complete
@ -51,23 +51,24 @@ node1 is the manager and node2 is the worker.
Installed plugin tiborvass/sample-volume-plugin Installed plugin tiborvass/sample-volume-plugin
``` ```
```bash ```console
$ docker volume create -d tiborvass/sample-volume-plugin --name pluginVol $ docker volume create -d tiborvass/sample-volume-plugin --name pluginVol
``` ```
3. Create a service using the plugin and volume. In node1: 3. Create a service using the plugin and volume. In node1:
```bash ```console
$ docker service create --name my-service --mount type=volume,volume-driver=tiborvass/sample-volume-plugin,source=pluginVol,destination=/tmp busybox top $ docker service create --name my-service --mount type=volume,volume-driver=tiborvass/sample-volume-plugin,source=pluginVol,destination=/tmp busybox top
$ docker service ls $ 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.
`docker service ls` shows service 1 instance of service running.
4. Observe the task getting scheduled in node 2: 4. Observe the task getting scheduled in node 2:
```bash ```console
{% raw %} {% raw %}
$ docker ps --format '{{.ID}}\t {{.Status}} {{.Names}} {{.Command}}' $ docker ps --format '{{.ID}}\t {{.Status}} {{.Names}} {{.Command}}'
83fc1e842599 Up 2 days my-service.1.9jn59qzn7nbc3m0zt1hij12xs "top" 83fc1e842599 Up 2 days my-service.1.9jn59qzn7nbc3m0zt1hij12xs "top"
@ -87,7 +88,7 @@ Note that node1 is the manager and node2 is the worker.
1. Install a global scoped network plugin on both manager and worker. On node1 1. Install a global scoped network plugin on both manager and worker. On node1
and node2: and node2:
```bash ```console
$ docker plugin install bboreham/weave2 $ docker plugin install bboreham/weave2
Plugin "bboreham/weave2" is requesting the following privileges: Plugin "bboreham/weave2" is requesting the following privileges:
- network: [host] - network: [host]
@ -102,7 +103,7 @@ Note that node1 is the manager and node2 is the worker.
2. Create a network using plugin on manager. On node1: 2. Create a network using plugin on manager. On node1:
```bash ```console
$ docker network create --driver=bboreham/weave2:latest globalnet $ docker network create --driver=bboreham/weave2:latest globalnet
$ docker network ls $ docker network ls
@ -115,12 +116,12 @@ containers get scheduled on both manager and worker.
On node 1: On node 1:
```bash ```console
$ docker service create --network globalnet --name myservice --replicas=8 mrjana/simpleweb simpleweb $ docker service create --network globalnet --name myservice --replicas=8 mrjana/simpleweb simpleweb
w90drnfzw85nygbie9kb89vpa w90drnfzw85nygbie9kb89vpa
``` ```
```bash ```console
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
87520965206a mrjana/simpleweb@sha256:317d7f221d68c86d503119b0ea12c29de42af0a22ca087d522646ad1069a47a4 "simpleweb" 5 seconds ago Up 4 seconds myservice.4.ytdzpktmwor82zjxkh118uf1v 87520965206a mrjana/simpleweb@sha256:317d7f221d68c86d503119b0ea12c29de42af0a22ca087d522646ad1069a47a4 "simpleweb" 5 seconds ago Up 4 seconds myservice.4.ytdzpktmwor82zjxkh118uf1v
@ -131,7 +132,7 @@ w90drnfzw85nygbie9kb89vpa
On node 2: On node 2:
```bash ```console
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
53c0ae7c1dae mrjana/simpleweb@sha256:317d7f221d68c86d503119b0ea12c29de42af0a22ca087d522646ad1069a47a4 "simpleweb" 2 seconds ago Up Less than a second myservice.7.x44tvvdm3iwkt9kif35f7ykz1 53c0ae7c1dae mrjana/simpleweb@sha256:317d7f221d68c86d503119b0ea12c29de42af0a22ca087d522646ad1069a47a4 "simpleweb" 2 seconds ago Up Less than a second myservice.7.x44tvvdm3iwkt9kif35f7ykz1
@ -142,14 +143,14 @@ w90drnfzw85nygbie9kb89vpa
4. Scale down the number of instances. On node1: 4. Scale down the number of instances. On node1:
```bash ```console
$ docker service scale myservice=0 $ docker service scale myservice=0
myservice scaled to 0 myservice scaled to 0
``` ```
5. Disable and uninstall the plugin on the worker. On node2: 5. Disable and uninstall the plugin on the worker. On node2:
```bash ```console
$ docker plugin rm -f bboreham/weave2 $ docker plugin rm -f bboreham/weave2
bboreham/weave2 bboreham/weave2
``` ```
@ -159,12 +160,12 @@ scheduled on the master and not on the worker, because the plugin is not availab
On node 1: On node 1:
```bash ```console
$ docker service scale myservice=8 $ docker service scale myservice=8
myservice scaled to 8 myservice scaled to 8
``` ```
```bash ```console
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cf4b0ec2415e mrjana/simpleweb@sha256:317d7f221d68c86d503119b0ea12c29de42af0a22ca087d522646ad1069a47a4 "simpleweb" 39 seconds ago Up 36 seconds myservice.3.r7p5o208jmlzpcbm2ytl3q6n1 cf4b0ec2415e mrjana/simpleweb@sha256:317d7f221d68c86d503119b0ea12c29de42af0a22ca087d522646ad1069a47a4 "simpleweb" 39 seconds ago Up 36 seconds myservice.3.r7p5o208jmlzpcbm2ytl3q6n1
@ -179,7 +180,7 @@ scheduled on the master and not on the worker, because the plugin is not availab
On node 2: On node 2:
```bash ```console
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
``` ```

View File

@ -54,7 +54,7 @@ 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 volume name and path on the host, and the `--volume-driver` flag
accepts a driver type. accepts a driver type.
```bash ```console
$ docker volume create --driver=flocker volumename $ docker volume create --driver=flocker volumename
$ docker container run -it --volume volumename:/data busybox sh $ docker container run -it --volume volumename:/data busybox sh

View File

@ -759,6 +759,7 @@ RUN instruction onto the next line. For example, consider these two lines:
RUN /bin/bash -c 'source $HOME/.bashrc; \ RUN /bin/bash -c 'source $HOME/.bashrc; \
echo $HOME' echo $HOME'
``` ```
Together they are equivalent to this single line: Together they are equivalent to this single line:
```dockerfile ```dockerfile
@ -938,6 +939,7 @@ the `--format` option to show just the labels;
```console ```console
$ docker image inspect --format='{{json .Config.Labels}}' myimage $ docker image inspect --format='{{json .Config.Labels}}' myimage
``` ```
```json ```json
{ {
"com.example.vendor": "ACME Incorporated", "com.example.vendor": "ACME Incorporated",
@ -2173,9 +2175,14 @@ ONBUILD RUN /usr/local/bin/python-build --dir /app/src
STOPSIGNAL signal STOPSIGNAL signal
``` ```
The `STOPSIGNAL` instruction sets the system call signal that will be sent to the container to exit. The `STOPSIGNAL` instruction sets the system call signal that will be sent to the
This signal can be a valid unsigned number that matches a position in the kernel's syscall table, for instance 9, container to exit. This signal can be a signal name in the format `SIG<NAME>`,
or a signal name in the format SIGNAME, for instance SIGKILL. for instance `SIGKILL`, or an unsigned number that matches a position in the
kernel's syscall table, for instance `9`. The default is `SIGTERM` if not
defined.
The image's default stopsignal can be overridden per container, using the
`--stop-signal` flag on `docker run` and `docker create`.
## HEALTHCHECK ## HEALTHCHECK

View File

@ -84,7 +84,7 @@ containers, see [**Configuration file** section](cli.md#configuration-files).
### Attach to and detach from a running container ### Attach to and detach from a running container
```bash ```console
$ docker run -d --name topdemo ubuntu /usr/bin/top -b $ docker run -d --name topdemo ubuntu /usr/bin/top -b
$ docker attach topdemo $ docker attach topdemo
@ -130,22 +130,19 @@ $ docker ps -a | grep topdemo
And in this second example, you can see the exit code returned by the `bash` 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: process is returned by the `docker attach` command to its caller too:
```bash ```console
$ docker run --name test -d -it debian $ docker run --name test -d -it debian
275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab
275c44472aebd77c926d4527885bb09f2f6db21d878c75f0a1c212c03d3bcfab $ docker attach test
root@f38c87f2a42d:/# exit 13
$ docker attach test exit
root@f38c87f2a42d:/# exit 13 $ echo $?
13
exit $ docker ps -a | grep test
$ echo $? 275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test
13
$ docker ps -a | grep test
275c44472aeb debian:7 "/bin/bash" 26 seconds ago Exited (13) 17 seconds ago test
``` ```

View File

@ -92,7 +92,7 @@ context.
For example, run this command to use a directory called `docker` in the branch For example, run this command to use a directory called `docker` in the branch
`container`: `container`:
```bash ```console
$ docker build https://github.com/docker/rootfs.git#container:docker $ docker build https://github.com/docker/rootfs.git#container:docker
``` ```
@ -120,7 +120,7 @@ Build Syntax Suffix | Commit Used | Build Context Used
If you pass an URL to a remote tarball, the URL itself is sent to the daemon: If you pass an URL to a remote tarball, the URL itself is sent to the daemon:
```bash ```console
$ docker build http://server/context.tar.gz $ docker build http://server/context.tar.gz
``` ```
@ -136,7 +136,7 @@ build context. Tarball contexts must be tar archives conforming to the standard
Instead of specifying a context, you can pass a single `Dockerfile` in the Instead of specifying a context, you can pass a single `Dockerfile` in the
`URL` or pipe the file in via `STDIN`. To pipe a `Dockerfile` from `STDIN`: `URL` or pipe the file in via `STDIN`. To pipe a `Dockerfile` from `STDIN`:
```bash ```console
$ docker build - < Dockerfile $ docker build - < Dockerfile
``` ```
@ -176,7 +176,7 @@ build fails, a non-zero failure code will be returned.
There should be informational output of the reason for failure output to There should be informational output of the reason for failure output to
`STDERR`: `STDERR`:
```bash ```console
$ docker build -t fail . $ docker build -t fail .
Sending build context to Docker daemon 2.048 kB Sending build context to Docker daemon 2.048 kB
@ -198,7 +198,7 @@ See also:
### Build with PATH ### Build with PATH
```bash ```console
$ docker build . $ docker build .
Uploading context 10240 bytes Uploading context 10240 bytes
@ -243,7 +243,7 @@ you must use `--rm=false`. This does not affect the build cache.
### Build with URL ### Build with URL
```bash ```console
$ docker build github.com/creack/docker-firefox $ docker build github.com/creack/docker-firefox
``` ```
@ -251,7 +251,7 @@ This will clone the GitHub repository and use the cloned repository as context.
The Dockerfile at the root of the repository is used as Dockerfile. You can The Dockerfile at the root of the repository is used as Dockerfile. You can
specify an arbitrary Git repository by using the `git://` or `git@` scheme. specify an arbitrary Git repository by using the `git://` or `git@` scheme.
```bash ```console
$ docker build -f ctx/Dockerfile http://server/ctx.tar.gz $ docker build -f ctx/Dockerfile http://server/ctx.tar.gz
Downloading context: http://server/ctx.tar.gz [===================>] 240 B/240 B Downloading context: http://server/ctx.tar.gz [===================>] 240 B/240 B
@ -277,7 +277,7 @@ ctx/container.cfg /` operation works as expected.
### Build with - ### Build with -
```bash ```console
$ docker build - < Dockerfile $ docker build - < Dockerfile
``` ```
@ -286,7 +286,7 @@ context, no contents of any local directory will be sent to the Docker daemon.
Since there is no context, a Dockerfile `ADD` only works if it refers to a Since there is no context, a Dockerfile `ADD` only works if it refers to a
remote URL. remote URL.
```bash ```console
$ docker build - < context.tar.gz $ docker build - < context.tar.gz
``` ```
@ -295,7 +295,7 @@ formats are: bzip2, gzip and xz.
### Use a .dockerignore file ### Use a .dockerignore file
```bash ```console
$ docker build . $ docker build .
Uploading context 18.829 MB Uploading context 18.829 MB
@ -334,7 +334,7 @@ files.
### Tag an image (-t) ### Tag an image (-t)
```bash ```console
$ docker build -t vieux/apache:2.0 . $ docker build -t vieux/apache:2.0 .
``` ```
@ -348,27 +348,27 @@ version.
For example, to tag an image both as `whenry/fedora-jboss:latest` and For example, to tag an image both as `whenry/fedora-jboss:latest` and
`whenry/fedora-jboss:v2.1`, use the following: `whenry/fedora-jboss:v2.1`, use the following:
```bash ```console
$ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 . $ docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .
``` ```
### Specify a Dockerfile (-f) ### Specify a Dockerfile (-f)
```bash ```console
$ docker build -f Dockerfile.debug . $ docker build -f Dockerfile.debug .
``` ```
This will use a file called `Dockerfile.debug` for the build instructions This will use a file called `Dockerfile.debug` for the build instructions
instead of `Dockerfile`. instead of `Dockerfile`.
```bash ```console
$ curl example.com/remote/Dockerfile | docker build -f - . $ curl example.com/remote/Dockerfile | docker build -f - .
``` ```
The above command will use the current directory as the build context and read The above command will use the current directory as the build context and read
a Dockerfile from stdin. a Dockerfile from stdin.
```bash ```console
$ docker build -f dockerfiles/Dockerfile.debug -t myapp_debug . $ docker build -f dockerfiles/Dockerfile.debug -t myapp_debug .
$ docker build -f dockerfiles/Dockerfile.prod -t myapp_prod . $ docker build -f dockerfiles/Dockerfile.prod -t myapp_prod .
``` ```
@ -377,7 +377,7 @@ The above commands will build the current build context (as specified by the
`.`) twice, once using a debug version of a `Dockerfile` and once using a `.`) twice, once using a debug version of a `Dockerfile` and once using a
production version. production version.
```bash ```console
$ cd /home/me/myapp/some/dir/really/deep $ cd /home/me/myapp/some/dir/really/deep
$ docker build -f /home/me/myapp/dockerfiles/debug /home/me/myapp $ docker build -f /home/me/myapp/dockerfiles/debug /home/me/myapp
$ docker build -f ../../../../dockerfiles/debug /home/me/myapp $ docker build -f ../../../../dockerfiles/debug /home/me/myapp
@ -420,7 +420,7 @@ A good example is `http_proxy` or source versions for pulling intermediate
files. The `ARG` instruction lets Dockerfile authors define values that users files. The `ARG` instruction lets Dockerfile authors define values that users
can set at build-time using the `--build-arg` flag: can set at build-time using the `--build-arg` flag:
```bash ```console
$ docker build --build-arg HTTP_PROXY=http://10.20.30.2:1234 --build-arg FTP_PROXY=http://40.50.60.5:4567 . $ docker build --build-arg HTTP_PROXY=http://10.20.30.2:1234 --build-arg FTP_PROXY=http://40.50.60.5:4567 .
``` ```
@ -439,7 +439,7 @@ You may also use the `--build-arg` flag without a value, in which case the value
from the local environment will be propagated into the Docker container being from the local environment will be propagated into the Docker container being
built: built:
```bash ```console
$ export HTTP_PROXY=http://10.20.30.2:1234 $ export HTTP_PROXY=http://10.20.30.2:1234
$ docker build --build-arg HTTP_PROXY . $ docker build --build-arg HTTP_PROXY .
``` ```
@ -491,7 +491,7 @@ FROM alpine AS production-env
... ...
``` ```
```bash ```console
$ docker build -t mybuildimage --target build-env . $ docker build -t mybuildimage --target build-env .
``` ```
@ -516,7 +516,7 @@ The following example builds an image using the current directory (`.`) as build
context, and exports the files to a directory named `out` in the current directory. context, and exports the files to a directory named `out` in the current directory.
If the directory does not exist, Docker creates the directory automatically: If the directory does not exist, Docker creates the directory automatically:
```bash ```console
$ docker build -o out . $ docker build -o out .
``` ```
@ -525,13 +525,13 @@ thus uses the default (`local`) exporter. The example below shows the equivalent
using the long-hand CSV syntax, specifying both `type` and `dest` (destination using the long-hand CSV syntax, specifying both `type` and `dest` (destination
path): path):
```bash ```console
$ docker build --output type=local,dest=out . $ docker build --output type=local,dest=out .
``` ```
Use the `tar` type to export the files as a `.tar` archive: Use the `tar` type to export the files as a `.tar` archive:
```bash ```console
$ docker build --output type=tar,dest=out.tar . $ docker build --output type=tar,dest=out.tar .
``` ```
@ -540,8 +540,8 @@ case, `-` is specified as destination, which automatically selects the `tar` typ
and writes the output tarball to standard output, which is then redirected to and writes the output tarball to standard output, which is then redirected to
the `out.tar` file: the `out.tar` file:
```bash ```console
docker build -o - . > out.tar $ docker build -o - . > out.tar
``` ```
The `--output` option exports all files from the target stage. A common pattern The `--output` option exports all files from the target stage. A common pattern
@ -562,7 +562,7 @@ COPY --from=build-stage /go/bin/vndr /
When building the Dockerfile with the `-o` option, only the files from the final When building the Dockerfile with the `-o` option, only the files from the final
stage are exported to the `out` directory, in this case, the `vndr` binary: stage are exported to the `out` directory, in this case, the `vndr` binary:
```bash ```console
$ docker build -o out . $ docker build -o out .
[+] Building 2.3s (7/7) FINISHED [+] Building 2.3s (7/7) FINISHED
@ -610,7 +610,7 @@ options) allow pulling layer data for intermediate stages in multi-stage builds.
The following example builds an image with inline-cache metadata and pushes it The following example builds an image with inline-cache metadata and pushes it
to a registry, then uses the image as a cache source on another machine: to a registry, then uses the image as a cache source on another machine:
```bash ```console
$ docker build -t myname/myapp --build-arg BUILDKIT_INLINE_CACHE=1 . $ docker build -t myname/myapp --build-arg BUILDKIT_INLINE_CACHE=1 .
$ docker push myname/myapp $ docker push myname/myapp
``` ```
@ -618,8 +618,9 @@ $ docker push myname/myapp
After pushing the image, the image is used as cache source on another machine. After pushing the image, the image is used as cache source on another machine.
BuildKit automatically pulls the image from the registry if needed. BuildKit automatically pulls the image from the registry if needed.
```bash On another machine:
# on another machine
```console
$ docker build --cache-from myname/myapp . $ docker build --cache-from myname/myapp .
``` ```
@ -725,7 +726,7 @@ To enable experimental features, you need to start the Docker daemon with
Then make sure the experimental flag is enabled: Then make sure the experimental flag is enabled:
```bash ```console
$ docker version -f '{{.Server.Experimental}}' $ docker version -f '{{.Server.Experimental}}'
true true
``` ```
@ -745,15 +746,15 @@ RUN rm /remove_me
An image named `test` is built with `--squash` argument. An image named `test` is built with `--squash` argument.
```bash ```console
$ docker build --squash -t test . $ docker build --squash -t test .
[...] <...>
``` ```
If everything is right, the history looks like this: If everything is right, the history looks like this:
```bash ```console
$ docker history test $ docker history test
IMAGE CREATED CREATED BY SIZE COMMENT IMAGE CREATED CREATED BY SIZE COMMENT

View File

@ -24,7 +24,7 @@ redirect_from:
To list available commands, either run `docker` with no parameters To list available commands, either run `docker` with no parameters
or execute `docker help`: or execute `docker help`:
```bash ```console
$ docker $ docker
Usage: docker [OPTIONS] COMMAND [ARG...] Usage: docker [OPTIONS] COMMAND [ARG...]
docker [ --help | -v | --version ] docker [ --help | -v | --version ]

View File

@ -43,7 +43,7 @@ created. Supported `Dockerfile` instructions:
### Commit a container ### Commit a container
```bash ```console
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -62,7 +62,7 @@ svendowideit/testimage version3 f5283438590d 16 sec
### Commit a container with new configurations ### Commit a container with new configurations
```bash ```console
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -84,7 +84,7 @@ $ docker inspect -f "{{ .Config.Env }}" f5283438590d
### Commit a container with new `CMD` and `EXPOSE` instructions ### Commit a container with new `CMD` and `EXPOSE` instructions
```bash ```console
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

View File

@ -33,7 +33,7 @@ For detailed information about using configs, refer to [store configuration data
### Create a config ### Create a config
```bash ```console
$ printf <config> | docker config create my_config - $ printf <config> | docker config create my_config -
onakdyv307se2tl7nl20anokv onakdyv307se2tl7nl20anokv
@ -46,7 +46,7 @@ onakdyv307se2tl7nl20anokv my_config 6 seconds ago 6 seconds ag
### Create a config with a file ### Create a config with a file
```bash ```console
$ docker config create my_config ./config.json $ docker config create my_config ./config.json
dg426haahpi5ezmkkj5kyl3sn dg426haahpi5ezmkkj5kyl3sn
@ -59,7 +59,7 @@ dg426haahpi5ezmkkj5kyl3sn my_config 7 seconds ago 7 seconds ag
### Create a config with labels ### Create a config with labels
```bash ```console
$ docker config create \ $ docker config create \
--label env=dev \ --label env=dev \
--label rev=20170324 \ --label rev=20170324 \
@ -68,7 +68,7 @@ $ docker config create \
eo7jnzguqgtpdah3cm5srfb97 eo7jnzguqgtpdah3cm5srfb97
``` ```
```bash ```console
$ docker config inspect my_config $ docker config inspect my_config
[ [

View File

@ -43,14 +43,14 @@ You can inspect a config, either by its *name*, or *ID*
For example, given the following config: For example, given the following config:
```bash ```console
$ docker config ls $ docker config ls
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
eo7jnzguqgtpdah3cm5srfb97 my_config 3 minutes ago 3 minutes ago eo7jnzguqgtpdah3cm5srfb97 my_config 3 minutes ago 3 minutes ago
``` ```
```bash ```console
$ docker config inspect config.json $ docker config inspect config.json
``` ```
@ -83,7 +83,7 @@ You can use the --format option to obtain specific information about a
config. The following example command outputs the creation time of the config. The following example command outputs the creation time of the
config. config.
```bash ```console
$ docker config inspect --format='{{.CreatedAt}}' eo7jnzguqgtpdah3cm5srfb97 $ docker config inspect --format='{{.CreatedAt}}' eo7jnzguqgtpdah3cm5srfb97
2017-03-24 08:15:09.735271783 +0000 UTC 2017-03-24 08:15:09.735271783 +0000 UTC

View File

@ -36,7 +36,7 @@ For detailed information about using configs, refer to [store configuration data
## Examples ## Examples
```bash ```console
$ docker config ls $ docker config ls
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
@ -60,7 +60,7 @@ The currently supported filters are:
The `id` filter matches all or prefix of a config's id. The `id` filter matches all or prefix of a config's id.
```bash ```console
$ docker config ls -f "id=6697bflskwj1998km1gnnjr38" $ docker config ls -f "id=6697bflskwj1998km1gnnjr38"
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
@ -75,7 +75,7 @@ a `label` and a value.
The following filter matches all configs with a `project` label regardless of The following filter matches all configs with a `project` label regardless of
its value: its value:
```bash ```console
$ docker config ls --filter label=project $ docker config ls --filter label=project
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
@ -85,7 +85,7 @@ mem02h8n73mybpgqjf0kfi1n0 test_config About an hour ago Abou
The following filter matches only services with the `project` label with the The following filter matches only services with the `project` label with the
`project-a` value. `project-a` value.
```bash ```console
$ docker service ls --filter label=project=test $ docker service ls --filter label=project=test
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
@ -98,7 +98,7 @@ The `name` filter matches on all or prefix of a config's name.
The following filter matches config with a name containing a prefix of `test`. The following filter matches config with a name containing a prefix of `test`.
```bash ```console
$ docker config ls --filter name=test_config $ docker config ls --filter name=test_config
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
@ -128,7 +128,7 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`ID` and `Name` entries separated by a colon (`:`) for all images: `ID` and `Name` entries separated by a colon (`:`) for all images:
```bash ```console
$ docker config ls --format "{{.ID}}: {{.Name}}" $ docker config ls --format "{{.ID}}: {{.Name}}"
77af4d6b9913: config-1 77af4d6b9913: config-1
@ -139,7 +139,7 @@ b6fa739cedf5: config-2
To list all configs with their name and created date in a table format you To list all configs with their name and created date in a table format you
can use: can use:
```bash ```console
$ docker config ls --format "table {{.ID}}\t{{.Name}}\t{{.CreatedAt}}" $ docker config ls --format "table {{.ID}}\t{{.Name}}\t{{.CreatedAt}}"
ID NAME CREATED ID NAME CREATED

View File

@ -35,7 +35,7 @@ For detailed information about using configs, refer to [store configuration data
This example removes a config: This example removes a config:
```bash ```console
$ docker config rm my_config $ docker config rm my_config
sapth4csdo5b6wz2p5uimh5xg sapth4csdo5b6wz2p5uimh5xg
``` ```

View File

@ -26,7 +26,7 @@ Removes all stopped containers.
### Prune containers ### Prune containers
```bash ```console
$ docker container prune $ docker container prune
WARNING! This will remove all stopped containers. WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y Are you sure you want to continue? [y/N] y
@ -66,7 +66,7 @@ containers without the specified labels.
The following removes containers created more than 5 minutes ago: The following removes containers created more than 5 minutes ago:
```bash ```console
$ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}' $ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
CONTAINER ID IMAGE COMMAND CREATED AT STATUS CONTAINER ID IMAGE COMMAND CREATED AT STATUS
@ -88,7 +88,7 @@ CONTAINER ID IMAGE COMMAND CREATED AT
The following removes containers created before `2017-01-04T13:10:00`: The following removes containers created before `2017-01-04T13:10:00`:
```bash ```console
$ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}' $ docker ps -a --format 'table {{.ID}}\t{{.Image}}\t{{.Command}}\t{{.CreatedAt}}\t{{.Status}}'
CONTAINER ID IMAGE COMMAND CREATED AT STATUS CONTAINER ID IMAGE COMMAND CREATED AT STATUS

View File

@ -62,7 +62,7 @@ kubernetes options. The example below creates the context `my-context`
with a docker endpoint of `/var/run/docker.sock` and a kubernetes configuration with a docker endpoint of `/var/run/docker.sock` and a kubernetes configuration
sourced from the file `/home/me/my-kube-config`: sourced from the file `/home/me/my-kube-config`:
```bash ```console
$ docker context create \ $ docker context create \
--docker host=unix:///var/run/docker.sock \ --docker host=unix:///var/run/docker.sock \
--kubernetes config-file=/home/me/my-kube-config \ --kubernetes config-file=/home/me/my-kube-config \
@ -75,19 +75,19 @@ Use the `--from=<context-name>` option to create a new context from
an existing context. The example below creates a new context named `my-context` an existing context. The example below creates a new context named `my-context`
from the existing context `existing-context`: from the existing context `existing-context`:
```bash ```console
$ docker context create --from existing-context my-context $ docker context create --from existing-context my-context
``` ```
If the `--from` option is not set, the `context` is created from the current context: If the `--from` option is not set, the `context` is created from the current context:
```bash ```console
$ docker context create my-context $ docker context create my-context
``` ```
This can be used to create a context out of an existing `DOCKER_HOST` based script: This can be used to create a context out of an existing `DOCKER_HOST` based script:
```bash ```console
$ source my-setup-script.sh $ source my-setup-script.sh
$ docker context create my-context $ docker context create my-context
``` ```
@ -98,7 +98,7 @@ new context named `my-context` using the docker endpoint configuration from
the existing context `existing-context` and a kubernetes configuration sourced the existing context `existing-context` and a kubernetes configuration sourced
from the file `/home/me/my-kube-config`: from the file `/home/me/my-kube-config`:
```bash ```console
$ docker context create \ $ docker context create \
--docker from=existing-context \ --docker from=existing-context \
--kubernetes config-file=/home/me/my-kube-config \ --kubernetes config-file=/home/me/my-kube-config \
@ -110,7 +110,7 @@ To source only the `kubernetes` configuration from an existing context use the
context named `my-context` using the kuberentes configuration from the existing context named `my-context` using the kuberentes configuration from the existing
context `existing-context` and a docker endpoint of `/var/run/docker.sock`: context `existing-context` and a docker endpoint of `/var/run/docker.sock`:
```bash ```console
$ docker context create \ $ docker context create \
--docker host=unix:///var/run/docker.sock \ --docker host=unix:///var/run/docker.sock \
--kubernetes from=existing-context \ --kubernetes from=existing-context \

View File

@ -23,7 +23,7 @@ Inspects one or more contexts.
### Inspect a context by name ### Inspect a context by name
```bash ```console
$ docker context inspect "local+aks" $ docker context inspect "local+aks"
[ [

View File

@ -25,7 +25,9 @@ Options:
Use `docker context ls` to print all contexts. The currently active context is Use `docker context ls` to print all contexts. The currently active context is
indicated with an `*`: indicated with an `*`:
```bash ```console
$ docker context ls
NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR NAME DESCRIPTION DOCKER ENDPOINT KUBERNETES ENDPOINT ORCHESTRATOR
default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm default * Current DOCKER_HOST based configuration unix:///var/run/docker.sock swarm
production tcp:///prod.corp.example.com:2376 production tcp:///prod.corp.example.com:2376

View File

@ -54,7 +54,7 @@ See [context create](context_create.md).
### Update an existing context ### Update an existing context
```bash ```console
$ docker context update \ $ docker context update \
--description "some description" \ --description "some description" \
--docker "host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file" \ --docker "host=tcp://myserver:2376,ca=~/ca-file,cert=~/cert-file,key=~/key-file" \

View File

@ -95,11 +95,11 @@ the user in the container. However, you can still copy such files by manually
running `tar` in `docker exec`. Both of the following examples do the same thing 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): in different ways (consider `SRC_PATH` and `DEST_PATH` are directories):
```bash ```console
$ docker exec CONTAINER tar Ccf $(dirname SRC_PATH) - $(basename SRC_PATH) | tar Cxf DEST_PATH - $ docker exec CONTAINER tar Ccf $(dirname SRC_PATH) - $(basename SRC_PATH) | tar Cxf DEST_PATH -
``` ```
```bash ```console
$ tar Ccf $(dirname SRC_PATH) - $(basename SRC_PATH) | docker exec -i CONTAINER tar Cxf DEST_PATH - $ tar Ccf $(dirname SRC_PATH) - $(basename SRC_PATH) | docker exec -i CONTAINER tar Cxf DEST_PATH -
``` ```

View File

@ -109,7 +109,7 @@ Options:
Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes), Unit is optional and can be `b` (bytes), `k` (kilobytes), `m` (megabytes),
or `g` (gigabytes). If you omit the unit, the system uses bytes. or `g` (gigabytes). If you omit the unit, the system uses bytes.
--stop-signal string Signal to stop a container (default "SIGTERM") --stop-signal string Signal to stop a container (default "SIGTERM")
--stop-timeout=10 Timeout (in seconds) to stop a container --stop-timeout int Timeout (in seconds) to stop a container
--storage-opt value Storage driver options for the container (default []) --storage-opt value Storage driver options for the container (default [])
--sysctl value Sysctl options (default map[]) --sysctl value Sysctl options (default map[])
--tmpfs value Mount a tmpfs directory (default []) --tmpfs value Mount a tmpfs directory (default [])
@ -131,6 +131,7 @@ Options:
--volumes-from value Mount volumes from the specified container(s) (default []) --volumes-from value Mount volumes from the specified container(s) (default [])
-w, --workdir string Working directory inside the container -w, --workdir string Working directory inside the container
``` ```
## Description ## Description
The `docker create` command creates a writeable container layer over the The `docker create` command creates a writeable container layer over the
@ -149,7 +150,7 @@ Please see the [run command](run.md) section and the [Docker run reference](../r
### Create and start a container ### Create and start a container
```bash ```console
$ docker create -t -i fedora bash $ docker create -t -i fedora bash
6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752 6d8af538ec541dd581ebc2a24153a28329acb5268abe5ef868c1f1a261221752
@ -165,7 +166,7 @@ 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` (i.e., `docker run` too). For example, this allows you to `create` the `data`
volume container, and then use it from another container: volume container, and then use it from another container:
```bash ```console
$ docker create -v /data --name data ubuntu $ docker create -v /data --name data ubuntu
240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57 240633dfbb98128fa77473d3d9018f6123b99c454b3251427ae190a7d951ad57
@ -180,7 +181,7 @@ drwxr-xr-x 48 root root 4096 Dec 5 04:11 ..
Similarly, `create` a host directory bind mounted volume container, which can Similarly, `create` a host directory bind mounted volume container, which can
then be used from the subsequent container: then be used from the subsequent container:
```bash ```console
$ docker create -v /home/docker:/docker --name docker ubuntu $ docker create -v /home/docker:/docker --name docker ubuntu
9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03 9aa88c08f319cd1e4515c3c46b0de7cc9aa75e878357b1e96f91e2c773029f03
@ -202,7 +203,7 @@ drwxr-xr-x 32 1000 staff 1140 Dec 5 04:01 docker
Set storage driver options per container. Set storage driver options per container.
```bash ```console
$ docker create -it --storage-opt size=120G fedora /bin/bash $ docker create -it --storage-opt size=120G fedora /bin/bash
``` ```
@ -245,8 +246,8 @@ our container needs access to a character device with major `42` and
any number of minor number (added as new devices appear), the any number of minor number (added as new devices appear), the
following rule would be added: following rule would be added:
``` ```console
docker create --device-cgroup-rule='c 42:* rmw' -name my-container my-image $ docker create --device-cgroup-rule='c 42:* rmw' -name my-container my-image
``` ```
Then, a user could ask `udev` to execute a script that would `docker exec my-container mknod newDevX c 42 <minor>` Then, a user could ask `udev` to execute a script that would `docker exec my-container mknod newDevX c 42 <minor>`

View File

@ -33,7 +33,7 @@ You can use the full or shortened container ID or the container name set using
Inspect the changes to an `nginx` container: Inspect the changes to an `nginx` container:
```bash ```console
$ docker diff 1fdfd1f54c1b $ docker diff 1fdfd1f54c1b
C /dev C /dev

View File

@ -175,20 +175,21 @@ find examples of using Systemd socket activation with Docker and Systemd in the
You can configure the Docker daemon to listen to multiple sockets at the same You can configure the Docker daemon to listen to multiple sockets at the same
time using multiple `-H` options: time using multiple `-H` options:
```bash The example below runs the daemon listenin on the default unix socket, and
# listen using the default unix socket, and on 2 specific IP addresses on this host. on 2 specific IP addresses on this host:
```console
$ sudo dockerd -H unix:///var/run/docker.sock -H tcp://192.168.59.106 -H tcp://10.10.10.2 $ 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 The Docker client will honor the `DOCKER_HOST` environment variable to set the
`-H` flag for the client. Use **one** of the following commands: `-H` flag for the client. Use **one** of the following commands:
```bash ```console
$ docker -H tcp://0.0.0.0:2375 ps $ docker -H tcp://0.0.0.0:2375 ps
``` ```
```bash ```console
$ export DOCKER_HOST="tcp://0.0.0.0:2375" $ export DOCKER_HOST="tcp://0.0.0.0:2375"
$ docker ps $ docker ps
@ -198,7 +199,7 @@ Setting the `DOCKER_TLS_VERIFY` environment variable to any value other than
the empty string is equivalent to setting the `--tlsverify` flag. The following the empty string is equivalent to setting the `--tlsverify` flag. The following
are equivalent: are equivalent:
```bash ```console
$ docker --tlsverify ps $ docker --tlsverify ps
# or # or
$ export DOCKER_TLS_VERIFY=1 $ export DOCKER_TLS_VERIFY=1
@ -211,7 +212,7 @@ precedence over `HTTP_PROXY`.
The Docker client supports connecting to a remote daemon via SSH: The Docker client supports connecting to a remote daemon via SSH:
``` ```console
$ docker -H ssh://me@example.com:22 ps $ docker -H ssh://me@example.com:22 ps
$ docker -H ssh://me@example.com ps $ docker -H ssh://me@example.com ps
$ docker -H ssh://example.com ps $ docker -H ssh://example.com ps
@ -268,22 +269,21 @@ when no `-H` was passed in.
Run Docker in daemon mode: Run Docker in daemon mode:
```bash ```console
$ sudo <path to>/dockerd -H 0.0.0.0:5555 & $ sudo <path to>/dockerd -H 0.0.0.0:5555 &
``` ```
Download an `ubuntu` image: Download an `ubuntu` image:
```bash ```console
$ docker -H :5555 pull ubuntu $ docker -H :5555 pull ubuntu
``` ```
You can use multiple `-H`, for example, if you want to listen on both You can use multiple `-H`, for example, if you want to listen on both
TCP and a Unix socket TCP and a Unix socket
```bash ```console
# Run docker in daemon mode $ sudo dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock &
$ sudo <path to>/dockerd -H tcp://127.0.0.1:2375 -H unix:///var/run/docker.sock &
# Download an ubuntu image, use default Unix socket # Download an ubuntu image, use default Unix socket
$ docker pull ubuntu $ docker pull ubuntu
# OR use the TCP port # OR use the TCP port
@ -396,7 +396,7 @@ not use loopback in production. Ensure your Engine daemon has a
###### Example: ###### Example:
```bash ```console
$ sudo dockerd --storage-opt dm.thinpooldev=/dev/mapper/thin-pool $ sudo dockerd --storage-opt dm.thinpooldev=/dev/mapper/thin-pool
``` ```
@ -407,7 +407,7 @@ device for you.
###### Example: ###### Example:
```bash ```console
$ sudo dockerd --storage-opt dm.directlvm_device=/dev/xvdf $ sudo dockerd --storage-opt dm.directlvm_device=/dev/xvdf
``` ```
@ -417,7 +417,7 @@ Sets the percentage of passed in block device to use for storage.
###### Example: ###### Example:
```bash ```console
$ sudo dockerd --storage-opt dm.thinp_percent=95 $ sudo dockerd --storage-opt dm.thinp_percent=95
``` ```
@ -427,7 +427,7 @@ Sets the percentage of the passed in block device to use for metadata storage.
###### Example: ###### Example:
```bash ```console
$ sudo dockerd --storage-opt dm.thinp_metapercent=1 $ sudo dockerd --storage-opt dm.thinp_metapercent=1
``` ```
@ -438,7 +438,7 @@ autoextend the available space [100 = disabled]
###### Example: ###### Example:
```bash ```console
$ sudo dockerd --storage-opt dm.thinp_autoextend_threshold=80 $ sudo dockerd --storage-opt dm.thinp_autoextend_threshold=80
``` ```
@ -449,7 +449,7 @@ attempts to autoextend the available space [100 = disabled]
###### Example: ###### Example:
```bash ```console
$ sudo dockerd --storage-opt dm.thinp_autoextend_percent=20 $ sudo dockerd --storage-opt dm.thinp_autoextend_percent=20
``` ```
@ -468,7 +468,7 @@ new base device size.
###### Examples ###### Examples
```bash ```console
$ sudo dockerd --storage-opt dm.basesize=50G $ sudo dockerd --storage-opt dm.basesize=50G
``` ```
@ -480,7 +480,7 @@ This value affects the system-wide "base" empty filesystem
that may already be initialized and inherited by pulled images. Typically, that may already be initialized and inherited by pulled images. Typically,
a change to this value requires additional steps to take effect: a change to this value requires additional steps to take effect:
```bash ```console
$ sudo service docker stop $ sudo service docker stop
$ sudo rm -rf /var/lib/docker $ sudo rm -rf /var/lib/docker
@ -503,7 +503,7 @@ much space.
###### Example ###### Example
```bash ```console
$ sudo dockerd --storage-opt dm.loopdatasize=200G $ sudo dockerd --storage-opt dm.loopdatasize=200G
``` ```
@ -521,7 +521,7 @@ this much space.
###### Example ###### Example
```bash ```console
$ sudo dockerd --storage-opt dm.loopmetadatasize=4G $ sudo dockerd --storage-opt dm.loopmetadatasize=4G
``` ```
@ -532,7 +532,7 @@ options are "ext4" and "xfs". The default is "xfs"
###### Example ###### Example
```bash ```console
$ sudo dockerd --storage-opt dm.fs=ext4 $ sudo dockerd --storage-opt dm.fs=ext4
``` ```
@ -542,7 +542,7 @@ Specifies extra mkfs arguments to be used when creating the base device.
###### Example ###### Example
```bash ```console
$ sudo dockerd --storage-opt "dm.mkfsarg=-O ^has_journal" $ sudo dockerd --storage-opt "dm.mkfsarg=-O ^has_journal"
``` ```
@ -552,7 +552,7 @@ Specifies extra mount options used when mounting the thin devices.
###### Example ###### Example
```bash ```console
$ sudo dockerd --storage-opt dm.mountopt=nodiscard $ sudo dockerd --storage-opt dm.mountopt=nodiscard
``` ```
@ -568,7 +568,7 @@ device.
###### Example ###### Example
```bash ```console
$ sudo dockerd \ $ sudo dockerd \
--storage-opt dm.datadev=/dev/sdb1 \ --storage-opt dm.datadev=/dev/sdb1 \
--storage-opt dm.metadatadev=/dev/sdc1 --storage-opt dm.metadatadev=/dev/sdc1
@ -586,13 +586,13 @@ data, or even better on an SSD.
If setting up a new metadata pool it is required to be valid. This can be 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: achieved by zeroing the first 4k to indicate empty metadata, like this:
```bash ```console
$ dd if=/dev/zero of=$metadata_dev bs=4096 count=1 $ dd if=/dev/zero of=$metadata_dev bs=4096 count=1
``` ```
###### Example ###### Example
```bash ```console
$ sudo dockerd \ $ sudo dockerd \
--storage-opt dm.datadev=/dev/sdb1 \ --storage-opt dm.datadev=/dev/sdb1 \
--storage-opt dm.metadatadev=/dev/sdc1 --storage-opt dm.metadatadev=/dev/sdc1
@ -605,7 +605,7 @@ blocksize is 64K.
###### Example ###### Example
```bash ```console
$ sudo dockerd --storage-opt dm.blocksize=512K $ sudo dockerd --storage-opt dm.blocksize=512K
``` ```
@ -621,7 +621,7 @@ returned to the system for other use when containers are removed.
###### Examples ###### Examples
```bash ```console
$ sudo dockerd --storage-opt dm.blkdiscard=false $ sudo dockerd --storage-opt dm.blkdiscard=false
``` ```
@ -633,11 +633,11 @@ Overrides the `udev` synchronization checks between `devicemapper` and `udev`.
To view the `udev` sync support of a Docker daemon that is using the To view the `udev` sync support of a Docker daemon that is using the
`devicemapper` driver, run: `devicemapper` driver, run:
```bash ```console
$ docker info $ docker info
[...] <...>
Udev Sync Supported: true Udev Sync Supported: true
[...] <...>
``` ```
When `udev` sync support is `true`, then `devicemapper` and udev can When `udev` sync support is `true`, then `devicemapper` and udev can
@ -651,7 +651,7 @@ results in errors and failures. (For information on these failures, see
To allow the `docker` daemon to start, regardless of `udev` sync not being To allow the `docker` daemon to start, regardless of `udev` sync not being
supported, set `dm.override_udev_sync_check` to true: supported, set `dm.override_udev_sync_check` to true:
```bash ```console
$ sudo dockerd --storage-opt dm.override_udev_sync_check=true $ sudo dockerd --storage-opt dm.override_udev_sync_check=true
``` ```
@ -684,7 +684,7 @@ loop trying to remove a busy device.
###### Example ###### Example
```bash ```console
$ sudo dockerd --storage-opt dm.use_deferred_removal=true $ sudo dockerd --storage-opt dm.use_deferred_removal=true
``` ```
@ -702,7 +702,7 @@ Error deleting container: Error response from daemon: Cannot destroy container
To avoid this failure, enable both deferred device deletion and deferred To avoid this failure, enable both deferred device deletion and deferred
device removal on the daemon. device removal on the daemon.
```bash ```console
$ sudo dockerd \ $ sudo dockerd \
--storage-opt dm.use_deferred_deletion=true \ --storage-opt dm.use_deferred_deletion=true \
--storage-opt dm.use_deferred_removal=true --storage-opt dm.use_deferred_removal=true
@ -742,7 +742,7 @@ the issue.
###### Example ###### Example
```bash ```console
$ sudo dockerd --storage-opt dm.min_free_space=10% $ sudo dockerd --storage-opt dm.min_free_space=10%
``` ```
@ -758,7 +758,7 @@ ENOSPC and will shutdown filesystem.
###### Example ###### Example
```bash ```console
$ sudo dockerd --storage-opt dm.xfs_nospace_max_retries=0 $ sudo dockerd --storage-opt dm.xfs_nospace_max_retries=0
``` ```
@ -784,7 +784,7 @@ their corresponding levels when output by `dockerd`.
###### Example ###### Example
```bash ```console
$ sudo dockerd \ $ sudo dockerd \
--log-level debug \ --log-level debug \
--storage-opt dm.libdm_log_level=7 --storage-opt dm.libdm_log_level=7
@ -800,7 +800,7 @@ By default docker will pick up the zfs filesystem where docker graph
###### Example ###### Example
```bash ```console
$ sudo dockerd -s zfs --storage-opt zfs.fsname=zroot/docker $ sudo dockerd -s zfs --storage-opt zfs.fsname=zroot/docker
``` ```
@ -815,7 +815,7 @@ a container with **--storage-opt size** option, docker should ensure the
###### Example ###### Example
```bash ```console
$ sudo dockerd -s btrfs --storage-opt btrfs.min_space=10G $ sudo dockerd -s btrfs --storage-opt btrfs.min_space=10G
``` ```
@ -838,7 +838,7 @@ conditions the user can pass any size less then the backing fs size.
###### Example ###### Example
```bash ```console
$ sudo dockerd -s overlay2 --storage-opt overlay2.size=1G $ sudo dockerd -s overlay2 --storage-opt overlay2.size=1G
``` ```
@ -960,7 +960,7 @@ By default, the Docker daemon automatically starts `containerd`. If you want to
control `containerd` startup, manually start `containerd` and pass the path to control `containerd` startup, manually start `containerd` and pass the path to
the `containerd` socket using the `--containerd` flag. For example: the `containerd` socket using the `--containerd` flag. For example:
```bash ```console
$ sudo dockerd --containerd /var/run/dev/docker-containerd.sock $ sudo dockerd --containerd /var/run/dev/docker-containerd.sock
``` ```
@ -988,7 +988,7 @@ The following is an example adding 2 runtimes via the configuration:
This is the same example via the command line: This is the same example via the command line:
```bash ```console
$ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-runc-replacement $ sudo dockerd --add-runtime runc=runc --add-runtime custom=/usr/local/bin/my-runc-replacement
``` ```
@ -1010,7 +1010,7 @@ is used on cgroup v2 hosts with systemd available.
This example sets the `cgroupdriver` to `systemd`: This example sets the `cgroupdriver` to `systemd`:
```bash ```console
$ sudo dockerd --exec-opt native.cgroupdriver=systemd $ sudo dockerd --exec-opt native.cgroupdriver=systemd
``` ```
@ -1031,13 +1031,13 @@ value is specified on daemon start, on Windows client, the default is
To set the DNS server for all Docker containers, use: To set the DNS server for all Docker containers, use:
```bash ```console
$ sudo dockerd --dns 8.8.8.8 $ sudo dockerd --dns 8.8.8.8
``` ```
To set the DNS search domain for all Docker containers, use: To set the DNS search domain for all Docker containers, use:
```bash ```console
$ sudo dockerd --dns-search example.com $ sudo dockerd --dns-search example.com
``` ```
@ -1163,7 +1163,7 @@ TLS. To configure the client TLS settings used by the daemon can be configured
using the `--cluster-store-opt` flag, specifying the paths to PEM encoded using the `--cluster-store-opt` flag, specifying the paths to PEM encoded
files. For example: files. For example:
```bash ```console
$ sudo dockerd \ $ sudo dockerd \
--cluster-advertise 192.168.1.2:2376 \ --cluster-advertise 192.168.1.2:2376 \
--cluster-store etcd://192.168.1.2:2379 \ --cluster-store etcd://192.168.1.2:2379 \
@ -1190,7 +1190,7 @@ organization can purchase or build themselves. You can install one or more
authorization plugins when you start the Docker `daemon` using the authorization plugins when you start the Docker `daemon` using the
`--authorization-plugin=PLUGIN_ID` option. `--authorization-plugin=PLUGIN_ID` option.
```bash ```console
$ sudo dockerd --authorization-plugin=plugin1 --authorization-plugin=plugin2,... $ sudo dockerd --authorization-plugin=plugin1 --authorization-plugin=plugin2,...
``` ```

View File

@ -208,13 +208,13 @@ You'll need two shells for this example.
**Shell 1: Listening for events:** **Shell 1: Listening for events:**
```bash ```console
$ docker events $ docker events
``` ```
**Shell 2: Start and Stop containers:** **Shell 2: Start and Stop containers:**
```bash ```console
$ docker create --name test alpine:latest top $ docker create --name test alpine:latest top
$ docker start test $ docker start test
$ docker stop test $ docker stop test
@ -239,7 +239,7 @@ To exit the `docker events` command, use `CTRL+C`.
You can filter the output by an absolute timestamp or relative time on the host You can filter the output by an absolute timestamp or relative time on the host
machine, using the following different time syntaxes: machine, using the following different time syntaxes:
```bash ```console
$ docker events --since 1483283804 $ docker events --since 1483283804
2017-01-05T00:35:41.241772953+08:00 volume create testVol (driver=local) 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:35:58.859401177+08:00 container create d9cd...4d70 (image=alpine:latest, name=test)
@ -292,7 +292,7 @@ $ docker events --since '2017-01-05T00:35:30' --until '2017-01-05T00:36:05'
The following commands show several different ways to filter the `docker event` The following commands show several different ways to filter the `docker event`
output. output.
```bash ```console
$ docker events --filter 'event=stop' $ 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:40:22.880175420+08:00 container stop 0fdb...ff37 (image=alpine:latest, name=test)
@ -388,7 +388,7 @@ $ docker events --filter 'scope=swarm'
### Format the output ### Format the output
```bash ```console
$ docker events --filter 'type=container' --format 'Type={{.Type}} Status={{.Status}} ID={{.ID}}' $ docker events --filter 'type=container' --format 'Type={{.Type}} Status={{.Status}} ID={{.ID}}'
Type=container Status=create ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26 Type=container Status=create ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299c126a87812311951e26
@ -401,7 +401,7 @@ Type=container Status=destroy ID=2ee349dac409e97974ce8d01b70d250b85e0ba8189299
#### Format as JSON #### Format as JSON
```bash ```console
$ docker events --format '{{json .}}' $ docker events --format '{{json .}}'
{"status":"create","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4.. {"status":"create","id":"196016a57679bf42424484918746a9474cd905dd993c4d0f4..

View File

@ -46,7 +46,7 @@ not work, but `docker exec -ti my_container sh -c "echo a && echo b"` will.
First, start a container. First, start a container.
```bash ```console
$ docker run --name ubuntu_bash --rm -i -t ubuntu bash $ docker run --name ubuntu_bash --rm -i -t ubuntu bash
``` ```
@ -54,7 +54,7 @@ This will create a container named `ubuntu_bash` and start a Bash session.
Next, execute a command on the container. Next, execute a command on the container.
```bash ```console
$ docker exec -d ubuntu_bash touch /tmp/execWorks $ docker exec -d ubuntu_bash touch /tmp/execWorks
``` ```
@ -63,7 +63,7 @@ This will create a new file `/tmp/execWorks` inside the running container
Next, execute an interactive `bash` shell on the container. Next, execute an interactive `bash` shell on the container.
```bash ```console
$ docker exec -it ubuntu_bash bash $ docker exec -it ubuntu_bash bash
``` ```
@ -71,7 +71,7 @@ This will create a new Bash session in the container `ubuntu_bash`.
Next, set an environment variable in the current bash session. Next, set an environment variable in the current bash session.
```bash ```console
$ docker exec -it -e VAR=1 ubuntu_bash bash $ docker exec -it -e VAR=1 ubuntu_bash bash
``` ```
@ -81,14 +81,14 @@ on the current Bash session.
By default `docker exec` command runs in the same working directory set when container was created. By default `docker exec` command runs in the same working directory set when container was created.
```bash ```console
$ docker exec -it ubuntu_bash pwd $ docker exec -it ubuntu_bash pwd
/ /
``` ```
You can select working directory for the command to execute into You can select working directory for the command to execute into
```bash ```console
$ docker exec -it -w /root ubuntu_bash pwd $ docker exec -it -w /root ubuntu_bash pwd
/root /root
``` ```
@ -98,7 +98,7 @@ $ docker exec -it -w /root ubuntu_bash pwd
If the container is paused, then the `docker exec` command will fail with an error: If the container is paused, then the `docker exec` command will fail with an error:
```bash ```console
$ docker pause test $ docker pause test
test test

View File

@ -30,10 +30,10 @@ in the user guide for examples on exporting data in a volume.
Each of these commands has the same result. Each of these commands has the same result.
```bash ```console
$ docker export red_panda > latest.tar $ docker export red_panda > latest.tar
``` ```
```bash ```console
$ docker export --output="latest.tar" red_panda $ docker export --output="latest.tar" red_panda
``` ```

View File

@ -24,7 +24,7 @@ Options:
To see how the `docker:latest` image was built: To see how the `docker:latest` image was built:
```bash ```console
$ docker history docker $ docker history docker
IMAGE CREATED CREATED BY SIZE COMMENT IMAGE CREATED CREATED BY SIZE COMMENT
@ -38,7 +38,7 @@ be51b77efb42 8 days ago /bin/sh -c apt-get update && apt-get ins
To see how the `docker:apache` image was added to a container's base image: To see how the `docker:apache` image was added to a container's base image:
```bash ```console
$ docker history docker:scm $ docker history docker:scm
IMAGE CREATED CREATED BY SIZE COMMENT IMAGE CREATED CREATED BY SIZE COMMENT
2ac9d1098bf1 3 months ago /bin/bash 241.4 MB Added Apache to Fedora base image 2ac9d1098bf1 3 months ago /bin/bash 241.4 MB Added Apache to Fedora base image
@ -71,7 +71,7 @@ The following example uses a template without headers and outputs the
`ID` and `CreatedSince` entries separated by a colon (`:`) for the `busybox` `ID` and `CreatedSince` entries separated by a colon (`:`) for the `busybox`
image: image:
```bash ```console
$ docker history --format "{{.ID}}: {{.CreatedSince}}" busybox $ docker history --format "{{.ID}}: {{.CreatedSince}}" busybox
f6e427c148a7: 4 weeks ago f6e427c148a7: 4 weeks ago

View File

@ -26,7 +26,7 @@ Remove all dangling images. If `-a` is specified, will also remove all images no
Example output: Example output:
```bash ```console
$ docker image prune -a $ docker image prune -a
WARNING! This will remove all images without at least one container associated to them. WARNING! This will remove all images without at least one container associated to them.
@ -101,7 +101,7 @@ images without the specified labels.
The following removes images created before `2017-01-04T00:00:00`: The following removes images created before `2017-01-04T00:00:00`:
```bash ```console
$ docker images --format 'table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Size}}' $ docker images --format 'table {{.Repository}}\t{{.Tag}}\t{{.ID}}\t{{.CreatedAt}}\t{{.Size}}'
REPOSITORY TAG IMAGE ID CREATED AT SIZE REPOSITORY TAG IMAGE ID CREATED AT SIZE
foo latest 2f287ac753da 2017-01-04 13:42:23 -0800 PST 3.98 MB foo latest 2f287ac753da 2017-01-04 13:42:23 -0800 PST 3.98 MB
@ -128,7 +128,7 @@ foo latest 2f287ac753da 2017-01-04 13:42:23
The following removes images created more than 10 days (`240h`) ago: The following removes images created more than 10 days (`240h`) ago:
```bash ```console
$ docker images $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -168,25 +168,25 @@ busybox latest e02e811dd08f 2 months ago
The following example removes images with the label `deprecated`: The following example removes images with the label `deprecated`:
```bash ```console
$ docker image prune --filter="label=deprecated" $ docker image prune --filter="label=deprecated"
``` ```
The following example removes images with the label `maintainer` set to `john`: The following example removes images with the label `maintainer` set to `john`:
```bash ```console
$ docker image prune --filter="label=maintainer=john" $ docker image prune --filter="label=maintainer=john"
``` ```
This example removes images which have no `maintainer` label: This example removes images which have no `maintainer` label:
```bash ```console
$ docker image prune --filter="label!=maintainer" $ docker image prune --filter="label!=maintainer"
``` ```
This example removes images which have a maintainer label not set to `john`: This example removes images which have a maintainer label not set to `john`:
```bash ```console
$ docker image prune --filter="label!=maintainer=john" $ docker image prune --filter="label!=maintainer=john"
``` ```

View File

@ -48,7 +48,7 @@ uses up the `SIZE` listed only once.
### List the most recently created images ### List the most recently created images
```bash ```console
$ docker images $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -72,7 +72,7 @@ given repository.
For example, to list all images in the "java" repository, run this command : For example, to list all images in the "java" repository, run this command :
```bash ```console
$ docker images java $ docker images java
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -88,7 +88,7 @@ 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 and tag are listed. To find all local images in the "java"
repository with tag "8" you can use: repository with tag "8" you can use:
```bash ```console
$ docker images java:8 $ docker images java:8
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -97,7 +97,7 @@ java 8 308e519aac60 6 days ago
If nothing matches `REPOSITORY[:TAG]`, the list is empty. If nothing matches `REPOSITORY[:TAG]`, the list is empty.
```bash ```console
$ docker images java:0 $ docker images java:0
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -105,7 +105,7 @@ REPOSITORY TAG IMAGE ID CREATED
### List the full length image IDs ### List the full length image IDs
```bash ```console
$ docker images --no-trunc $ docker images --no-trunc
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -127,7 +127,7 @@ 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 unchanged, the digest value is predictable. To list image digest values, use
the `--digests` flag: the `--digests` flag:
```bash ```console
$ docker images --digests $ docker images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf 4986bf8c1536 9 weeks ago 2.43 MB
@ -153,7 +153,7 @@ The currently supported filters are:
#### Show untagged images (dangling) #### Show untagged images (dangling)
```bash ```console
$ docker images --filter "dangling=true" $ docker images --filter "dangling=true"
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -173,7 +173,7 @@ using it. By having this flag it allows for batch cleanup.
You can use this in conjunction with `docker rmi ...`: You can use this in conjunction with `docker rmi ...`:
```bash ```console
$ docker rmi $(docker images -f "dangling=true" -q) $ docker rmi $(docker images -f "dangling=true" -q)
8abc22fbb042 8abc22fbb042
@ -194,7 +194,7 @@ value.
The following filter matches images with the `com.example.version` label regardless of its value. The following filter matches images with the `com.example.version` label regardless of its value.
```bash ```console
$ docker images --filter "label=com.example.version" $ docker images --filter "label=com.example.version"
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -204,7 +204,7 @@ match-me-2 latest dea752e4e117 About a minute ago
The following filter matches images with the `com.example.version` label with the `1.0` value. The following filter matches images with the `com.example.version` label with the `1.0` value.
```bash ```console
$ docker images --filter "label=com.example.version=1.0" $ docker images --filter "label=com.example.version=1.0"
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -213,7 +213,7 @@ match-me latest 511136ea3c5a About a minute ago
In this example, with the `0.1` value, it returns an empty set because no matches were found. In this example, with the `0.1` value, it returns an empty set because no matches were found.
```bash ```console
$ docker images --filter "label=com.example.version=0.1" $ docker images --filter "label=com.example.version=0.1"
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
``` ```
@ -223,7 +223,7 @@ REPOSITORY TAG IMAGE ID CREATED
The `before` filter shows only images created before the image with The `before` filter shows only images created before the image with
given id or reference. For example, having these images: given id or reference. For example, having these images:
```bash ```console
$ docker images $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -234,7 +234,7 @@ image3 latest 511136ea3c5a 25 minutes ago
Filtering with `before` would give: Filtering with `before` would give:
```bash ```console
$ docker images --filter "before=image1" $ docker images --filter "before=image1"
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -244,7 +244,7 @@ image3 latest 511136ea3c5a 25 minutes ago
Filtering with `since` would give: Filtering with `since` would give:
```bash ```console
$ docker images --filter "since=image3" $ docker images --filter "since=image3"
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
image1 latest eeae25ada2aa 4 minutes ago 188.3 MB image1 latest eeae25ada2aa 4 minutes ago 188.3 MB
@ -256,7 +256,7 @@ image2 latest dea752e4e117 9 minutes ago
The `reference` filter shows only images whose reference matches The `reference` filter shows only images whose reference matches
the specified pattern. the specified pattern.
```bash ```console
$ docker images $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -268,7 +268,7 @@ busybox glibc 21c16b6787c6 5 weeks ago
Filtering with `reference` would give: Filtering with `reference` would give:
```bash ```console
$ docker images --filter=reference='busy*:*libc' $ docker images --filter=reference='busy*:*libc'
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -278,7 +278,7 @@ busybox glibc 21c16b6787c6 5 weeks ago
Filtering with multiple `reference` would give, either match A or B: Filtering with multiple `reference` would give, either match A or B:
```bash ```console
$ docker images --filter=reference='busy*:uclibc' --filter=reference='busy*:glibc' $ docker images --filter=reference='busy*:uclibc' --filter=reference='busy*:glibc'
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -310,7 +310,7 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`ID` and `Repository` entries separated by a colon (`:`) for all images: `ID` and `Repository` entries separated by a colon (`:`) for all images:
```bash ```console
$ docker images --format "{{.ID}}: {{.Repository}}" $ docker images --format "{{.ID}}: {{.Repository}}"
77af4d6b9913: <none> 77af4d6b9913: <none>
@ -327,7 +327,7 @@ b6fa739cedf5: committ
To list all images with their repository and tag in a table format you To list all images with their repository and tag in a table format you
can use: can use:
```bash ```console
$ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}" $ docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}"
IMAGE ID REPOSITORY TAG IMAGE ID REPOSITORY TAG

View File

@ -39,39 +39,39 @@ Supported `Dockerfile` instructions:
This will create a new untagged image. This will create a new untagged image.
```bash ```console
$ docker import http://example.com/exampleimage.tgz $ docker import https://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`.
```bash ```console
$ cat exampleimage.tgz | docker import - exampleimagelocal:new $ cat exampleimage.tgz | docker import - exampleimagelocal:new
``` ```
- Import with a commit message. Import with a commit message.
```bash ```console
$ cat exampleimage.tgz | docker import --message "New image imported from tarball" - exampleimagelocal:new $ 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 ```console
$ docker import /path/to/exampleimage.tgz $ docker import /path/to/exampleimage.tgz
``` ```
### Import from a local directory ### Import from a local directory
```bash ```console
$ sudo tar -c . | docker import - exampleimagedir $ sudo tar -c . | docker import - exampleimagedir
``` ```
### Import from a local directory with new configurations ### Import from a local directory with new configurations
```bash ```console
$ sudo tar -c . | docker import --change "ENV DEBUG=true" - exampleimagedir $ sudo tar -c . | docker import --change "ENV DEBUG=true" - exampleimagedir
``` ```
@ -87,6 +87,6 @@ does not match the default operating system, it may be necessary to add
`--platform`. This would be necessary when importing a Linux image into a Windows `--platform`. This would be necessary when importing a Linux image into a Windows
daemon. daemon.
```bash ```console
$ docker import --platform=linux .\linuximage.tar $ docker import --platform=linux .\linuximage.tar
``` ```

View File

@ -44,8 +44,9 @@ The example below shows the output for a daemon running on Red Hat Enterprise Li
using the `devicemapper` storage driver. As can be seen in the output, additional using the `devicemapper` storage driver. As can be seen in the output, additional
information about the `devicemapper` storage driver is shown: information about the `devicemapper` storage driver is shown:
```bash ```console
$ docker info $ docker info
Client: Client:
Context: default Context: default
Debug Mode: false Debug Mode: false
@ -104,8 +105,9 @@ Server:
Here is a sample output for a daemon running on Ubuntu, using the overlay2 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: storage driver and a node that is part of a 2-node swarm:
```bash ```console
$ docker -D info $ docker --debug info
Client: Client:
Context: default Context: default
Debug Mode: true Debug Mode: true
@ -194,7 +196,7 @@ The global `-D` option causes all `docker` commands to output debug information.
You can also specify the output format: You can also specify the output format:
```bash ```console
$ docker info --format '{{json .}}' $ docker info --format '{{json .}}'
{"ID":"I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S","Containers":14, ...} {"ID":"I54V:OLXT:HVMM:TPKO:JPHQ:CQCD:JNLC:O3BZ:4ZVJ:43XJ:PFHZ:6N2S","Containers":14, ...}

View File

@ -45,7 +45,7 @@ option.
The following example inspects a _volume_ named "myvolume" The following example inspects a _volume_ named "myvolume"
```bash ```console
$ docker inspect --type=volume myvolume $ docker inspect --type=volume myvolume
``` ```
@ -56,25 +56,25 @@ $ docker inspect --type=volume myvolume
For the most part, you can pick out any field from the JSON in a fairly For the most part, you can pick out any field from the JSON in a fairly
straightforward manner. straightforward manner.
```bash ```console
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' $INSTANCE_ID
``` ```
### Get an instance's MAC address ### Get an instance's MAC address
```bash ```console
$ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID $ docker inspect --format='{{range .NetworkSettings.Networks}}{{.MacAddress}}{{end}}' $INSTANCE_ID
``` ```
### Get an instance's log path ### Get an instance's log path
```bash ```console
$ docker inspect --format='{{.LogPath}}' $INSTANCE_ID $ docker inspect --format='{{.LogPath}}' $INSTANCE_ID
``` ```
### Get an instance's image name ### Get an instance's image name
```bash ```console
$ docker inspect --format='{{.Config.Image}}' $INSTANCE_ID $ docker inspect --format='{{.Config.Image}}' $INSTANCE_ID
``` ```
@ -83,7 +83,7 @@ $ docker inspect --format='{{.Config.Image}}' $INSTANCE_ID
You 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: output:
```bash ```console
$ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID $ docker inspect --format='{{range $p, $conf := .NetworkSettings.Ports}} {{$p}} -> {{(index $conf 0).HostPort}} {{end}}' $INSTANCE_ID
``` ```
@ -97,7 +97,7 @@ 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 then `index` 0 contains the first object inside of that. Then we ask for
the `HostPort` field to get the public address. the `HostPort` field to get the public address.
```bash ```console
$ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID $ docker inspect --format='{{(index (index .NetworkSettings.Ports "8787/tcp") 0).HostPort}}' $INSTANCE_ID
``` ```
@ -108,6 +108,6 @@ 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 Docker adds a template function, `json`, which can be applied to get
results in JSON format. results in JSON format.
```bash ```console
$ docker inspect --format='{{json .Config}}' $INSTANCE_ID $ docker inspect --format='{{json .Config}}' $INSTANCE_ID
``` ```

View File

@ -20,8 +20,18 @@ Options:
The `docker kill` subcommand kills one or more containers. The main process The `docker kill` subcommand kills one or more containers. The main process
inside the container is sent `SIGKILL` signal (default), or the signal that is inside the container is sent `SIGKILL` signal (default), or the signal that is
specified with the `--signal` option. You can kill a container using the specified with the `--signal` option. You can reference a container by its
container's ID, ID-prefix, or name. ID, ID-prefix, or name.
The `--signal` (or `-s` shorthand) flag sets the system call signal that is sent
to the container. This signal can be a signal name in the format `SIG<NAME>`, for
instance `SIGINT`, or an unsigned number that matches a position in the kernel's
syscall table, for instance `2`.
While the default (`SIGKILL`) signal will terminate the container, the signal
set through `--signal` may be non-terminal, depending on the container's main
process. For example, the `SIGHUP` signal in most cases will be non-terminal,
and the container will continue running after receiving the signal.
> **Note** > **Note**
> >
@ -32,21 +42,21 @@ container's ID, ID-prefix, or name.
## Examples ## Examples
### Send a KILL signal to a container ### Send a KILL signal to a container
The following example sends the default `KILL` signal to the container named The following example sends the default `SIGKILL` signal to the container named
`my_container`: `my_container`:
```bash ```console
$ docker kill my_container $ docker kill my_container
``` ```
### Send a custom signal to a container ### Send a custom signal to a container
The following example sends a `SIGHUP` signal to the container named The following example sends a `SIGHUP` signal to the container named
`my_container`: `my_container`:
```bash ```console
$ docker kill --signal=SIGHUP my_container $ docker kill --signal=SIGHUP my_container
``` ```
@ -54,7 +64,7 @@ $ docker kill --signal=SIGHUP my_container
You can specify a custom signal either by _name_, or _number_. The `SIG` prefix You can specify a custom signal either by _name_, or _number_. The `SIG` prefix
is optional, so the following examples are equivalent: is optional, so the following examples are equivalent:
```bash ```console
$ docker kill --signal=SIGHUP my_container $ docker kill --signal=SIGHUP my_container
$ docker kill --signal=HUP my_container $ docker kill --signal=HUP my_container
$ docker kill --signal=1 my_container $ docker kill --signal=1 my_container

View File

@ -18,6 +18,7 @@ Options:
The tarball may be compressed with gzip, bzip, or xz The tarball may be compressed with gzip, bzip, or xz
-q, --quiet Suppress the load output but still outputs the imported images -q, --quiet Suppress the load output but still outputs the imported images
``` ```
## Description ## Description
Load an image or repository from a tar archive (even if compressed with gzip, Load an image or repository from a tar archive (even if compressed with gzip,
@ -25,7 +26,7 @@ bzip2, or xz) from a file or STDIN. It restores both images and tags.
## Examples ## Examples
```bash ```console
$ docker image ls $ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE

View File

@ -30,7 +30,7 @@ Login to a registry.
If you want to login to a self-hosted registry you can specify this by If you want to login to a self-hosted registry you can specify this by
adding the server name. adding the server name.
```bash ```console
$ docker login localhost:8080 $ docker login localhost:8080
``` ```
@ -44,7 +44,7 @@ or log-files.
The following example reads a password from a file, and passes it to the The following example reads a password from a file, and passes it to the
`docker login` command using `STDIN`: `docker login` command using `STDIN`:
```bash ```console
$ cat ~/my_password.txt | docker login --username foo --password-stdin $ cat ~/my_password.txt | docker login --username foo --password-stdin
``` ```

View File

@ -18,7 +18,7 @@ Options:
## Examples ## Examples
```bash ```console
$ docker logout localhost:8080 $ docker logout localhost:8080
``` ```

View File

@ -67,7 +67,7 @@ fraction of a second no more than nine digits long. You can combine the
In order to retrieve logs before a specific point in time, run: In order to retrieve logs before a specific point in time, run:
```bash ```console
$ docker run --name test -d busybox sh -c "while true; do $(echo date); sleep 1; done" $ docker run --name test -d busybox sh -c "while true; do $(echo date); sleep 1; done"
$ date $ date
Tue 14 Nov 2017 16:40:00 CET Tue 14 Nov 2017 16:40:00 CET

View File

@ -40,8 +40,8 @@ to two images -- one for windows on amd64, and one for darwin on amd64.
### manifest inspect ### manifest inspect
```bash ```console
manifest inspect --help $ docker manifest inspect --help
Usage: docker manifest inspect [OPTIONS] [MANIFEST_LIST] MANIFEST Usage: docker manifest inspect [OPTIONS] [MANIFEST_LIST] MANIFEST
@ -55,7 +55,7 @@ Options:
### manifest create ### manifest create
```bash ```console
Usage: docker manifest create MANIFEST_LIST MANIFEST [MANIFEST...] Usage: docker manifest create MANIFEST_LIST MANIFEST [MANIFEST...]
Create a local manifest list for annotating and pushing to a registry Create a local manifest list for annotating and pushing to a registry
@ -68,7 +68,7 @@ Options:
### manifest annotate ### manifest annotate
```bash ```console
Usage: docker manifest annotate [OPTIONS] MANIFEST_LIST MANIFEST Usage: docker manifest annotate [OPTIONS] MANIFEST_LIST MANIFEST
Add additional information to a local image manifest Add additional information to a local image manifest
@ -85,7 +85,7 @@ Options:
### manifest push ### manifest push
```bash ```console
Usage: docker manifest push [OPTIONS] MANIFEST_LIST Usage: docker manifest push [OPTIONS] MANIFEST_LIST
Push a manifest list to a repository Push a manifest list to a repository
@ -113,7 +113,7 @@ default requirements.
### Inspect an image's manifest object ### Inspect an image's manifest object
```bash ```console
$ docker manifest inspect hello-world $ docker manifest inspect hello-world
{ {
"schemaVersion": 2, "schemaVersion": 2,
@ -143,7 +143,7 @@ without a tag, or by digest (e.g. `hello-world@sha256:f3b3b28a45160805bb16542c95
Here is an example of inspecting an image's manifest with the `--verbose` flag: Here is an example of inspecting an image's manifest with the `--verbose` flag:
```bash ```console
$ docker manifest inspect --verbose hello-world $ docker manifest inspect --verbose hello-world
{ {
"Ref": "docker.io/library/hello-world:latest", "Ref": "docker.io/library/hello-world:latest",
@ -187,7 +187,7 @@ After you have created your local copy of the manifest list, you may optionally
Finally, you need to `push` your manifest list to the desired registry. Below are Finally, you need to `push` your manifest list to the desired registry. Below are
descriptions of these three commands, and an example putting them all together. descriptions of these three commands, and an example putting them all together.
```bash ```console
$ docker manifest create 45.55.81.106:5000/coolapp:v1 \ $ docker manifest create 45.55.81.106:5000/coolapp:v1 \
45.55.81.106:5000/coolapp-ppc64le-linux:v1 \ 45.55.81.106:5000/coolapp-ppc64le-linux:v1 \
45.55.81.106:5000/coolapp-arm-linux:v1 \ 45.55.81.106:5000/coolapp-arm-linux:v1 \
@ -197,11 +197,11 @@ $ docker manifest create 45.55.81.106:5000/coolapp:v1 \
Created manifest list 45.55.81.106:5000/coolapp:v1 Created manifest list 45.55.81.106:5000/coolapp:v1
``` ```
```bash ```console
$ docker manifest annotate 45.55.81.106:5000/coolapp:v1 45.55.81.106:5000/coolapp-arm-linux --arch arm $ docker manifest annotate 45.55.81.106:5000/coolapp:v1 45.55.81.106:5000/coolapp-arm-linux --arch arm
``` ```
```bash ```console
$ docker manifest push 45.55.81.106:5000/coolapp:v1 $ docker manifest push 45.55.81.106:5000/coolapp:v1
Pushed manifest 45.55.81.106:5000/coolapp@sha256:9701edc932223a66e49dd6c894a11db8c2cf4eccd1414f1ec105a623bf16b426 with digest: sha256:f67dcc5fc786f04f0743abfe0ee5dae9bd8caf8efa6c8144f7f2a43889dc513b Pushed manifest 45.55.81.106:5000/coolapp@sha256:9701edc932223a66e49dd6c894a11db8c2cf4eccd1414f1ec105a623bf16b426 with digest: sha256:f67dcc5fc786f04f0743abfe0ee5dae9bd8caf8efa6c8144f7f2a43889dc513b
Pushed manifest 45.55.81.106:5000/coolapp@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f with digest: sha256:b64ca0b60356a30971f098c92200b1271257f100a55b351e6bbe985638352f3a Pushed manifest 45.55.81.106:5000/coolapp@sha256:f3b3b28a45160805bb16542c9531888519430e9e6d6ffc09d72261b0d26ff74f with digest: sha256:b64ca0b60356a30971f098c92200b1271257f100a55b351e6bbe985638352f3a
@ -213,7 +213,7 @@ sha256:050b213d49d7673ba35014f21454c573dcbec75254a08f4a7c34f66a47c06aba
### Inspect a manifest list ### Inspect a manifest list
```bash ```console
$ docker manifest inspect coolapp:v1 $ docker manifest inspect coolapp:v1
{ {
"schemaVersion": 2, "schemaVersion": 2,
@ -264,7 +264,7 @@ $ docker manifest inspect coolapp:v1
Here is an example of creating and pushing a manifest list using a known Here is an example of creating and pushing a manifest list using a known
insecure registry. insecure registry.
```bash ```console
$ docker manifest create --insecure myprivateregistry.mycompany.com/repo/image:1.0 \ $ docker manifest create --insecure myprivateregistry.mycompany.com/repo/image:1.0 \
myprivateregistry.mycompany.com/repo/image-linux-ppc64le:1.0 \ myprivateregistry.mycompany.com/repo/image-linux-ppc64le:1.0 \
myprivateregistry.mycompany.com/repo/image-linux-s390x:1.0 \ myprivateregistry.mycompany.com/repo/image-linux-s390x:1.0 \

View File

@ -30,7 +30,7 @@ the same network.
### Connect a running container to a network ### Connect a running container to a network
```bash ```console
$ docker network connect multi-host-network container1 $ docker network connect multi-host-network container1
``` ```
@ -38,7 +38,7 @@ $ docker network connect multi-host-network container1
You can also use the `docker run --network=<network-name>` option to start a container and immediately connect it to a network. You can also use the `docker run --network=<network-name>` option to start a container and immediately connect it to a network.
```bash ```console
$ docker run -itd --network=multi-host-network busybox $ docker run -itd --network=multi-host-network busybox
``` ```
@ -46,7 +46,7 @@ $ docker run -itd --network=multi-host-network busybox
You can specify the IP address you want to be assigned to the container's interface. You can specify the IP address you want to be assigned to the container's interface.
```bash ```console
$ docker network connect --ip 10.10.36.122 multi-host-network container2 $ docker network connect --ip 10.10.36.122 multi-host-network container2
``` ```
@ -54,7 +54,7 @@ $ docker network connect --ip 10.10.36.122 multi-host-network container2
You can use `--link` option to link another container with a preferred alias You can use `--link` option to link another container with a preferred alias
```bash ```console
$ docker network connect --link container1:c1 multi-host-network container2 $ docker network connect --link container1:c1 multi-host-network container2
``` ```
@ -63,7 +63,7 @@ $ docker network connect --link container1:c1 multi-host-network container2
`--alias` option can be used to resolve the container by another name in the network `--alias` option can be used to resolve the container by another name in the network
being connected to. being connected to.
```bash ```console
$ docker network connect --alias db --alias mysql multi-host-network container2 $ docker network connect --alias db --alias mysql multi-host-network container2
``` ```
@ -79,11 +79,11 @@ to specify an `--ip-range` when creating the network, and choose the static IP
address(es) from outside that range. This ensures that the IP address is not address(es) from outside that range. This ensures that the IP address is not
given to another container while this container is not on the network. given to another container while this container is not on the network.
```bash ```console
$ docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 multi-host-network $ docker network create --subnet 172.20.0.0/16 --ip-range 172.20.240.0/20 multi-host-network
``` ```
```bash ```console
$ docker network connect --ip 172.20.128.2 multi-host-network container2 $ docker network connect --ip 172.20.128.2 multi-host-network container2
``` ```

View File

@ -45,7 +45,7 @@ on. When you launch a new container with `docker run` it automatically connects
this bridge network. You cannot remove this default bridge network, but you can this bridge network. You cannot remove this default bridge network, but you can
create new ones using the `network create` command. create new ones using the `network create` command.
```bash ```console
$ docker network create -d bridge my-bridge-network $ docker network create -d bridge my-bridge-network
``` ```
@ -75,7 +75,7 @@ discovery and server management tools that can assist your implementation.
Once you have prepared the `overlay` network prerequisites you simply choose a Once you have prepared the `overlay` network prerequisites you simply choose a
Docker host in the cluster and issue the following to create the network: Docker host in the cluster and issue the following to create the network:
```bash ```console
$ docker network create -d overlay my-multihost-network $ docker network create -d overlay my-multihost-network
``` ```
@ -102,7 +102,7 @@ for more information about different endpoint modes.
When you start a container, use the `--network` flag to connect it to a network. 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: This example adds the `busybox` container to the `mynet` network:
```bash ```console
$ docker run -itd --network=mynet busybox $ docker run -itd --network=mynet busybox
``` ```
@ -126,14 +126,14 @@ network. It is purely for ip-addressing purposes. You can override this default
and specify subnetwork values directly using the `--subnet` option. On a and specify subnetwork values directly using the `--subnet` option. On a
`bridge` network you can only create a single subnet: `bridge` network you can only create a single subnet:
```bash ```console
$ docker network create --driver=bridge --subnet=192.168.0.0/16 br0 $ docker network create --driver=bridge --subnet=192.168.0.0/16 br0
``` ```
Additionally, you also specify the `--gateway` `--ip-range` and `--aux-address` Additionally, you also specify the `--gateway` `--ip-range` and `--aux-address`
options. options.
```bash ```console
$ docker network create \ $ docker network create \
--driver=bridge \ --driver=bridge \
--subnet=172.28.0.0/16 \ --subnet=172.28.0.0/16 \
@ -148,7 +148,7 @@ support it you can create multiple subnetworks. This example uses two `/25`
subnet mask to adhere to the current guidance of not having more than 256 IPs in subnet mask to adhere to the current guidance of not having more than 256 IPs in
a single overlay network. Each of the subnetworks has 126 usable addresses. a single overlay network. Each of the subnetworks has 126 usable addresses.
```bash ```console
$ docker network create -d overlay \ $ docker network create -d overlay \
--subnet=192.168.10.0/25 \ --subnet=192.168.10.0/25 \
--subnet=192.168.20.0/25 \ --subnet=192.168.20.0/25 \
@ -191,7 +191,7 @@ network driver, again with their approximate equivalents to `docker daemon`.
For example, let's use `-o` or `--opt` options to specify an IP address binding For example, let's use `-o` or `--opt` options to specify an IP address binding
when publishing ports: when publishing ports:
```bash ```console
$ docker network create \ $ docker network create \
-o "com.docker.network.bridge.host_binding_ipv4"="172.19.0.1" \ -o "com.docker.network.bridge.host_binding_ipv4"="172.19.0.1" \
simple-network simple-network
@ -212,7 +212,7 @@ one ingress network can be created at the time. The network can be removed only
if no services depend on it. Any option available when creating an overlay network if no services depend on it. Any option available when creating an overlay network
is also available when creating the ingress network, besides the `--attachable` option. is also available when creating the ingress network, besides the `--attachable` option.
```bash ```console
$ docker network create -d overlay \ $ docker network create -d overlay \
--subnet=10.11.0.0/16 \ --subnet=10.11.0.0/16 \
--ingress \ --ingress \

View File

@ -23,7 +23,7 @@ disconnect it from the network.
## Examples ## Examples
```bash ```console
$ docker network disconnect multi-host-network container1 $ docker network disconnect multi-host-network container1
``` ```

View File

@ -27,7 +27,7 @@ all results in a JSON object.
Connect two containers to the default `bridge` network: Connect two containers to the default `bridge` network:
```bash ```console
$ sudo docker run -itd --name=container1 busybox $ sudo docker run -itd --name=container1 busybox
f2870c98fd504370fb86e59f32cd0753b1ac9b69b7d80566ffc7192a82b3ed27 f2870c98fd504370fb86e59f32cd0753b1ac9b69b7d80566ffc7192a82b3ed27
@ -47,7 +47,7 @@ template for each result. Go's
[text/template](http://golang.org/pkg/text/template/) package describes all the [text/template](http://golang.org/pkg/text/template/) package describes all the
details of the format. details of the format.
```bash ```console
$ sudo docker network inspect bridge $ sudo docker network inspect bridge
``` ```
@ -104,13 +104,13 @@ The output is in JSON format, for example:
Create and inspect a user-defined network: Create and inspect a user-defined network:
```bash ```console
$ docker network create simple-network $ docker network create simple-network
69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a 69568e6336d8c96bbf57869030919f7c69524f71183b44d80948bd3927c87f6a
``` ```
```bash ```console
$ docker network inspect simple-network $ docker network inspect simple-network
``` ```
@ -146,7 +146,7 @@ For swarm mode overlay networks `network inspect` also shows the IP address and
of the peers. Peers are the nodes in the swarm cluster which have at least one task attached 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>`. to the network. Node name is of the format `<hostname>-<unique ID>`.
```bash ```console
$ docker network inspect ingress $ docker network inspect ingress
``` ```
@ -213,7 +213,7 @@ and the IPs of the nodes where the tasks are running.
Following is an example output for an overlay network `ov1` that has one service `s1` Following is an example output for an overlay network `ov1` that has one service `s1`
attached to. service `s1` in this case has three replicas. attached to. service `s1` in this case has three replicas.
```bash ```console
$ docker network inspect --verbose ov1 $ docker network inspect --verbose ov1
``` ```

View File

@ -31,8 +31,8 @@ networks that span across multiple hosts in a cluster.
### List all networks ### List all networks
```bash ```console
$ sudo docker network ls $ docker network ls
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
7fca4eb8c647 bridge bridge local 7fca4eb8c647 bridge bridge local
9f904ee27bf5 none null local 9f904ee27bf5 none null local
@ -42,7 +42,7 @@ cf03ee007fb4 host host local
Use the `--no-trunc` option to display the full network id: Use the `--no-trunc` option to display the full network id:
```bash ```console
$ docker network ls --no-trunc $ docker network ls --no-trunc
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
18a2866682b85619a026c81b98a5e375bd33e1b0936a26cc497c283d27bae9b3 none null local 18a2866682b85619a026c81b98a5e375bd33e1b0936a26cc497c283d27bae9b3 none null local
@ -74,7 +74,7 @@ The `driver` filter matches networks based on their driver.
The following example matches networks with the `bridge` driver: The following example matches networks with the `bridge` driver:
```bash ```console
$ docker network ls --filter driver=bridge $ docker network ls --filter driver=bridge
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
db9db329f835 test1 bridge local db9db329f835 test1 bridge local
@ -88,7 +88,7 @@ The `id` filter matches on all or part of a network's ID.
The following filter matches all networks with an ID containing the The following filter matches all networks with an ID containing the
`63d1ff1f77b0...` string. `63d1ff1f77b0...` string.
```bash ```console
$ docker network ls --filter id=63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161 $ docker network ls --filter id=63d1ff1f77b07ca51070a8c227e962238358bd310bde1529cf62e6c307ade161
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
63d1ff1f77b0 dev bridge local 63d1ff1f77b0 dev bridge local
@ -96,7 +96,7 @@ NETWORK ID NAME DRIVER SCOPE
You can also filter for a substring in an ID as this shows: You can also filter for a substring in an ID as this shows:
```bash ```console
$ docker network ls --filter id=95e74588f40d $ docker network ls --filter id=95e74588f40d
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
95e74588f40d foo bridge local 95e74588f40d foo bridge local
@ -113,7 +113,7 @@ value.
The following filter matches networks with the `usage` label regardless of its value. The following filter matches networks with the `usage` label regardless of its value.
```bash ```console
$ docker network ls -f "label=usage" $ docker network ls -f "label=usage"
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
db9db329f835 test1 bridge local db9db329f835 test1 bridge local
@ -122,7 +122,7 @@ f6e212da9dfd test2 bridge local
The following filter matches networks with the `usage` label with the `prod` value. The following filter matches networks with the `usage` label with the `prod` value.
```bash ```console
$ docker network ls -f "label=usage=prod" $ docker network ls -f "label=usage=prod"
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
f6e212da9dfd test2 bridge local f6e212da9dfd test2 bridge local
@ -134,7 +134,7 @@ The `name` filter matches on all or part of a network's name.
The following filter matches all networks with a name containing the `foobar` string. The following filter matches all networks with a name containing the `foobar` string.
```bash ```console
$ docker network ls --filter name=foobar $ docker network ls --filter name=foobar
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
06e7eef0a170 foobar bridge local 06e7eef0a170 foobar bridge local
@ -142,7 +142,7 @@ NETWORK ID NAME DRIVER SCOPE
You can also filter for a substring in a name as this shows: You can also filter for a substring in a name as this shows:
```bash ```console
$ docker network ls --filter name=foo $ docker network ls --filter name=foo
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
95e74588f40d foo bridge local 95e74588f40d foo bridge local
@ -155,7 +155,7 @@ The `scope` filter matches networks based on their scope.
The following example matches networks with the `swarm` scope: The following example matches networks with the `swarm` scope:
```bash ```console
$ docker network ls --filter scope=swarm $ docker network ls --filter scope=swarm
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
xbtm0v4f1lfh ingress overlay swarm xbtm0v4f1lfh ingress overlay swarm
@ -164,7 +164,7 @@ ic6r88twuu92 swarmnet overlay swarm
The following example matches networks with the `local` scope: The following example matches networks with the `local` scope:
```bash ```console
$ docker network ls --filter scope=local $ docker network ls --filter scope=local
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
e85227439ac7 bridge bridge local e85227439ac7 bridge bridge local
@ -180,7 +180,7 @@ The `type` filter supports two values; `builtin` displays predefined networks
The following filter matches all user defined networks: The following filter matches all user defined networks:
```bash ```console
$ docker network ls --filter type=custom $ docker network ls --filter type=custom
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE
95e74588f40d foo bridge local 95e74588f40d foo bridge local
@ -190,7 +190,7 @@ NETWORK ID NAME DRIVER SCOPE
By having this flag it allows for batch cleanup. For example, use this filter By having this flag it allows for batch cleanup. For example, use this filter
to delete all user defined networks: to delete all user defined networks:
```bash ```console
$ docker network rm `docker network ls --filter type=custom -q` $ docker network rm `docker network ls --filter type=custom -q`
``` ```
@ -223,7 +223,7 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`ID` and `Driver` entries separated by a colon (`:`) for all networks: `ID` and `Driver` entries separated by a colon (`:`) for all networks:
```bash ```console
$ docker network ls --format "{{.ID}}: {{.Driver}}" $ docker network ls --format "{{.ID}}: {{.Driver}}"
afaaab448eb2: bridge afaaab448eb2: bridge
d1584f8dc718: host d1584f8dc718: host

View File

@ -24,7 +24,7 @@ by any containers.
## Examples ## Examples
```bash ```console
$ docker network prune $ docker network prune
WARNING! This will remove all custom networks not used by at least one container. WARNING! This will remove all custom networks not used by at least one container.
@ -64,7 +64,7 @@ networks without the specified labels.
The following removes networks created more than 5 minutes ago. Note that The following removes networks created more than 5 minutes ago. Note that
system networks such as `bridge`, `host`, and `none` will never be pruned: system networks such as `bridge`, `host`, and `none` will never be pruned:
```bash ```console
$ docker network ls $ docker network ls
NETWORK ID NAME DRIVER SCOPE NETWORK ID NAME DRIVER SCOPE

View File

@ -29,8 +29,8 @@ you must first disconnect any containers connected to it.
To remove the network named 'my-network': To remove the network named 'my-network':
```bash ```console
$ docker network rm my-network $ docker network rm my-network
``` ```
### Remove multiple networks ### Remove multiple networks
@ -39,8 +39,8 @@ 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 multiple network names or ids. The following example deletes a network with id
`3695c422697f` and a network named `my-network`: `3695c422697f` and a network named `my-network`:
```bash ```console
$ docker network rm 3695c422697f my-network $ docker network rm 3695c422697f my-network
``` ```
When you specify multiple networks, the command attempts to delete each in turn. When you specify multiple networks, the command attempts to delete each in turn.

View File

@ -28,7 +28,7 @@ Demotes an existing manager so that it is no longer a manager.
## Examples ## Examples
```bash ```console
$ docker node demote <node name> $ docker node demote <node name>
``` ```

View File

@ -36,7 +36,7 @@ details of the format.
### Inspect a node ### Inspect a node
```bash ```console
$ docker node inspect swarm-manager $ docker node inspect swarm-manager
``` ```
@ -113,7 +113,7 @@ $ docker node inspect swarm-manager
### Specify an output format ### Specify an output format
```bash ```console
$ docker node inspect --format '{{ .ManagerStatus.Leader }}' self $ docker node inspect --format '{{ .ManagerStatus.Leader }}' self
false false
@ -121,7 +121,7 @@ false
Use `--format=pretty` or the `--pretty` shorthand to pretty-print the output: Use `--format=pretty` or the `--pretty` shorthand to pretty-print the output:
```bash ```console
$ docker node inspect --format=pretty self $ docker node inspect --format=pretty self
ID: e216jshn25ckzbvmwlnh5jr3g ID: e216jshn25ckzbvmwlnh5jr3g

View File

@ -36,7 +36,7 @@ for more information about available filter options.
## Examples ## Examples
```bash ```console
$ docker node ls $ docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
@ -44,6 +44,7 @@ ID HOSTNAME STATUS AVAILABILITY MANAGER STATU
38ciaotwjuritcdtn9npbnkuz swarm-worker1 Ready Active 38ciaotwjuritcdtn9npbnkuz swarm-worker1 Ready Active
e216jshn25ckzbvmwlnh5jr3g * swarm-manager1 Ready Active Leader e216jshn25ckzbvmwlnh5jr3g * swarm-manager1 Ready Active Leader
``` ```
> **Note** > **Note**
> >
> In the above example output, there is a hidden column of `.Self` that indicates > In the above example output, there is a hidden column of `.Self` that indicates
@ -69,7 +70,7 @@ The currently supported filters are:
The `id` filter matches all or part of a node's id. The `id` filter matches all or part of a node's id.
```bash ```console
$ docker node ls -f id=1 $ docker node ls -f id=1
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
@ -85,7 +86,7 @@ Swarm `node` labels, use [`node.label` instead](#nodelabel).
The following filter matches nodes with the `foo` label regardless of its value. The following filter matches nodes with the `foo` label regardless of its value.
```bash ```console
$ docker node ls -f "label=foo" $ docker node ls -f "label=foo"
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
@ -135,7 +136,7 @@ The `membership` filter matches nodes based on the presence of a `membership` an
The following filter matches nodes with the `membership` of `accepted`. The following filter matches nodes with the `membership` of `accepted`.
```bash ```console
$ docker node ls -f "membership=accepted" $ docker node ls -f "membership=accepted"
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
@ -149,7 +150,7 @@ The `name` filter matches on all or part of a node hostname.
The following filter matches the nodes with a name equal to `swarm-master` string. The following filter matches the nodes with a name equal to `swarm-master` string.
```bash ```console
$ docker node ls -f name=swarm-manager1 $ docker node ls -f name=swarm-manager1
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
@ -162,7 +163,7 @@ The `role` filter matches nodes based on the presence of a `role` and a value `w
The following filter matches nodes with the `manager` role. The following filter matches nodes with the `manager` role.
```bash ```console
$ docker node ls -f "role=manager" $ docker node ls -f "role=manager"
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
@ -195,8 +196,9 @@ The following example uses a template without headers and outputs the
`ID`, `Hostname`, and `TLS Status` entries separated by a colon (`:`) for all `ID`, `Hostname`, and `TLS Status` entries separated by a colon (`:`) for all
nodes: nodes:
```bash ```console
$ docker node ls --format "{{.ID}}: {{.Hostname}} {{.TLSStatus}}" $ docker node ls --format "{{.ID}}: {{.Hostname}} {{.TLSStatus}}"
e216jshn25ckzbvmwlnh5jr3g: swarm-manager1 Ready e216jshn25ckzbvmwlnh5jr3g: swarm-manager1 Ready
35o6tiywb700jesrt3dmllaza: swarm-worker1 Needs Rotation 35o6tiywb700jesrt3dmllaza: swarm-worker1 Needs Rotation
``` ```

View File

@ -28,7 +28,7 @@ Promotes a node to manager. This command can only be executed on a manager node.
## Examples ## Examples
```bash ```console
$ docker node promote <node name> $ docker node promote <node name>
``` ```

View File

@ -36,8 +36,9 @@ information about available filter options.
## Examples ## Examples
```bash ```console
$ docker node ps swarm-manager1 $ docker node ps swarm-manager1
NAME IMAGE NODE DESIRED STATE CURRENT STATE NAME IMAGE NODE DESIRED STATE CURRENT STATE
redis.1.7q92v0nr1hcgts2amcjyqg3pq redis:3.0.6 swarm-manager1 Running Running 5 hours 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.6.b465edgho06e318egmgjbqo4o redis:3.0.6 swarm-manager1 Running Running 29 seconds
@ -64,7 +65,7 @@ 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. The following filter matches all tasks with a name containing the `redis` string.
```bash ```console
$ docker node ps -f name=redis swarm-manager1 $ docker node ps -f name=redis swarm-manager1
NAME IMAGE NODE DESIRED STATE CURRENT STATE NAME IMAGE NODE DESIRED STATE CURRENT STATE
@ -79,7 +80,7 @@ redis.10.0tgctg8h8cech4w0k0gwrmr23 redis:3.0.6 swarm-manager1 Running
The `id` filter matches a task's id. The `id` filter matches a task's id.
```bash ```console
$ docker node ps -f id=bg8c07zzg87di2mufeq51a2qp swarm-manager1 $ docker node ps -f id=bg8c07zzg87di2mufeq51a2qp swarm-manager1
NAME IMAGE NODE DESIRED STATE CURRENT STATE NAME IMAGE NODE DESIRED STATE CURRENT STATE
@ -93,7 +94,7 @@ value.
The following filter matches tasks with the `usage` label regardless of its value. The following filter matches tasks with the `usage` label regardless of its value.
```bash ```console
$ docker node ps -f "label=usage" $ docker node ps -f "label=usage"
NAME IMAGE NODE DESIRED STATE CURRENT STATE NAME IMAGE NODE DESIRED STATE CURRENT STATE
@ -132,8 +133,9 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`Name` and `Image` entries separated by a colon (`:`) for all tasks: `Name` and `Image` entries separated by a colon (`:`) for all tasks:
```bash ```console
$ docker node ps --format "{{.Name}}: {{.Image}}" $ docker node ps --format "{{.Name}}: {{.Image}}"
top.1: busybox top.1: busybox
top.2: busybox top.2: busybox
top.3: busybox top.3: busybox

View File

@ -34,11 +34,12 @@ Removes the specified nodes from a swarm.
### Remove a stopped node from the swarm ### Remove a stopped node from the swarm
```bash ```console
$ docker node rm swarm-node-02 $ docker node rm swarm-node-02
Node swarm-node-02 removed from swarm Node swarm-node-02 removed from swarm
``` ```
### Attempt to remove a running node from a 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 Removes the specified nodes from the swarm, but only if the nodes are in the
@ -58,7 +59,7 @@ 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 This may cause transient errors or interruptions, depending on the type of task
being run on the node. being run on the node.
```bash ```console
$ docker node rm --force swarm-node-03 $ docker node rm --force swarm-node-03
Node swarm-node-03 removed from swarm Node swarm-node-03 removed from swarm

View File

@ -43,7 +43,7 @@ $ docker node update --label-add foo worker1
To add multiple labels to a node, pass the `--label-add` flag for each label: To add multiple labels to a node, pass the `--label-add` flag for each label:
```bash ```console
$ docker node update --label-add foo --label-add bar worker1 $ docker node update --label-add foo --label-add bar worker1
``` ```

View File

@ -30,7 +30,7 @@ for further details.
## Examples ## Examples
```bash ```console
$ docker pause my_container $ docker pause my_container
``` ```

View File

@ -25,7 +25,7 @@ Creates a plugin. Before creating the plugin, prepare the plugin's root filesyst
The following example shows how to create a sample `plugin`. The following example shows how to create a sample `plugin`.
```bash ```console
$ ls -ls /home/pluginDir $ ls -ls /home/pluginDir
total 4 total 4

View File

@ -27,7 +27,7 @@ a plugin that has references (e.g., volumes, networks) cannot be disabled.
The following example shows that the `sample-volume-plugin` plugin is installed The following example shows that the `sample-volume-plugin` plugin is installed
and enabled: and enabled:
```bash ```console
$ docker plugin ls $ docker plugin ls
ID NAME DESCRIPTION ENABLED ID NAME DESCRIPTION ENABLED
@ -36,7 +36,7 @@ ID NAME DESCRIPTION
To disable the plugin, use the following command: To disable the plugin, use the following command:
```bash ```console
$ docker plugin disable tiborvass/sample-volume-plugin $ docker plugin disable tiborvass/sample-volume-plugin
tiborvass/sample-volume-plugin tiborvass/sample-volume-plugin

View File

@ -26,7 +26,7 @@ see [`docker plugin install`](plugin_install.md).
The following example shows that the `sample-volume-plugin` plugin is installed, The following example shows that the `sample-volume-plugin` plugin is installed,
but disabled: but disabled:
```bash ```console
$ docker plugin ls $ docker plugin ls
ID NAME DESCRIPTION ENABLED ID NAME DESCRIPTION ENABLED
@ -35,7 +35,7 @@ ID NAME DESCRIPTION
To enable the plugin, use the following command: To enable the plugin, use the following command:
```bash ```console
$ docker plugin enable tiborvass/sample-volume-plugin $ docker plugin enable tiborvass/sample-volume-plugin
tiborvass/sample-volume-plugin tiborvass/sample-volume-plugin

View File

@ -27,7 +27,7 @@ in a JSON array.
The following example example inspects the `tiborvass/sample-volume-plugin` plugin: The following example example inspects the `tiborvass/sample-volume-plugin` plugin:
```bash ```console
$ docker plugin inspect tiborvass/sample-volume-plugin:latest $ docker plugin inspect tiborvass/sample-volume-plugin:latest
``` ```
@ -144,7 +144,7 @@ Output is in JSON format (output below is formatted for readability):
### Formatting the output ### Formatting the output
```bash ```console
$ docker plugin inspect -f '{{.Id}}' tiborvass/sample-volume-plugin:latest $ docker plugin inspect -f '{{.Id}}' tiborvass/sample-volume-plugin:latest
8c74c978c434745c3ade82f1bc0acf38d04990eaf494fa507c16d9f1daa99c21 8c74c978c434745c3ade82f1bc0acf38d04990eaf494fa507c16d9f1daa99c21

View File

@ -33,7 +33,7 @@ The following example installs `vieus/sshfs` plugin and [sets](plugin_set.md) it
Hub and prompt the user to accept the list of privileges that the plugin needs, Hub and prompt the user to accept the list of privileges that the plugin needs,
set the plugin's parameters and enable the plugin. set the plugin's parameters and enable the plugin.
```bash ```console
$ docker plugin install vieux/sshfs DEBUG=1 $ docker plugin install vieux/sshfs DEBUG=1
Plugin "vieux/sshfs" is requesting the following privileges: Plugin "vieux/sshfs" is requesting the following privileges:
@ -46,7 +46,7 @@ vieux/sshfs
After the plugin is installed, it appears in the list of plugins: After the plugin is installed, it appears in the list of plugins:
```bash ```console
$ docker plugin ls $ docker plugin ls
ID NAME DESCRIPTION ENABLED ID NAME DESCRIPTION ENABLED

View File

@ -31,7 +31,7 @@ Refer to the [filtering](#filtering) section for more information about availabl
## Examples ## Examples
```bash ```console
$ docker plugin ls $ docker plugin ls
ID NAME DESCRIPTION ENABLED ID NAME DESCRIPTION ENABLED
@ -58,7 +58,7 @@ The `capability` filter matches on plugin capabilities. One plugin
might have multiple capabilities. Currently `volumedriver`, `networkdriver`, might have multiple capabilities. Currently `volumedriver`, `networkdriver`,
`ipamdriver`, `logdriver`, `metricscollector`, and `authz` are supported capabilities. `ipamdriver`, `logdriver`, `metricscollector`, and `authz` are supported capabilities.
```bash ```console
$ docker plugin install --disable vieux/sshfs $ docker plugin install --disable vieux/sshfs
Installed plugin vieux/sshfs Installed plugin vieux/sshfs
@ -90,7 +90,7 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`ID` and `Name` entries separated by a colon (`:`) for all plugins: `ID` and `Name` entries separated by a colon (`:`) for all plugins:
```bash ```console
$ docker plugin ls --format "{{.ID}}: {{.Name}}" $ docker plugin ls --format "{{.ID}}: {{.Name}}"
4be01827a72e: vieux/sshfs:latest 4be01827a72e: vieux/sshfs:latest

View File

@ -26,7 +26,7 @@ Registry credentials are managed by [docker login](login.md).
The following example shows how to push a sample `user/plugin`. The following example shows how to push a sample `user/plugin`.
```bash ```console
$ docker plugin ls $ docker plugin ls
ID NAME DESCRIPTION ENABLED ID NAME DESCRIPTION ENABLED

View File

@ -31,7 +31,7 @@ functioning of running containers using the plugin).
The following example disables and removes the `sample-volume-plugin:latest` The following example disables and removes the `sample-volume-plugin:latest`
plugin: plugin:
```bash ```console
$ docker plugin disable tiborvass/sample-volume-plugin $ docker plugin disable tiborvass/sample-volume-plugin
tiborvass/sample-volume-plugin tiborvass/sample-volume-plugin

View File

@ -84,7 +84,7 @@ On the contrary, the `LOGGING` environment variable doesn't have any settable fi
The following example change the env variable `DEBUG` on the The following example change the env variable `DEBUG` on the
`sample-volume-plugin` plugin. `sample-volume-plugin` plugin.
```bash ```console
$ docker plugin inspect -f {{.Settings.Env}} tiborvass/sample-volume-plugin $ docker plugin inspect -f {{.Settings.Env}} tiborvass/sample-volume-plugin
[DEBUG=0] [DEBUG=0]
@ -99,7 +99,7 @@ $ docker plugin inspect -f {{.Settings.Env}} tiborvass/sample-volume-plugin
The following example change the source of the `mymount` mount on The following example change the source of the `mymount` mount on
the `myplugin` plugin. the `myplugin` plugin.
```bash ```console
$ docker plugin inspect -f '{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}' myplugin $ docker plugin inspect -f '{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}' myplugin
/foo /foo
@ -119,7 +119,7 @@ $ docker plugin inspect -f '{{with $mount := index .Settings.Mounts 0}}{{$mount.
The following example change the path of the `mydevice` device on The following example change the path of the `mydevice` device on
the `myplugin` plugin. the `myplugin` plugin.
```bash ```console
$ docker plugin inspect -f '{{with $device := index .Settings.Devices 0}}{{$device.Path}}{{end}}' myplugin $ docker plugin inspect -f '{{with $device := index .Settings.Devices 0}}{{$device.Path}}{{end}}' myplugin
/dev/foo /dev/foo
@ -139,7 +139,7 @@ $ docker plugin inspect -f '{{with $device := index .Settings.Devices 0}}{{$devi
The following example change the value of the args on the `myplugin` plugin. The following example change the value of the args on the `myplugin` plugin.
```bash ```console
$ docker plugin inspect -f '{{.Settings.Args}}' myplugin $ docker plugin inspect -f '{{.Settings.Args}}' myplugin
["foo", "bar"] ["foo", "bar"]

View File

@ -30,7 +30,7 @@ The plugin must be disabled before running the upgrade.
The following example installs `vieus/sshfs` plugin, uses it to create and use The following example installs `vieus/sshfs` plugin, uses it to create and use
a volume, then upgrades the plugin. a volume, then upgrades the plugin.
```bash ```console
$ docker plugin install vieux/sshfs DEBUG=1 $ docker plugin install vieux/sshfs DEBUG=1
Plugin "vieux/sshfs:next" is requesting the following privileges: Plugin "vieux/sshfs:next" is requesting the following privileges:

View File

@ -22,7 +22,7 @@ Options:
You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or You can find out all the ports mapped by not specifying a `PRIVATE_PORT`, or
just a specific mapping: just a specific mapping:
```bash ```console
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

View File

@ -45,7 +45,7 @@ Options:
Running `docker ps --no-trunc` showing 2 linked containers. Running `docker ps --no-trunc` showing 2 linked containers.
```bash ```console
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -58,7 +58,7 @@ d7886598dbe2 crosbymichael/redis:latest /redis-server --dir 33 minut
The `docker ps` command only shows running containers by default. To see all The `docker ps` command only shows running containers by default. To see all
containers, use the `-a` (or `--all`) flag: containers, use the `-a` (or `--all`) flag:
```bash ```console
$ docker ps -a $ docker ps -a
``` ```
@ -70,7 +70,7 @@ the `PORTS` column.
The `docker ps -s` command displays two different on-disk-sizes for each container: The `docker ps -s` command displays two different on-disk-sizes for each container:
```bash ```console
$ docker ps -s $ docker ps -s
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE SIZE CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES SIZE SIZE
@ -114,7 +114,7 @@ value.
The following filter matches containers with the `color` label regardless of its value. The following filter matches containers with the `color` label regardless of its value.
```bash ```console
$ docker ps --filter "label=color" $ docker ps --filter "label=color"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -124,7 +124,7 @@ d85756f57265 busybox "top" 52 seconds ago
The following filter matches containers with the `color` label with the `blue` value. The following filter matches containers with the `color` label with the `blue` value.
```bash ```console
$ docker ps --filter "label=color=blue" $ docker ps --filter "label=color=blue"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -137,7 +137,7 @@ The `name` filter matches on all or part of a container's name.
The following filter matches all containers with a name containing the `nostalgic_stallman` string. The following filter matches all containers with a name containing the `nostalgic_stallman` string.
```bash ```console
$ docker ps --filter "name=nostalgic_stallman" $ docker ps --filter "name=nostalgic_stallman"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -146,7 +146,7 @@ CONTAINER ID IMAGE COMMAND CREATED
You can also filter for a substring in a name as this shows: You can also filter for a substring in a name as this shows:
```bash ```console
$ docker ps --filter "name=nostalgic" $ docker ps --filter "name=nostalgic"
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -160,7 +160,7 @@ CONTAINER ID IMAGE COMMAND CREATED
The `exited` filter matches containers by exist status code. For example, to The `exited` filter matches containers by exist status code. For example, to
filter for containers that have exited successfully: filter for containers that have exited successfully:
```bash ```console
$ docker ps -a --filter 'exited=0' $ docker ps -a --filter 'exited=0'
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -174,7 +174,7 @@ ea09c3c82f6e registry:latest /srv/run.sh 2 weeks ago
You can use a filter to locate containers that exited with status of `137` You can use a filter to locate containers that exited with status of `137`
meaning a `SIGKILL(9)` killed them. meaning a `SIGKILL(9)` killed them.
```bash ```console
$ docker ps -a --filter 'exited=137' $ docker ps -a --filter 'exited=137'
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -194,7 +194,7 @@ The `status` filter matches containers by status. You can filter using
`created`, `restarting`, `running`, `removing`, `paused`, `exited` and `dead`. For example, `created`, `restarting`, `running`, `removing`, `paused`, `exited` and `dead`. For example,
to filter for `running` containers: to filter for `running` containers:
```bash ```console
$ docker ps --filter status=running $ docker ps --filter status=running
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -205,7 +205,7 @@ d5c976d3c462 busybox "top" 23 minutes ago
To filter for `paused` containers: To filter for `paused` containers:
```bash ```console
$ docker ps --filter status=paused $ docker ps --filter status=paused
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -226,7 +226,7 @@ it. The filter supports the following image representation:
If you don't specify a `tag`, the `latest` tag is used. For example, to filter If you don't specify a `tag`, the `latest` tag is used. For example, to filter
for containers that use the latest `ubuntu` image: for containers that use the latest `ubuntu` image:
```bash ```console
$ docker ps --filter ancestor=ubuntu $ docker ps --filter ancestor=ubuntu
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -239,7 +239,7 @@ bab2a34ba363 ubuntu "top" 3 minutes ago
Match containers based on the `ubuntu-c1` image which, in this case, is a child Match containers based on the `ubuntu-c1` image which, in this case, is a child
of `ubuntu`: of `ubuntu`:
```bash ```console
$ docker ps --filter ancestor=ubuntu-c1 $ docker ps --filter ancestor=ubuntu-c1
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -248,7 +248,7 @@ CONTAINER ID IMAGE COMMAND CREATED
Match containers based on the `ubuntu` version `12.04.5` image: Match containers based on the `ubuntu` version `12.04.5` image:
```bash ```console
$ docker ps --filter ancestor=ubuntu:12.04.5 $ docker ps --filter ancestor=ubuntu:12.04.5
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -258,7 +258,7 @@ CONTAINER ID IMAGE COMMAND CREATED
The following matches containers based on the layer `d0e008c6cf02` or an image The following matches containers based on the layer `d0e008c6cf02` or an image
that have this layer in its layer stack. that have this layer in its layer stack.
```bash ```console
$ docker ps --filter ancestor=d0e008c6cf02 $ docker ps --filter ancestor=d0e008c6cf02
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -272,7 +272,7 @@ CONTAINER ID IMAGE COMMAND CREATED
The `before` filter shows only containers created before the container with The `before` filter shows only containers created before the container with
given id or name. For example, having these containers created: given id or name. For example, having these containers created:
```bash ```console
$ docker ps $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -283,7 +283,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
Filtering with `before` would give: Filtering with `before` would give:
```bash ```console
$ docker ps -f before=9c3527ed70ce $ docker ps -f before=9c3527ed70ce
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -296,7 +296,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
The `since` filter shows only containers created since the container with given 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: id or name. For example, with the same containers as in `before` filter:
```bash ```console
$ docker ps -f since=6e63f6ff38b0 $ docker ps -f since=6e63f6ff38b0
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -309,7 +309,7 @@ CONTAINER ID IMAGE COMMAND CREATED STATUS
The `volume` filter shows only containers that mount a specific volume or have The `volume` filter shows only containers that mount a specific volume or have
a volume mounted in a specific path: a volume mounted in a specific path:
```bash ```console
$ docker ps --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}" $ docker ps --filter volume=remote-volume --format "table {{.ID}}\t{{.Mounts}}"
CONTAINER ID MOUNTS CONTAINER ID MOUNTS
@ -329,7 +329,7 @@ a given name or id.
The following filter matches all containers that are connected to a network The following filter matches all containers that are connected to a network
with a name containing `net1`. with a name containing `net1`.
```bash ```console
$ docker run -d --net=net1 --name=test1 ubuntu top $ docker run -d --net=net1 --name=test1 ubuntu top
$ docker run -d --net=net2 --name=test2 ubuntu top $ docker run -d --net=net2 --name=test2 ubuntu top
@ -343,7 +343,7 @@ The network filter matches on both the network's name and id. The following
example shows all containers that are attached to the `net1` network, using example shows all containers that are attached to the `net1` network, using
the network id as a filter; the network id as a filter;
```bash ```console
$ docker network inspect --format "{{.ID}}" net1 $ docker network inspect --format "{{.ID}}" net1
8c0b4110ae930dbe26b258de9bc34a03f98056ed6f27f991d32919bfe401d7c5 8c0b4110ae930dbe26b258de9bc34a03f98056ed6f27f991d32919bfe401d7c5
@ -361,7 +361,7 @@ number, port range, and/or protocol. The default protocol is `tcp` when not spec
The following filter matches all containers that have published port of 80: The following filter matches all containers that have published port of 80:
```bash ```console
$ docker run -d --publish=80 busybox top $ docker run -d --publish=80 busybox top
$ docker run -d --expose=8080 busybox top $ docker run -d --expose=8080 busybox top
@ -378,7 +378,8 @@ fc7e477723b7 busybox "top" About a minute ago
``` ```
The following filter matches all containers that have exposed TCP port in the range of `8000-8080`: The following filter matches all containers that have exposed TCP port in the range of `8000-8080`:
```bash
```console
$ docker ps --filter expose=8000-8080/tcp $ docker ps --filter expose=8000-8080/tcp
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -386,7 +387,8 @@ CONTAINER ID IMAGE COMMAND CREATED
``` ```
The following filter matches all containers that have exposed UDP port `80`: The following filter matches all containers that have exposed UDP port `80`:
```bash
```console
$ docker ps --filter publish=80/udp $ docker ps --filter publish=80/udp
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
@ -423,7 +425,7 @@ column headers as well.
The following example uses a template without headers and outputs the `ID` and The following example uses a template without headers and outputs the `ID` and
`Command` entries separated by a colon (`:`) for all running containers: `Command` entries separated by a colon (`:`) for all running containers:
```bash ```console
$ docker ps --format "{{.ID}}: {{.Command}}" $ docker ps --format "{{.ID}}: {{.Command}}"
a87ecb4f327c: /bin/sh -c #(nop) MA a87ecb4f327c: /bin/sh -c #(nop) MA
@ -434,7 +436,7 @@ c1d3b0166030: /bin/sh -c yum -y up
To list all running containers with their labels in a table format you can use: To list all running containers with their labels in a table format you can use:
```bash ```console
$ docker ps --format "table {{.ID}}\t{{.Labels}}" $ docker ps --format "table {{.ID}}\t{{.Labels}}"
CONTAINER ID LABELS CONTAINER ID LABELS

View File

@ -53,7 +53,7 @@ To download a particular image, or set of images (i.e., a repository), use
`docker pull`. If no tag is provided, Docker Engine uses the `:latest` tag as a `docker pull`. If no tag is provided, Docker Engine uses the `:latest` tag as a
default. This command pulls the `debian:latest` image: default. This command pulls the `debian:latest` image:
```bash ```console
$ docker pull debian $ docker pull debian
Using default tag: latest Using default tag: latest
@ -72,7 +72,7 @@ both layers with `debian:latest`. Pulling the `debian:jessie` image therefore
only pulls its metadata, but not its layers, because all layers are already only pulls its metadata, but not its layers, because all layers are already
present locally: present locally:
```bash ```console
$ docker pull debian:jessie $ docker pull debian:jessie
jessie: Pulling from library/debian jessie: Pulling from library/debian
@ -85,7 +85,7 @@ Status: Downloaded newer image for debian:jessie
To see which images are present locally, use the [`docker images`](images.md) To see which images are present locally, use the [`docker images`](images.md)
command: command:
```bash ```console
$ docker images $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -121,22 +121,22 @@ and guarantee that the image you're using is always the same.
To know the digest of an image, pull the image first. Let's pull the latest To know the digest of an image, pull the image first. Let's pull the latest
`ubuntu:14.04` image from Docker Hub: `ubuntu:14.04` image from Docker Hub:
```bash ```console
$ docker pull ubuntu:14.04 $ docker pull ubuntu:20.04
14.04: Pulling from library/ubuntu 20.04: Pulling from library/ubuntu
5a132a7e7af1: Pull complete 16ec32c2132b: Pull complete
fd2731e4c50c: Pull complete Digest: sha256:82becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3
28a2f68d1120: Pull complete Status: Downloaded newer image for ubuntu:20.04
a3ed95caeb02: Pull complete docker.io/library/ubuntu:20.04
Digest: sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2
Status: Downloaded newer image for ubuntu:14.04
``` ```
Docker prints the digest of the image after the pull has finished. In the example Docker prints the digest of the image after the pull has finished. In the example
above, the digest of the image is: above, the digest of the image is:
sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2 ```console
sha256:82becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3
```
Docker also prints the digest of an image when *pushing* to a registry. This Docker also prints the digest of an image when *pushing* to a registry. This
may be useful if you want to pin to a version of the image you just pushed. may be useful if you want to pin to a version of the image you just pushed.
@ -144,22 +144,19 @@ may be useful if you want to pin to a version of the image you just pushed.
A digest takes the place of the tag when pulling an image, for example, to A digest takes the place of the tag when pulling an image, for example, to
pull the above image by digest, run the following command: pull the above image by digest, run the following command:
```bash ```console
$ docker pull ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2 $ docker pull ubuntu@sha256:82becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3
sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2: Pulling from library/ubuntu docker.io/library/ubuntu@sha256:82becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3: Pulling from library/ubuntu
5a132a7e7af1: Already exists Digest: sha256:82becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3
fd2731e4c50c: Already exists Status: Image is up to date for ubuntu@sha256:82becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3
28a2f68d1120: Already exists docker.io/library/ubuntu@sha256:82becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3
a3ed95caeb02: Already exists
Digest: sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2
Status: Downloaded newer image for ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2
``` ```
Digest can also be used in the `FROM` of a Dockerfile, for example: Digest can also be used in the `FROM` of a Dockerfile, for example:
```dockerfile ```dockerfile
FROM ubuntu@sha256:45b23dee08af5e43a7fea6c4cf9c25ccf269ee113168c19722f87876677c5cb2 FROM ubuntu@sha256:82becede498899ec668628e7cb0ad87b6e1c371cb8a1e597d83a47fac21d6af3
LABEL org.opencontainers.image.authors="some maintainer <maintainer@example.com>" LABEL org.opencontainers.image.authors="some maintainer <maintainer@example.com>"
``` ```
@ -181,7 +178,7 @@ path is similar to a URL, but does not contain a protocol specifier (`https://`)
The following command pulls the `testing/test-image` image from a local registry The following command pulls the `testing/test-image` image from a local registry
listening on port 5000 (`myregistry.local:5000`): listening on port 5000 (`myregistry.local:5000`):
```bash ```console
$ docker pull myregistry.local:5000/testing/test-image $ docker pull myregistry.local:5000/testing/test-image
``` ```
@ -200,7 +197,7 @@ can contain multiple images. To pull all images from a repository, provide the
This command pulls all images from the `fedora` repository: This command pulls all images from the `fedora` repository:
```bash ```console
$ docker pull --all-tags fedora $ docker pull --all-tags fedora
Pulling repository fedora Pulling repository fedora
@ -217,7 +214,7 @@ After the pull has completed use the `docker images` command to see the
images that were pulled. The example below shows all the `fedora` images images that were pulled. The example below shows all the `fedora` images
that are present locally: that are present locally:
```bash ```console
$ docker images fedora $ docker images fedora
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -232,7 +229,7 @@ fedora latest 105182bb5e8b 5 days ago 372.7 MB
Killing the `docker pull` process, for example by pressing `CTRL-c` while it is Killing the `docker pull` process, for example by pressing `CTRL-c` while it is
running in a terminal, will terminate the pull operation. running in a terminal, will terminate the pull operation.
```bash ```console
$ docker pull fedora $ docker pull fedora
Using default tag: latest Using default tag: latest

View File

@ -50,7 +50,7 @@ First save the new image by finding the container ID (using [`docker container l
and then committing it to a new image name. Note that only `a-z0-9-_.` are and then committing it to a new image name. Note that only `a-z0-9-_.` are
allowed when naming images: allowed when naming images:
```bash ```console
$ docker container commit c16378f943fe rhel-httpd:latest $ docker container commit c16378f943fe rhel-httpd:latest
``` ```
@ -59,7 +59,7 @@ registry is on host named `registry-host` and listening on port `5000`. To do
this, tag the image with the host name or IP address, and the port of the this, tag the image with the host name or IP address, and the port of the
registry: registry:
```bash ```console
$ docker image tag rhel-httpd:latest registry-host:5000/myadmin/rhel-httpd:latest $ docker image tag rhel-httpd:latest registry-host:5000/myadmin/rhel-httpd:latest
$ docker image push registry-host:5000/myadmin/rhel-httpd:latest $ docker image push registry-host:5000/myadmin/rhel-httpd:latest
@ -67,7 +67,7 @@ $ docker image push registry-host:5000/myadmin/rhel-httpd:latest
Check that this worked by running: Check that this worked by running:
```bash ```console
$ docker image ls $ docker image ls
``` ```
@ -82,7 +82,7 @@ The following example creates multiple tags for an image, and pushes all those
tags to Docker Hub. tags to Docker Hub.
```bash ```console
$ docker image tag myimage registry-host:5000/myname/myimage:latest $ docker image tag myimage registry-host:5000/myname/myimage:latest
$ docker image tag myimage registry-host:5000/myname/myimage:v1.0.1 $ docker image tag myimage registry-host:5000/myname/myimage:v1.0.1
$ docker image tag myimage registry-host:5000/myname/myimage:v1.0 $ docker image tag myimage registry-host:5000/myname/myimage:v1.0
@ -91,7 +91,7 @@ $ docker image tag myimage registry-host:5000/myname/myimage:v1
The image is now tagged under multiple names: The image is now tagged under multiple names:
```bash ```console
$ docker image ls $ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -106,7 +106,7 @@ When pushing with the `--all-tags` option, all tags of the `registry-host:5000/m
image are pushed: image are pushed:
```bash ```console
$ docker image push --all-tags registry-host:5000/myname/myimage $ docker image push --all-tags registry-host:5000/myname/myimage
The push refers to repository [registry-host:5000/myname/myimage] The push refers to repository [registry-host:5000/myname/myimage]

View File

@ -21,6 +21,6 @@ The `docker rename` command renames a container.
## Examples ## Examples
```bash ```console
$ docker rename my_container my_new_container $ docker rename my_container my_new_container
``` ```

View File

@ -18,6 +18,6 @@ Options:
## Examples ## Examples
```bash ```console
$ docker restart my_container $ docker restart my_container
``` ```

View File

@ -24,7 +24,7 @@ Options:
This removes the container referenced under the link `/redis`. This removes the container referenced under the link `/redis`.
```bash ```console
$ docker rm /redis $ docker rm /redis
/redis /redis
@ -37,7 +37,7 @@ containers on the default bridge network, removing all network communication
between the two containers. This does not apply when `--link` is used with between the two containers. This does not apply when `--link` is used with
user-specified networks. user-specified networks.
```bash ```console
$ docker rm --link /webapp/redis $ docker rm --link /webapp/redis
/webapp/redis /webapp/redis
@ -47,7 +47,7 @@ $ docker rm --link /webapp/redis
This command force-removes a running container. This command force-removes a running container.
```bash ```console
$ docker rm --force redis $ docker rm --force redis
redis redis
@ -88,7 +88,7 @@ $ docker ps --filter status=exited -q | xargs docker rm
### Remove a container and its volumes ### Remove a container and its volumes
```bash ```console
$ docker rm -v redis $ docker rm -v redis
redis redis
``` ```
@ -98,7 +98,7 @@ Note that if a volume was specified with a name, it will not be removed.
### Remove a container and selectively remove volumes ### Remove a container and selectively remove volumes
```bash ```console
$ docker create -v awesome:/foo -v /bar --name hello redis $ docker create -v awesome:/foo -v /bar --name hello redis
hello hello

View File

@ -35,7 +35,7 @@ an image has one or more tags referencing it, you must remove all of them before
the image is removed. Digest references are removed automatically when an image the image is removed. Digest references are removed automatically when an image
is removed by tag. is removed by tag.
```bash ```console
$ docker images $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -71,7 +71,7 @@ Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
If you use the `-f` flag and specify the image's short or long ID, then this 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. command untags and removes all images that match the specified ID.
```bash ```console
$ docker images $ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE REPOSITORY TAG IMAGE ID CREATED SIZE
@ -89,7 +89,7 @@ Deleted: fd484f19954f4920da7ff372b5067f5b7ddb2fd3830cecd17b96ea9e286ba5b8
An image pulled by digest has no tag associated with it: An image pulled by digest has no tag associated with it:
```bash ```console
$ docker images --digests $ docker images --digests
REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE REPOSITORY TAG DIGEST IMAGE ID CREATED SIZE
@ -98,7 +98,7 @@ localhost:5000/test/busybox <none> sha256:cbbf2f9a99b47fc460d422812b6a5adf
To remove an image using its digest: To remove an image using its digest:
```bash ```console
$ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf $ docker rmi localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf Untagged: localhost:5000/test/busybox@sha256:cbbf2f9a99b47fc460d422812b6a5adff7dfee951d8fa2e4a98caa0382cfbdbf
Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125 Deleted: 4986bf8c15363d1c5d15512d5266f8777bfba4974ac56e3270e7760f6f0a8125

View File

@ -120,7 +120,7 @@ Options:
or `g` (gigabytes). If you omit the unit, the system uses bytes. or `g` (gigabytes). If you omit the unit, the system uses bytes.
--sig-proxy Proxy received signals to the process (default true) --sig-proxy Proxy received signals to the process (default true)
--stop-signal string Signal to stop a container (default "SIGTERM") --stop-signal string Signal to stop a container (default "SIGTERM")
--stop-timeout=10 Timeout (in seconds) to stop a container --stop-timeout int Timeout (in seconds) to stop a container
--storage-opt value Storage driver options for the container (default []) --storage-opt value Storage driver options for the container (default [])
--sysctl value Sysctl options (default map[]) --sysctl value Sysctl options (default map[])
--tmpfs value Mount a tmpfs directory (default []) --tmpfs value Mount a tmpfs directory (default [])
@ -161,7 +161,7 @@ For information on connecting a container to a network, see the ["*Docker networ
### Assign name and allocate pseudo-TTY (--name, -it) ### Assign name and allocate pseudo-TTY (--name, -it)
```bash ```console
$ docker run --name test -it debian $ docker run --name test -it debian
root@d6c0fe130dba:/# exit 13 root@d6c0fe130dba:/# exit 13
@ -180,7 +180,7 @@ In the example, the `bash` shell is quit by entering
### Capture container ID (--cidfile) ### Capture container ID (--cidfile)
```bash ```console
$ docker run --cidfile /tmp/docker_test.cid ubuntu echo "test" $ docker run --cidfile /tmp/docker_test.cid ubuntu echo "test"
``` ```
@ -191,7 +191,7 @@ file when `docker run` exits.
### Full container capabilities (--privileged) ### Full container capabilities (--privileged)
```bash ```console
$ docker run -t -i --rm ubuntu bash $ docker run -t -i --rm ubuntu bash
root@bc338942ef20:/# mount -t tmpfs none /mnt root@bc338942ef20:/# mount -t tmpfs none /mnt
mount: permission denied mount: permission denied
@ -201,7 +201,7 @@ This will *not* work, because by default, most potentially dangerous kernel
capabilities are dropped; including `cap_sys_admin` (which is required to mount capabilities are dropped; including `cap_sys_admin` (which is required to mount
filesystems). However, the `--privileged` flag will allow it to run: filesystems). However, the `--privileged` flag will allow it to run:
```bash ```console
$ docker run -t -i --privileged ubuntu bash $ docker run -t -i --privileged ubuntu bash
root@50e3f57e16e6:/# mount -t tmpfs none /mnt root@50e3f57e16e6:/# mount -t tmpfs none /mnt
root@50e3f57e16e6:/# df -h root@50e3f57e16e6:/# df -h
@ -216,7 +216,7 @@ flag exists to allow special use-cases, like running Docker within Docker.
### Set working directory (-w) ### Set working directory (-w)
```bash ```console
$ docker run -w /path/to/dir/ -i -t ubuntu pwd $ docker run -w /path/to/dir/ -i -t ubuntu pwd
``` ```
@ -225,7 +225,7 @@ The `-w` lets the command being executed inside directory given, here
### Set storage driver options per container ### Set storage driver options per container
```bash ```console
$ docker run -it --storage-opt size=120G fedora /bin/bash $ docker run -it --storage-opt size=120G fedora /bin/bash
``` ```
@ -240,7 +240,7 @@ Under these conditions, user can pass any size less than the backing fs size.
### Mount tmpfs (--tmpfs) ### Mount tmpfs (--tmpfs)
```bash ```console
$ docker run -d --tmpfs /run:rw,noexec,nosuid,size=65536k my_image $ docker run -d --tmpfs /run:rw,noexec,nosuid,size=65536k my_image
``` ```
@ -249,7 +249,7 @@ The `--tmpfs` flag mounts an empty tmpfs into the container with the `rw`,
### Mount volume (-v, --read-only) ### Mount volume (-v, --read-only)
```bash ```console
$ docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd $ docker run -v `pwd`:`pwd` -w `pwd` -i -t ubuntu pwd
``` ```
@ -259,7 +259,7 @@ changing into the directory to the value returned by `pwd`. So this
combination executes the command using the container, but inside the combination executes the command using the container, but inside the
current working directory. current working directory.
```bash ```console
$ docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash $ docker run -v /doesnt/exist:/foo -w /foo -i -t ubuntu bash
``` ```
@ -268,7 +268,7 @@ will automatically create this directory on the host for you. In the
example above, Docker will create the `/doesnt/exist` example above, Docker will create the `/doesnt/exist`
folder before starting your container. folder before starting your container.
```bash ```console
$ docker run --read-only -v /icanwrite busybox touch /icanwrite/here $ docker run --read-only -v /icanwrite busybox touch /icanwrite/here
``` ```
@ -277,7 +277,7 @@ a container writes files. The `--read-only` flag mounts the container's root
filesystem as read only prohibiting writes to locations other than the filesystem as read only prohibiting writes to locations other than the
specified volumes for the container. specified volumes for the container.
```bash ```console
$ docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v /path/to/static-docker-binary:/usr/bin/docker busybox sh $ docker run -t -i -v /var/run/docker.sock:/var/run/docker.sock -v /path/to/static-docker-binary:/usr/bin/docker busybox sh
``` ```
@ -327,17 +327,17 @@ Even though there is no plan to deprecate `--volume`, usage of `--mount` is reco
Examples: Examples:
```bash ```console
$ docker run --read-only --mount type=volume,target=/icanwrite busybox touch /icanwrite/here $ docker run --read-only --mount type=volume,target=/icanwrite busybox touch /icanwrite/here
``` ```
```bash ```console
$ docker run -t -i --mount type=bind,src=/data,dst=/data busybox sh $ docker run -t -i --mount type=bind,src=/data,dst=/data busybox sh
``` ```
### Publish or expose port (-p, --expose) ### Publish or expose port (-p, --expose)
```bash ```console
$ docker run -p 127.0.0.1:80:8080/tcp ubuntu bash $ docker run -p 127.0.0.1:80:8080/tcp ubuntu bash
``` ```
@ -351,7 +351,7 @@ Note that ports which are not bound to the host (i.e., `-p 80:80` instead of
you configured UFW to block this specific port, as Docker manages his you configured UFW to block this specific port, as Docker manages his
own iptables rules. [Read more](https://docs.docker.com/network/iptables/) own iptables rules. [Read more](https://docs.docker.com/network/iptables/)
```bash ```console
$ docker run --expose 80 ubuntu bash $ docker run --expose 80 ubuntu bash
``` ```
@ -360,7 +360,7 @@ system's interfaces.
### Set environment variables (-e, --env, --env-file) ### Set environment variables (-e, --env, --env-file)
```bash ```console
$ docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash $ docker run -e MYVAR1 --env MYVAR2=foo --env-file ./env.list ubuntu bash
``` ```
@ -370,7 +370,7 @@ that are defined in the Dockerfile of the image you're running.
You can define the variable and its value when running the container: You can define the variable and its value when running the container:
```bash ```console
$ docker run --env VAR1=value1 --env VAR2=value2 ubuntu env | grep VAR $ docker run --env VAR1=value1 --env VAR2=value2 ubuntu env | grep VAR
VAR1=value1 VAR1=value1
VAR2=value2 VAR2=value2
@ -378,7 +378,7 @@ VAR2=value2
You can also use variables that you've exported to your local environment: You can also use variables that you've exported to your local environment:
```bash ```console
export VAR1=value1 export VAR1=value1
export VAR2=value2 export VAR2=value2
@ -396,7 +396,7 @@ You can also load the environment variables from a file. This file should use
the syntax `<variable>=value` (which sets the variable to the given value) or the syntax `<variable>=value` (which sets the variable to the given value) or
`<variable>` (which takes the value from the local environment), and `#` for comments. `<variable>` (which takes the value from the local environment), and `#` for comments.
```bash ```console
$ cat env.list $ cat env.list
# This is a comment # This is a comment
VAR1=value1 VAR1=value1
@ -413,7 +413,7 @@ USER=denis
A label is a `key=value` pair that applies metadata to a container. To label a container with two labels: A label is a `key=value` pair that applies metadata to a container. To label a container with two labels:
```bash ```console
$ docker run -l my-label --label com.example.foo=bar ubuntu bash $ docker run -l my-label --label com.example.foo=bar ubuntu bash
``` ```
@ -428,7 +428,7 @@ 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 label in the file with an EOL mark. The example below loads labels from a
labels file in the current directory: labels file in the current directory:
```bash ```console
$ docker run --label-file ./labels ubuntu bash $ docker run --label-file ./labels ubuntu bash
``` ```
@ -456,14 +456,14 @@ the Docker User Guide.
When you start a container use the `--network` flag to connect it to a network. When you start a container use the `--network` flag to connect it to a network.
This adds the `busybox` container to the `my-net` network. This adds the `busybox` container to the `my-net` network.
```bash ```console
$ docker run -itd --network=my-net busybox $ docker run -itd --network=my-net busybox
``` ```
You can also choose the IP addresses for the container with `--ip` and `--ip6` You can also choose the IP addresses for the container with `--ip` and `--ip6`
flags when you start the container on a user-defined network. flags when you start the container on a user-defined network.
```bash ```console
$ docker run -itd --network=my-net --ip=10.10.9.75 busybox $ docker run -itd --network=my-net --ip=10.10.9.75 busybox
``` ```
@ -486,7 +486,7 @@ disconnect` command.
### Mount volumes from container (--volumes-from) ### Mount volumes from container (--volumes-from)
```bash ```console
$ docker run --volumes-from 777f7dc92da7 --volumes-from ba8c0c54f0f2:ro -i -t ubuntu pwd $ docker run --volumes-from 777f7dc92da7 --volumes-from ba8c0c54f0f2:ro -i -t ubuntu pwd
``` ```
@ -516,14 +516,14 @@ 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 or `STDERR`. This makes it possible to manipulate the output and input as
needed. needed.
```bash ```console
$ echo "test" | docker run -i -a stdin ubuntu cat - $ echo "test" | docker run -i -a stdin ubuntu cat -
``` ```
This pipes data into a container and prints the container's ID by attaching This pipes data into a container and prints the container's ID by attaching
only to the container's `STDIN`. only to the container's `STDIN`.
```bash ```console
$ docker run -a stderr ubuntu echo test $ docker run -a stderr ubuntu echo test
``` ```
@ -531,7 +531,7 @@ 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 only attached to the `STDERR` of the container. The container's logs
still store what's been written to `STDERR` and `STDOUT`. still store what's been written to `STDERR` and `STDOUT`.
```bash ```console
$ cat somefile | docker run -i -a stdin mybuilder dobuild $ cat somefile | docker run -i -a stdin mybuilder dobuild
``` ```
@ -543,7 +543,7 @@ retrieve the container's ID once the container has finished running.
### Add host device to container (--device) ### Add host device to container (--device)
```bash ```console
$ docker run --device=/dev/sdc:/dev/xvdc \ $ docker run --device=/dev/sdc:/dev/xvdc \
--device=/dev/sdd --device=/dev/zero:/dev/nulo \ --device=/dev/sdd --device=/dev/zero:/dev/nulo \
-i -t \ -i -t \
@ -564,7 +564,7 @@ This can be overridden using a third `:rwm` set of options to each `--device`
flag. If the container is running in privileged mode, then the permissions specified flag. If the container is running in privileged mode, then the permissions specified
will be ignored. will be ignored.
```bash ```console
$ 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 Command (m for help): q
@ -620,20 +620,20 @@ for more information.
To use `--gpus`, specify which GPUs (or all) to use. If no value is provied, all To use `--gpus`, specify which GPUs (or all) to use. If no value is provied, all
available GPUs are used. The example below exposes all available GPUs. available GPUs are used. The example below exposes all available GPUs.
```bash ```console
$ docker run -it --rm --gpus all ubuntu nvidia-smi $ docker run -it --rm --gpus all ubuntu nvidia-smi
``` ```
Use the `device` option to specify GPUs. The example below exposes a specific Use the `device` option to specify GPUs. The example below exposes a specific
GPU. GPU.
```bash ```console
$ docker run -it --rm --gpus device=GPU-3a23c669-1f69-c64e-cf85-44e9b07e7a2a ubuntu nvidia-smi $ docker run -it --rm --gpus device=GPU-3a23c669-1f69-c64e-cf85-44e9b07e7a2a ubuntu nvidia-smi
``` ```
The example below exposes the first and third GPUs. The example below exposes the first and third GPUs.
```bash ```console
$ docker run -it --rm --gpus device=0,2 nvidia-smi $ docker run -it --rm --gpus device=0,2 nvidia-smi
``` ```
@ -650,7 +650,7 @@ Docker supports the following restart policies:
| `unless-stopped` | Restart the container unless it is explicitly stopped or Docker itself is stopped or restarted. | | `unless-stopped` | Restart the container unless it is explicitly stopped or Docker itself is stopped or restarted. |
| `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. | | `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. |
```bash ```console
$ docker run --restart=always redis $ docker run --restart=always redis
``` ```
@ -667,16 +667,18 @@ 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 more `--add-host` flags. This example adds a static address for a host named
`docker`: `docker`:
```bash ```console
$ docker run --add-host=docker:10.180.0.1 --rm -it debian $ docker run --add-host=docker:93.184.216.34 --rm -it alpine
root@f38c87f2a42d:/# ping docker / # ping docker
PING docker (10.180.0.1): 48 data bytes PING docker (93.184.216.34): 56 data bytes
56 bytes from 10.180.0.1: icmp_seq=0 ttl=254 time=7.600 ms 64 bytes from 93.184.216.34: seq=0 ttl=37 time=93.052 ms
56 bytes from 10.180.0.1: icmp_seq=1 ttl=254 time=30.705 ms 64 bytes from 93.184.216.34: seq=1 ttl=37 time=92.467 ms
^C--- docker ping statistics --- 64 bytes from 93.184.216.34: seq=2 ttl=37 time=92.252 ms
2 packets transmitted, 2 packets received, 0% packet loss ^C
round-trip min/avg/max/stddev = 7.600/19.152/30.705/11.553 ms --- docker ping statistics ---
4 packets transmitted, 4 packets received, 0% packet loss
round-trip min/avg/max = 92.209/92.495/93.052 ms
``` ```
Sometimes you need to connect to the Docker host from within your Sometimes you need to connect to the Docker host from within your
@ -688,7 +690,7 @@ The flags you pass to `ip addr show` depend on whether you are
using IPv4 or IPv6 networking in your containers. Use the following using IPv4 or IPv6 networking in your containers. Use the following
flags for IPv4 address retrieval for a network device named `eth0`: flags for IPv4 address retrieval for a network device named `eth0`:
```bash ```console
$ HOSTIP=`ip -4 addr show scope global dev eth0 | grep inet | awk '{print $2}' | cut -d / -f 1 | sed -n 1p` $ HOSTIP=`ip -4 addr show scope global dev eth0 | grep inet | awk '{print $2}' | cut -d / -f 1 | sed -n 1p`
$ docker run --add-host=docker:${HOSTIP} --rm -it debian $ docker run --add-host=docker:${HOSTIP} --rm -it debian
``` ```
@ -704,7 +706,7 @@ available in the default container, you can set these using the `--ulimit` flag.
`--ulimit` is specified with a soft and hard limit as such: `--ulimit` is specified with a soft and hard limit as such:
`<type>=<soft limit>[:<hard limit>]`, for example: `<type>=<soft limit>[:<hard limit>]`, for example:
```bash ```console
$ docker run --ulimit nofile=1024:1024 --rm debian sh -c "ulimit -n" $ docker run --ulimit nofile=1024:1024 --rm debian sh -c "ulimit -n"
1024 1024
``` ```
@ -716,7 +718,7 @@ $ docker run --ulimit nofile=1024:1024 --rm debian sh -c "ulimit -n"
> the default `ulimits` set on the daemon. The `as` option is disabled now. > the default `ulimits` set on the daemon. The `as` option is disabled now.
> In other words, the following script is not supported: > In other words, the following script is not supported:
> >
> ```bash > ```console
> $ docker run -it --ulimit as=1024 fedora /bin/bash` > $ docker run -it --ulimit as=1024 fedora /bin/bash`
> ``` > ```
@ -729,7 +731,7 @@ 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 maximum number of processes available to a user, not to a container. For example, start four
containers with `daemon` user: containers with `daemon` user:
```bash ```console
$ 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
@ -745,9 +747,12 @@ the three processes quota set for the `daemon` user.
### Stop container with signal (--stop-signal) ### Stop container with signal (--stop-signal)
The `--stop-signal` flag sets the system call signal that will be sent to the container to exit. The `--stop-signal` flag sets the system call signal that will be sent to the
This signal can be a valid unsigned number that matches a position in the kernel's syscall table, for instance 9, container to exit. This signal can be a signal name in the format `SIG<NAME>`,
or a signal name in the format SIGNAME, for instance SIGKILL. for instance `SIGKILL`, or an unsigned number that matches a position in the
kernel's syscall table, for instance `9`.
The default is `SIGTERM` if not specified.
### Optional security options (--security-opt) ### Optional security options (--security-opt)
@ -756,8 +761,16 @@ The `credentialspec` must be in the format `file://spec.txt` or `registry://keyn
### Stop container with timeout (--stop-timeout) ### Stop container with timeout (--stop-timeout)
The `--stop-timeout` flag sets the timeout (in seconds) that a pre-defined (see `--stop-signal`) system call The `--stop-timeout` flag sets the number of seconds to wait for the container
signal that will be sent to the container to exit. After timeout elapses the container will be killed with SIGKILL. to stop after sending the pre-defined (see `--stop-signal`) system call signal.
If the container does not exit after the timeout elapses, it is forcibly killed
with a `SIGKILL` signal.
If `--stop-timeout` is set to `-1`, no timeout is applied, and the daemon will
wait indefinitely for the container to exit.
The default is determined by the daemon, and is 10 seconds for Linux containers,
and 30 seconds for Windows containers.
### Specify isolation technology for container (--isolation) ### Specify isolation technology for container (--isolation)
@ -766,7 +779,7 @@ Windows. The `--isolation <value>` option sets a container's isolation technolog
On Linux, the only supported is the `default` option which uses On Linux, the only supported is the `default` option which uses
Linux namespaces. These two commands are equivalent on Linux: Linux namespaces. These two commands are equivalent on Linux:
```bash ```console
$ docker run -d busybox top $ docker run -d busybox top
$ docker run -d --isolation default busybox top $ docker run -d --isolation default busybox top
``` ```
@ -847,7 +860,7 @@ The `--sysctl` sets namespaced kernel parameters (sysctls) in the
container. For example, to turn on IP forwarding in the containers container. For example, to turn on IP forwarding in the containers
network namespace, run this command: network namespace, run this command:
```bash ```console
$ docker run --sysctl net.ipv4.ip_forward=1 someimage $ docker run --sysctl net.ipv4.ip_forward=1 someimage
``` ```

View File

@ -26,7 +26,7 @@ each argument provided.
### Create a backup that can then be used with `docker load`. ### Create a backup that can then be used with `docker load`.
```bash ```console
$ docker save busybox > busybox.tar $ docker save busybox > busybox.tar
$ ls -sh busybox.tar $ ls -sh busybox.tar
@ -48,14 +48,14 @@ $ docker save -o fedora-latest.tar fedora:latest
You can use gzip to save the image file and make the backup smaller. You can use gzip to save the image file and make the backup smaller.
```bash ```console
docker save myimage:latest | gzip > myimage_latest.tar.gz $ docker save myimage:latest | gzip > myimage_latest.tar.gz
``` ```
### Cherry-pick particular tags ### Cherry-pick particular tags
You can even cherry-pick particular tags of an image repository. You can even cherry-pick particular tags of an image repository.
```bash ```console
$ docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy $ docker save -o ubuntu.tar ubuntu:lucid ubuntu:saucy
``` ```

View File

@ -32,7 +32,7 @@ Search [Docker Hub](https://hub.docker.com) for images
This example displays images with a name containing 'busybox': This example displays images with a name containing 'busybox':
```bash ```console
$ docker search busybox $ docker search busybox
NAME DESCRIPTION STARS OFFICIAL AUTOMATED NAME DESCRIPTION STARS OFFICIAL AUTOMATED
@ -68,8 +68,9 @@ marclop/busybox-solr
This example displays images with a name containing 'busybox', This example displays images with a name containing 'busybox',
at least 3 stars and the description isn't truncated in the output: at least 3 stars and the description isn't truncated in the output:
```bash ```console
$ docker search --filter=stars=3 --no-trunc busybox $ docker search --filter=stars=3 --no-trunc busybox
NAME DESCRIPTION STARS OFFICIAL AUTOMATED NAME DESCRIPTION STARS OFFICIAL AUTOMATED
busybox Busybox base image. 325 [OK] busybox Busybox base image. 325 [OK]
progrium/busybox 50 [OK] progrium/busybox 50 [OK]
@ -97,7 +98,7 @@ The currently supported filters are:
This example displays images with a name containing 'busybox' and at This example displays images with a name containing 'busybox' and at
least 3 stars: least 3 stars:
```bash ```console
$ docker search --filter stars=3 busybox $ docker search --filter stars=3 busybox
NAME DESCRIPTION STARS OFFICIAL AUTOMATED NAME DESCRIPTION STARS OFFICIAL AUTOMATED
@ -111,7 +112,7 @@ radial/busyboxplus Full-chain, Internet enabled, busybox made... 8
This example displays images with a name containing 'busybox' This example displays images with a name containing 'busybox'
and are automated builds: and are automated builds:
```bash ```console
$ docker search --filter is-automated=true busybox $ docker search --filter is-automated=true busybox
NAME DESCRIPTION STARS OFFICIAL AUTOMATED NAME DESCRIPTION STARS OFFICIAL AUTOMATED
@ -124,7 +125,7 @@ radial/busyboxplus Full-chain, Internet enabled, busybox made... 8
This example displays images with a name containing 'busybox', at least This example displays images with a name containing 'busybox', at least
3 stars and are official builds: 3 stars and are official builds:
```bash ```console
$ docker search --filter is-official=true --filter stars=3 busybox $ docker search --filter is-official=true --filter stars=3 busybox
NAME DESCRIPTION STARS OFFICIAL AUTOMATED NAME DESCRIPTION STARS OFFICIAL AUTOMATED
@ -154,7 +155,7 @@ output the data exactly as the template declares. If you use the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`Name` and `StarCount` entries separated by a colon (`:`) for all images: `Name` and `StarCount` entries separated by a colon (`:`) for all images:
```bash ```console
$ docker search --format "{{.Name}}: {{.StarCount}}" nginx $ docker search --format "{{.Name}}: {{.StarCount}}" nginx
nginx: 5441 nginx: 5441
@ -171,7 +172,7 @@ maxexcloo/nginx: 7
This example outputs a table format: This example outputs a table format:
```bash ```console
$ docker search --format "table {{.Name}}\t{{.IsAutomated}}\t{{.IsOfficial}}" nginx $ docker search --format "table {{.Name}}\t{{.IsAutomated}}\t{{.IsOfficial}}" nginx
NAME AUTOMATED OFFICIAL NAME AUTOMATED OFFICIAL

View File

@ -33,8 +33,8 @@ For detailed information about using secrets, refer to [manage sensitive data wi
### Create a secret ### Create a secret
```bash ```console
$ printf <secret> | docker secret create my_secret - $ printf "my super secret password" | docker secret create my_secret -
onakdyv307se2tl7nl20anokv onakdyv307se2tl7nl20anokv
@ -46,7 +46,7 @@ onakdyv307se2tl7nl20anokv my_secret 6 seconds ago 6 seconds ag
### Create a secret with a file ### Create a secret with a file
```bash ```console
$ docker secret create my_secret ./secret.json $ docker secret create my_secret ./secret.json
dg426haahpi5ezmkkj5kyl3sn dg426haahpi5ezmkkj5kyl3sn
@ -59,15 +59,16 @@ dg426haahpi5ezmkkj5kyl3sn my_secret 7 seconds ago 7 seconds ag
### Create a secret with labels ### Create a secret with labels
```bash ```console
$ docker secret create --label env=dev \ $ docker secret create \
--label rev=20170324 \ --label env=dev \
my_secret ./secret.json --label rev=20170324 \
my_secret ./secret.json
eo7jnzguqgtpdah3cm5srfb97 eo7jnzguqgtpdah3cm5srfb97
``` ```
```bash ```console
$ docker secret inspect my_secret $ docker secret inspect my_secret
[ [

View File

@ -43,14 +43,14 @@ You can inspect a secret, either by its *name*, or *ID*
For example, given the following secret: For example, given the following secret:
```bash ```console
$ docker secret ls $ docker secret ls
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
eo7jnzguqgtpdah3cm5srfb97 my_secret 3 minutes ago 3 minutes ago eo7jnzguqgtpdah3cm5srfb97 my_secret 3 minutes ago 3 minutes ago
``` ```
```bash ```console
$ docker secret inspect secret.json $ docker secret inspect secret.json
``` ```
@ -82,7 +82,7 @@ You can use the --format option to obtain specific information about a
secret. The following example command outputs the creation time of the secret. The following example command outputs the creation time of the
secret. secret.
```bash ```console
$ docker secret inspect --format='{{.CreatedAt}}' eo7jnzguqgtpdah3cm5srfb97 $ docker secret inspect --format='{{.CreatedAt}}' eo7jnzguqgtpdah3cm5srfb97
2017-03-24 08:15:09.735271783 +0000 UTC 2017-03-24 08:15:09.735271783 +0000 UTC

View File

@ -36,7 +36,7 @@ For detailed information about using secrets, refer to [manage sensitive data wi
## Examples ## Examples
```bash ```console
$ docker secret ls $ docker secret ls
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
@ -60,7 +60,7 @@ The currently supported filters are:
The `id` filter matches all or prefix of a secret's id. The `id` filter matches all or prefix of a secret's id.
```bash ```console
$ docker secret ls -f "id=6697bflskwj1998km1gnnjr38" $ docker secret ls -f "id=6697bflskwj1998km1gnnjr38"
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
@ -75,7 +75,7 @@ a `label` and a value.
The following filter matches all secrets with a `project` label regardless of The following filter matches all secrets with a `project` label regardless of
its value: its value:
```bash ```console
$ docker secret ls --filter label=project $ docker secret ls --filter label=project
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
@ -85,7 +85,7 @@ mem02h8n73mybpgqjf0kfi1n0 test_secret About an hour ago Abou
The following filter matches only services with the `project` label with the The following filter matches only services with the `project` label with the
`project-a` value. `project-a` value.
```bash ```console
$ docker service ls --filter label=project=test $ docker service ls --filter label=project=test
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
@ -98,7 +98,7 @@ The `name` filter matches on all or prefix of a secret's name.
The following filter matches secret with a name containing a prefix of `test`. The following filter matches secret with a name containing a prefix of `test`.
```bash ```console
$ docker secret ls --filter name=test_secret $ docker secret ls --filter name=test_secret
ID NAME CREATED UPDATED ID NAME CREATED UPDATED
@ -128,7 +128,7 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`ID` and `Name` entries separated by a colon (`:`) for all images: `ID` and `Name` entries separated by a colon (`:`) for all images:
```bash ```console
$ docker secret ls --format "{{.ID}}: {{.Name}}" $ docker secret ls --format "{{.ID}}: {{.Name}}"
77af4d6b9913: secret-1 77af4d6b9913: secret-1
@ -139,7 +139,7 @@ b6fa739cedf5: secret-2
To list all secrets with their name and created date in a table format you To list all secrets with their name and created date in a table format you
can use: can use:
```bash ```console
$ docker secret ls --format "table {{.ID}}\t{{.Name}}\t{{.CreatedAt}}" $ docker secret ls --format "table {{.ID}}\t{{.Name}}\t{{.CreatedAt}}"
ID NAME CREATED ID NAME CREATED

View File

@ -35,7 +35,7 @@ For detailed information about using secrets, refer to [manage sensitive data wi
This example removes a secret: This example removes a secret:
```bash ```console
$ docker secret rm secret.json $ docker secret rm secret.json
sapth4csdo5b6wz2p5uimh5xg sapth4csdo5b6wz2p5uimh5xg
``` ```

View File

@ -101,7 +101,7 @@ Creates a service as described by the specified parameters.
### Create a service ### Create a service
```bash ```console
$ docker service create --name redis redis:3.0.6 $ docker service create --name redis redis:3.0.6
dmu1ept4cxcfe8k8lhtux3ro3 dmu1ept4cxcfe8k8lhtux3ro3
@ -124,7 +124,7 @@ If your image is available on a private registry which requires login, use the
your image is stored on `registry.example.com`, which is a private registry, use your image is stored on `registry.example.com`, which is a private registry, use
a command like the following: a command like the following:
```bash ```console
$ docker login registry.example.com $ docker login registry.example.com
$ docker service create \ $ docker service create \
@ -142,7 +142,7 @@ nodes are able to log into the registry and pull the image.
Use the `--replicas` flag to set the number of replica tasks for a replicated Use the `--replicas` flag to set the number of replica tasks for a replicated
service. The following command creates a `redis` service with `5` replica tasks: service. The following command creates a `redis` service with `5` replica tasks:
```bash ```console
$ docker service create --name redis --replicas=5 redis:3.0.6 $ docker service create --name redis --replicas=5 redis:3.0.6
4cdgfyky7ozwh3htjfw0d12qv 4cdgfyky7ozwh3htjfw0d12qv
@ -156,7 +156,7 @@ of replica tasks for the service.
In the following example the desired state is `5` replicas, but the current In the following example the desired state is `5` replicas, but the current
number of `RUNNING` tasks is `3`: number of `RUNNING` tasks is `3`:
```bash ```console
$ docker service ls $ docker service ls
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE
@ -166,7 +166,7 @@ ID NAME MODE REPLICAS IMAGE
Once all the tasks are created and `RUNNING`, the actual number of tasks is Once all the tasks are created and `RUNNING`, the actual number of tasks is
equal to the desired number: equal to the desired number:
```bash ```console
$ docker service ls $ docker service ls
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE
@ -180,7 +180,7 @@ Use the `--secret` flag to give a container access to a
Create a service specifying a secret: Create a service specifying a secret:
```bash ```console
$ docker service create --name redis --secret secret.json redis:3.0.6 $ docker service create --name redis --secret secret.json redis:3.0.6
4cdgfyky7ozwh3htjfw0d12qv 4cdgfyky7ozwh3htjfw0d12qv
@ -188,7 +188,7 @@ $ docker service create --name redis --secret secret.json redis:3.0.6
Create a service specifying the secret, target, user/group ID, and mode: Create a service specifying the secret, target, user/group ID, and mode:
```bash ```console
$ docker service create --name redis \ $ docker service create --name redis \
--secret source=ssh-key,target=ssh \ --secret source=ssh-key,target=ssh \
--secret source=app-key,target=app,uid=1000,gid=1001,mode=0400 \ --secret source=app-key,target=app,uid=1000,gid=1001,mode=0400 \
@ -217,13 +217,13 @@ as numerical IDs or names. When using names, the provided group/user names must
pre-exist in the container. The `mode` is specified as a 4-number sequence such pre-exist in the container. The `mode` is specified as a 4-number sequence such
as `0755`. as `0755`.
```bash ```console
$ docker service create --name=redis --config redis-conf redis:3.0.6 $ docker service create --name=redis --config redis-conf redis:3.0.6
``` ```
Create a service with a config and specify the target location and file mode: Create a service with a config and specify the target location and file mode:
```bash ```console
$ docker service create --name redis \ $ docker service create --name redis \
--config source=redis-conf,target=/etc/redis/redis.conf,mode=0400 redis:3.0.6 --config source=redis-conf,target=/etc/redis/redis.conf,mode=0400 redis:3.0.6
``` ```
@ -236,7 +236,7 @@ the container. If a target is specified, that is used as the filename.
### Create a service with a rolling update policy ### Create a service with a rolling update policy
```bash ```console
$ docker service create \ $ docker service create \
--replicas 10 \ --replicas 10 \
--name redis \ --name redis \
@ -254,7 +254,7 @@ tutorial](https://docs.docker.com/engine/swarm/swarm-tutorial/rolling-update/).
This sets an environment variable for all tasks in a service. For example: This sets an environment variable for all tasks in a service. For example:
```bash ```console
$ docker service create \ $ docker service create \
--name redis_2 \ --name redis_2 \
--replicas 5 \ --replicas 5 \
@ -265,7 +265,7 @@ $ docker service create \
To specify multiple environment variables, specify multiple `--env` flags, each To specify multiple environment variables, specify multiple `--env` flags, each
with a separate key-value pair. with a separate key-value pair.
```bash ```console
$ docker service create \ $ docker service create \
--name redis_2 \ --name redis_2 \
--replicas 5 \ --replicas 5 \
@ -279,7 +279,7 @@ $ docker service create \
This option sets the docker service containers hostname to a specific string. This option sets the docker service containers hostname to a specific string.
For example: For example:
```bash ```console
$ docker service create --name redis --hostname myredis redis:3.0.6 $ docker service create --name redis --hostname myredis redis:3.0.6
``` ```
@ -288,7 +288,7 @@ $ docker service create --name redis --hostname myredis redis:3.0.6
A label is a `key=value` pair that applies metadata to a service. To label a A label is a `key=value` pair that applies metadata to a service. To label a
service with two labels: service with two labels:
```bash ```console
$ docker service create \ $ docker service create \
--name redis_2 \ --name redis_2 \
--label com.example.foo="bar" --label com.example.foo="bar"
@ -592,7 +592,7 @@ or `--volume` flag for `docker run`, with some important exceptions:
The following example creates a service that uses a named volume: The following example creates a service that uses a named volume:
```bash ```console
$ docker service create \ $ docker service create \
--name my-service \ --name my-service \
--replicas 3 \ --replicas 3 \
@ -622,7 +622,7 @@ be deployed on a different node.
The following command creates a service with three replicas with an anonymous The following command creates a service with three replicas with an anonymous
volume on `/path/in/container`: volume on `/path/in/container`:
```bash ```console
$ docker service create \ $ docker service create \
--name my-service \ --name my-service \
--replicas 3 \ --replicas 3 \
@ -640,7 +640,7 @@ the task using them is complete.
The following example bind-mounts a host directory at `/path/in/container` in The following example bind-mounts a host directory at `/path/in/container` in
the containers backing the service: the containers backing the service:
```bash ```console
$ docker service create \ $ docker service create \
--name my-service \ --name my-service \
--mount type=bind,source=/path/on/host,destination=/path/in/container \ --mount type=bind,source=/path/on/host,destination=/path/in/container \
@ -655,7 +655,7 @@ service runs on each active node in the swarm.
The following command creates a global service: The following command creates a global service:
```bash ```console
$ docker service create \ $ docker service create \
--name redis_2 \ --name redis_2 \
--mode global \ --mode global \
@ -688,7 +688,7 @@ the [`docker node update`](node_update.md) command.
For example, the following limits tasks for the redis service to nodes where the For example, the following limits tasks for the redis service to nodes where the
node type label equals queue: node type label equals queue:
```bash ```console
$ docker service create \ $ docker service create \
--name redis_2 \ --name redis_2 \
--constraint node.platform.os==linux \ --constraint node.platform.os==linux \
@ -703,7 +703,7 @@ loop and deploy the service once a suitable node becomes available.
In the example below, no node satisfying the constraint was found, causing the In the example below, no node satisfying the constraint was found, causing the
service to not reconcile with the desired state: service to not reconcile with the desired state:
```bash ```console
$ docker service create \ $ docker service create \
--name web \ --name web \
--constraint node.labels.region==east \ --constraint node.labels.region==east \
@ -721,7 +721,7 @@ b6lww17hrr4e web replicated 0/1 nginx:alpine
After adding the `region=east` label to a node in the cluster, the service After adding the `region=east` label to a node in the cluster, the service
reconciles, and the desired number of replicas are deployed: reconciles, and the desired number of replicas are deployed:
```bash ```console
$ docker node update --label-add region=east yswe2dm4c5fdgtsrli1e8ya5l $ docker node update --label-add region=east yswe2dm4c5fdgtsrli1e8ya5l
yswe2dm4c5fdgtsrli1e8ya5l yswe2dm4c5fdgtsrli1e8ya5l
@ -736,7 +736,7 @@ You can set up the service to divide tasks evenly over different categories of
nodes. One example of where this can be useful is to balance tasks over a set nodes. One example of where this can be useful is to balance tasks over a set
of datacenters or availability zones. The example below illustrates this: of datacenters or availability zones. The example below illustrates this:
```bash ```console
$ docker service create \ $ docker service create \
--replicas 9 \ --replicas 9 \
--name redis_2 \ --name redis_2 \
@ -787,7 +787,7 @@ The following example sets up a service with multiple placement preferences.
Tasks are spread first over the various datacenters, and then over racks Tasks are spread first over the various datacenters, and then over racks
(as indicated by the respective labels): (as indicated by the respective labels):
```bash ```console
$ docker service create \ $ docker service create \
--replicas 9 \ --replicas 9 \
--name redis_2 \ --name redis_2 \
@ -812,7 +812,7 @@ pending state.
The following example requires that 4GB of memory be available and reservable The following example requires that 4GB of memory be available and reservable
on a given node before scheduling the service to run on that node. on a given node before scheduling the service to run on that node.
```bash ```console
$ docker service create --reserve-memory=4GB --name=too-big nginx:alpine $ docker service create --reserve-memory=4GB --name=too-big nginx:alpine
``` ```
@ -825,7 +825,7 @@ given amount of memory on a node. This example limits the amount of memory used
by the task to 4GB. The task will be scheduled even if each of your nodes has by the task to 4GB. The task will be scheduled even if each of your nodes has
only 2GB of memory, because `--limit-memory` is an upper limit. only 2GB of memory, because `--limit-memory` is an upper limit.
```bash ```console
$ docker service create --limit-memory=4GB --name=too-big nginx:alpine $ docker service create --limit-memory=4GB --name=too-big nginx:alpine
``` ```
@ -880,7 +880,7 @@ maintenance or datacenter failure.
The example below illustrates this: The example below illustrates this:
```bash ```console
$ docker service create \ $ docker service create \
--name nginx \ --name nginx \
--replicas 2 \ --replicas 2 \
@ -896,7 +896,7 @@ You can use overlay networks to connect one or more services within the swarm.
First, create an overlay network on a manager node the docker network create First, create an overlay network on a manager node the docker network create
command: command:
```bash ```console
$ docker network create --driver overlay my-network $ docker network create --driver overlay my-network
etjpu59cykrptrgw0z0hk5snf etjpu59cykrptrgw0z0hk5snf
@ -908,7 +908,7 @@ access to the network.
When you create a service and pass the `--network` flag to attach the service to When you create a service and pass the `--network` flag to attach the service to
the overlay network: the overlay network:
```bash ```console
$ docker service create \ $ docker service create \
--replicas 3 \ --replicas 3 \
--network my-network \ --network my-network \
@ -933,7 +933,7 @@ using the `--publish` flag. The `--publish` flag can take two different styles
of arguments. The short version is positional, and allows you to specify the of arguments. The short version is positional, and allows you to specify the
published port and target port separated by a colon (`:`). published port and target port separated by a colon (`:`).
```bash ```console
$ docker service create --name my_web --replicas 3 --publish 8080:80 nginx $ docker service create --name my_web --replicas 3 --publish 8080:80 nginx
``` ```
@ -942,7 +942,7 @@ more options. The long format is preferred. You cannot specify the service's
mode when using the short format. Here is an example of using the long format mode when using the short format. Here is an example of using the long format
for the same service as above: for the same service as above:
```bash ```console
$ docker service create --name my_web --replicas 3 --publish published=8080,target=80 nginx $ docker service create --name my_web --replicas 3 --publish published=8080,target=80 nginx
``` ```
@ -1074,7 +1074,7 @@ Valid placeholders for the Go template are listed below:
In this example, we are going to set the template of the created containers based on the In this example, we are going to set the template of the created containers based on the
service's name, the node's ID and hostname where it sits. service's name, the node's ID and hostname where it sits.
```bash ```console
$ docker service create \ $ docker service create \
--name hosttempl \ --name hosttempl \
--hostname="{{.Node.Hostname}}-{{.Node.ID}}-{{.Service.Name}}"\ --hostname="{{.Node.Hostname}}-{{.Node.ID}}-{{.Service.Name}}"\
@ -1098,7 +1098,7 @@ By default, tasks scheduled on Windows nodes are run using the default isolation
configured for this particular node. To force a specific isolation mode, you can use configured for this particular node. To force a specific isolation mode, you can use
the `--isolation` flag: the `--isolation` flag:
```bash ```console
$ docker service create --name myservice --isolation=process microsoft/nanoserver $ docker service create --name myservice --isolation=process microsoft/nanoserver
``` ```
@ -1112,7 +1112,7 @@ Supported isolation modes on Windows are:
You can narrow the kind of nodes your task can land on through the using the You can narrow the kind of nodes your task can land on through the using the
`--generic-resource` flag (if the nodes advertise these resources): `--generic-resource` flag (if the nodes advertise these resources):
```bash ```console
$ docker service create \ $ docker service create \
--name cuda \ --name cuda \
--generic-resource "NVIDIA-GPU=2" \ --generic-resource "NVIDIA-GPU=2" \
@ -1129,7 +1129,7 @@ belonging to a job exits successfully (return value 0), the Task is marked as
Jobs are started by using one of two modes, `replicated-job` or `global-job` Jobs are started by using one of two modes, `replicated-job` or `global-job`
```bash ```console
$ docker service create --name myjob \ $ docker service create --name myjob \
--mode replicated-job \ --mode replicated-job \
bash "true" bash "true"
@ -1159,12 +1159,13 @@ By default, all replicas of a replicated job will launch at once. To control
the total number of replicas that are executing simultaneously at any one time, the total number of replicas that are executing simultaneously at any one time,
the `--max-concurrent` flag can be used: the `--max-concurrent` flag can be used:
```bash ```console
$ docker service create --name mythrottledjob \ $ docker service create \
--mode replicated-job \ --name mythrottledjob \
--replicas 10 \ --mode replicated-job \
--max-concurrent 2 \ --replicas 10 \
bash "true" --max-concurrent 2 \
bash "true"
``` ```
The above command will execute 10 Tasks in total, but only 2 of them will be The above command will execute 10 Tasks in total, but only 2 of them will be

View File

@ -42,7 +42,7 @@ You can inspect a service, either by its *name*, or *ID*
For example, given the following service; For example, given the following service;
```bash ```console
$ docker service ls $ docker service ls
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE
dmu1ept4cxcf redis replicated 3/3 redis:3.0.6 dmu1ept4cxcf redis replicated 3/3 redis:3.0.6
@ -51,7 +51,7 @@ dmu1ept4cxcf redis replicated 3/3 redis:3.0.6
Both `docker service inspect redis`, and `docker service inspect dmu1ept4cxcf` Both `docker service inspect redis`, and `docker service inspect dmu1ept4cxcf`
produce the same result: produce the same result:
```bash ```console
$ docker service inspect redis $ docker service inspect redis
``` ```
@ -99,7 +99,7 @@ The output is in JSON format, for example:
] ]
``` ```
```bash ```console
$ docker service inspect dmu1ept4cxcf $ docker service inspect dmu1ept4cxcf
[ [
@ -118,7 +118,7 @@ $ docker service inspect dmu1ept4cxcf
You can print the inspect output in a human-readable format instead of the default You can print the inspect output in a human-readable format instead of the default
JSON output, by using the `--pretty` option: JSON output, by using the `--pretty` option:
```bash ```console
$ docker service inspect --pretty frontend $ docker service inspect --pretty frontend
ID: c8wgl7q4ndfd52ni6qftkvnnp ID: c8wgl7q4ndfd52ni6qftkvnnp
@ -153,7 +153,7 @@ The `--format` option can be used to obtain specific information about a
service. For example, the following command outputs the number of replicas service. For example, the following command outputs the number of replicas
of the "redis" service. of the "redis" service.
```bash ```console
$ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis $ docker service inspect --format='{{.Spec.Mode.Replicated.Replicas}}' redis
10 10

View File

@ -36,7 +36,7 @@ This command lists services are running in the swarm.
On a manager node: On a manager node:
```bash ```console
$ docker service ls $ docker service ls
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE
@ -67,7 +67,7 @@ The currently supported filters are:
The `id` filter matches all or part of a service's id. The `id` filter matches all or part of a service's id.
```bash ```console
$ docker service ls -f "id=0bcjw" $ docker service ls -f "id=0bcjw"
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE
0bcjwfh8ychr redis replicated 1/1 redis:3.0.6 0bcjwfh8ychr redis replicated 1/1 redis:3.0.6
@ -81,7 +81,7 @@ a `label` and a value.
The following filter matches all services with a `project` label regardless of The following filter matches all services with a `project` label regardless of
its value: its value:
```bash ```console
$ docker service ls --filter label=project $ docker service ls --filter label=project
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE
01sl1rp6nj5u frontend2 replicated 1/1 nginx:alpine 01sl1rp6nj5u frontend2 replicated 1/1 nginx:alpine
@ -92,7 +92,7 @@ ID NAME MODE REPLICAS IMAGE
The following filter matches only services with the `project` label with the The following filter matches only services with the `project` label with the
`project-a` value. `project-a` value.
```bash ```console
$ docker service ls --filter label=project=project-a $ docker service ls --filter label=project=project-a
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE
36xvvwwauej0 frontend replicated 5/5 nginx:alpine 36xvvwwauej0 frontend replicated 5/5 nginx:alpine
@ -105,7 +105,7 @@ The `mode` filter matches on the mode (either `replicated` or `global`) of a ser
The following filter matches only `global` services. The following filter matches only `global` services.
```bash ```console
$ docker service ls --filter mode=global $ docker service ls --filter mode=global
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE
w7y0v2yrn620 top global 1/1 busybox w7y0v2yrn620 top global 1/1 busybox
@ -117,7 +117,7 @@ The `name` filter matches on all or part of a service's name.
The following filter matches services with a name containing `redis`. The following filter matches services with a name containing `redis`.
```bash ```console
$ docker service ls --filter name=redis $ docker service ls --filter name=redis
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE
0bcjwfh8ychr redis replicated 1/1 redis:3.0.6 0bcjwfh8ychr redis replicated 1/1 redis:3.0.6
@ -146,7 +146,7 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`ID`, `Mode`, and `Replicas` entries separated by a colon (`:`) for all services: `ID`, `Mode`, and `Replicas` entries separated by a colon (`:`) for all services:
```bash ```console
$ docker service ls --format "{{.ID}}: {{.Mode}} {{.Replicas}}" $ docker service ls --format "{{.ID}}: {{.Mode}} {{.Replicas}}"
0zmvwuiu3vue: replicated 10/10 0zmvwuiu3vue: replicated 10/10

View File

@ -38,7 +38,7 @@ Lists the tasks that are running as part of the specified services.
The following command shows all the tasks that are part of the `redis` service: The following command shows all the tasks that are part of the `redis` service:
```bash ```console
$ docker service ps redis $ docker service ps redis
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
@ -58,7 +58,7 @@ In addition to _running_ tasks, the output also shows the task history. For
example, after updating the service to use the `redis:3.0.6` image, the output example, after updating the service to use the `redis:3.0.6` image, the output
may look like this: may look like this:
```bash ```console
$ docker service ps redis $ docker service ps redis
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
@ -83,7 +83,7 @@ image, and pins the service to that digest. The digest is not shown by
default, but is printed if `--no-trunc` is used. The `--no-trunc` option default, but is printed if `--no-trunc` is used. The `--no-trunc` option
also shows the non-truncated task ID, and error-messages, as can be seen below; also shows the non-truncated task ID, and error-messages, as can be seen below;
```bash ```console
$ docker service ps --no-trunc redis $ docker service ps --no-trunc redis
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
@ -112,7 +112,7 @@ The currently supported filters are:
The `id` filter matches on all or a prefix of a task's ID. The `id` filter matches on all or a prefix of a task's ID.
```bash ```console
$ docker service ps -f "id=8" redis $ docker service ps -f "id=8" redis
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
@ -124,8 +124,9 @@ ID NAME IMAGE NODE DESIRED STATE CURRENT STATE
The `name` filter matches on task names. The `name` filter matches on task names.
```bash ```console
$ docker service ps -f "name=redis.1" redis $ docker service ps -f "name=redis.1" redis
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
qihejybwf1x5 redis.1 redis:3.0.6 manager1 Running Running 8 seconds qihejybwf1x5 redis.1 redis:3.0.6 manager1 Running Running 8 seconds
``` ```
@ -135,8 +136,9 @@ qihejybwf1x5 redis.1 redis:3.0.6 manager1 Running Running 8 seconds
The `node` filter matches on a node name or a node ID. The `node` filter matches on a node name or a node ID.
```bash ```console
$ docker service ps -f "node=manager1" redis $ docker service ps -f "node=manager1" redis
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
0qihejybwf1x redis.1 redis:3.0.6 manager1 Running Running 8 seconds 0qihejybwf1x redis.1 redis:3.0.6 manager1 Running Running 8 seconds
1x0v8yomsncd redis.5 redis:3.0.6 manager1 Running Running 8 seconds 1x0v8yomsncd redis.5 redis:3.0.6 manager1 Running Running 8 seconds
@ -173,8 +175,9 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`Name` and `Image` entries separated by a colon (`:`) for all tasks: `Name` and `Image` entries separated by a colon (`:`) for all tasks:
```bash ```console
$ docker service ps --format "{{.Name}}: {{.Image}}" top $ docker service ps --format "{{.Name}}: {{.Image}}" top
top.1: busybox top.1: busybox
top.2: busybox top.2: busybox
top.3: busybox top.3: busybox

View File

@ -33,7 +33,7 @@ Removes the specified services from the swarm.
Remove the `redis` service: Remove the `redis` service:
```bash ```console
$ docker service rm redis $ docker service rm redis
redis redis

View File

@ -43,13 +43,13 @@ previous version, having one replica.
Create a service with a single replica: Create a service with a single replica:
```bash ```console
$ docker service create --name my-service -p 8080:80 nginx:alpine $ docker service create --name my-service -p 8080:80 nginx:alpine
``` ```
Confirm that the service is running with a single replica: Confirm that the service is running with a single replica:
```bash ```console
$ docker service ls $ docker service ls
ID NAME MODE REPLICAS IMAGE PORTS ID NAME MODE REPLICAS IMAGE PORTS
@ -58,7 +58,7 @@ xbw728mf6q0d my-service replicated 1/1
Update the service to use three replicas: Update the service to use three replicas:
```bash ```console
$ docker service update --replicas=3 my-service $ docker service update --replicas=3 my-service
$ docker service ls $ docker service ls
@ -70,7 +70,7 @@ xbw728mf6q0d my-service replicated 3/3
Now roll back the service to its previous version, and confirm it is Now roll back the service to its previous version, and confirm it is
running a single replica again: running a single replica again:
```bash ```console
$ docker service rollback my-service $ docker service rollback my-service
$ docker service ls $ docker service ls

View File

@ -37,7 +37,7 @@ service while keeping the service active in the swarm you can set the scale to 0
The following command scales the "frontend" service to 50 tasks. The following command scales the "frontend" service to 50 tasks.
```bash ```console
$ docker service scale frontend=50 $ docker service scale frontend=50
frontend scaled to 50 frontend scaled to 50
@ -45,7 +45,7 @@ frontend scaled to 50
The following command tries to scale a global service to 10 tasks and returns an error. The following command tries to scale a global service to 10 tasks and returns an error.
```bash ```console
$ docker service create --mode global --name backend backend:latest $ docker service create --mode global --name backend backend:latest
b4g08uwuairexjub6ome6usqh b4g08uwuairexjub6ome6usqh
@ -58,7 +58,7 @@ backend: scale can only be used with replicated or replicated-job mode
Directly afterwards, run `docker service ls`, to see the actual number of Directly afterwards, run `docker service ls`, to see the actual number of
replicas. replicas.
```bash ```console
$ docker service ls --filter name=frontend $ docker service ls --filter name=frontend
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE
@ -68,7 +68,7 @@ ID NAME MODE REPLICAS IMAGE
You can also scale a service using the [`docker service update`](service_update.md) You can also scale a service using the [`docker service update`](service_update.md)
command. The following commands are equivalent: command. The following commands are equivalent:
```bash ```console
$ docker service scale frontend=50 $ docker service scale frontend=50
$ docker service update --replicas=50 frontend $ docker service update --replicas=50 frontend
``` ```
@ -79,7 +79,7 @@ The `docker service scale` command allows you to set the desired number of
tasks for multiple services at once. The following example scales both the tasks for multiple services at once. The following example scales both the
backend and frontend services: backend and frontend services:
```bash ```console
$ docker service scale backend=3 frontend=5 $ docker service scale backend=3 frontend=5
backend scaled to 3 backend scaled to 3

View File

@ -127,13 +127,13 @@ rolling restart without any changes to the service parameters.
### Update a service ### Update a service
```bash ```console
$ docker service update --limit-cpu 2 redis $ docker service update --limit-cpu 2 redis
``` ```
### Perform a rolling restart with no parameter changes ### Perform a rolling restart with no parameter changes
```bash ```console
$ docker service update --force --update-parallelism 1 --update-delay 30s redis $ docker service update --force --update-parallelism 1 --update-delay 30s redis
``` ```
@ -161,7 +161,7 @@ service name.
- The `--mount-rm` flag takes the `target` path of the mount. - The `--mount-rm` flag takes the `target` path of the mount.
```bash ```console
$ docker service create \ $ docker service create \
--name=myservice \ --name=myservice \
--mount type=volume,source=test-data,target=/somewhere \ --mount type=volume,source=test-data,target=/somewhere \
@ -189,7 +189,7 @@ reference.
The following example adds a published service port to an existing service. The following example adds a published service port to an existing service.
```bash ```console
$ docker service update \ $ docker service update \
--publish-add published=8080,target=80 \ --publish-add published=8080,target=80 \
myservice myservice
@ -204,7 +204,7 @@ reference.
The following example adds a new alias name to an existing service already connected to network my-network: The following example adds a new alias name to an existing service already connected to network my-network:
```bash ```console
$ docker service update \ $ docker service update \
--network-rm my-network \ --network-rm my-network \
--network-add name=my-network,alias=web1 \ --network-add name=my-network,alias=web1 \
@ -219,7 +219,7 @@ This will revert the service to the configuration that was in place before the m
The following example updates the number of replicas for the service from 4 to 5, and then rolls back to the previous configuration. The following example updates the number of replicas for the service from 4 to 5, and then rolls back to the previous configuration.
```bash ```console
$ docker service update --replicas=5 web $ docker service update --replicas=5 web
web web
@ -230,9 +230,10 @@ ID NAME MODE REPLICAS IMAGE
80bvrzp6vxf3 web replicated 0/5 nginx:alpine 80bvrzp6vxf3 web replicated 0/5 nginx:alpine
``` ```
Roll back the `web` service... Roll back the `web` service...
```bash ```console
$ docker service update --rollback web $ docker service update --rollback web
web web
@ -246,7 +247,7 @@ ID NAME MODE REPLICAS IMAGE
Other options can be combined with `--rollback` as well, for example, `--update-delay 0s` to execute the rollback without a delay between tasks: Other options can be combined with `--rollback` as well, for example, `--update-delay 0s` to execute the rollback without a delay between tasks:
```bash ```console
$ docker service update \ $ docker service update \
--rollback \ --rollback \
--update-delay 0s --update-delay 0s
@ -283,7 +284,7 @@ secrets.
The following example adds a secret named `ssh-2` and removes `ssh-1`: The following example adds a secret named `ssh-2` and removes `ssh-1`:
```bash ```console
$ docker service update \ $ docker service update \
--secret-add source=ssh-2,target=ssh-2 \ --secret-add source=ssh-2,target=ssh-2 \
--secret-rm ssh-1 \ --secret-rm ssh-1 \

View File

@ -43,7 +43,7 @@ Create and update a stack from a `compose` file on the swarm.
The `deploy` command supports compose file version `3.0` and above. The `deploy` command supports compose file version `3.0` and above.
```bash ```console
$ docker stack deploy --compose-file docker-compose.yml vossibility $ docker stack deploy --compose-file docker-compose.yml vossibility
Ignoring unsupported options: links Ignoring unsupported options: links
@ -60,7 +60,7 @@ Creating service vossibility_lookupd
The Compose file can also be provided as standard input with `--compose-file -`: The Compose file can also be provided as standard input with `--compose-file -`:
```bash ```console
$ cat docker-compose.yml | docker stack deploy --compose-file - vossibility $ cat docker-compose.yml | docker stack deploy --compose-file - vossibility
Ignoring unsupported options: links Ignoring unsupported options: links
@ -79,7 +79,7 @@ If your configuration is split between multiple Compose files, e.g. a base
configuration and environment-specific overrides, you can provide multiple configuration and environment-specific overrides, you can provide multiple
`--compose-file` flags. `--compose-file` flags.
```bash ```console
$ docker stack deploy --compose-file docker-compose.yml -c docker-compose.prod.yml vossibility $ docker stack deploy --compose-file docker-compose.yml -c docker-compose.prod.yml vossibility
Ignoring unsupported options: links Ignoring unsupported options: links
@ -96,7 +96,7 @@ Creating service vossibility_lookupd
You can verify that the services were correctly created: You can verify that the services were correctly created:
```bash ```console
$ docker service ls $ docker service ls
ID NAME MODE REPLICAS IMAGE ID NAME MODE REPLICAS IMAGE

View File

@ -37,7 +37,7 @@ Lists the stacks.
The following command shows all stacks and some additional information: The following command shows all stacks and some additional information:
```bash ```console
$ docker stack ls $ docker stack ls
ID SERVICES ORCHESTRATOR ID SERVICES ORCHESTRATOR
@ -65,7 +65,7 @@ the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`Name` and `Services` entries separated by a colon (`:`) for all stacks: `Name` and `Services` entries separated by a colon (`:`) for all stacks:
```bash ```console
$ docker stack ls --format "{{.Name}}: {{.Services}}" $ docker stack ls --format "{{.Name}}: {{.Services}}"
web-server: 1 web-server: 1
web-cache: 4 web-cache: 4

View File

@ -40,8 +40,9 @@ Lists the tasks that are running as part of the specified stack.
The following command shows all the tasks that are part of the `voting` stack: The following command shows all the tasks that are part of the `voting` stack:
```bash ```console
$ docker stack ps voting $ docker stack ps voting
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
xim5bcqtgk1b voting_worker.1 dockersamples/examplevotingapp_worker:latest node2 Running Running 2 minutes ago xim5bcqtgk1b voting_worker.1 dockersamples/examplevotingapp_worker:latest node2 Running Running 2 minutes ago
q7yik0ks1in6 voting_result.1 dockersamples/examplevotingapp_result:before node1 Running Running 2 minutes ago q7yik0ks1in6 voting_result.1 dockersamples/examplevotingapp_result:before node1 Running Running 2 minutes ago
@ -71,8 +72,9 @@ The currently supported filters are:
The `id` filter matches on all or a prefix of a task's ID. The `id` filter matches on all or a prefix of a task's ID.
```bash ```console
$ docker stack ps -f "id=t" voting $ docker stack ps -f "id=t" voting
ID NAME IMAGE NODE DESIRED STATE CURRENTSTATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENTSTATE ERROR PORTS
tz6j82jnwrx7 voting_db.1 postgres:9.4 node1 Running Running 14 minutes ago tz6j82jnwrx7 voting_db.1 postgres:9.4 node1 Running Running 14 minutes ago
t72q3z038jeh voting_redis.2 redis:alpine node3 Running Running 14 minutes ago t72q3z038jeh voting_redis.2 redis:alpine node3 Running Running 14 minutes ago
@ -82,8 +84,9 @@ t72q3z038jeh voting_redis.2 redis:alpine node3 Running
The `name` filter matches on task names. The `name` filter matches on task names.
```bash ```console
$ docker stack ps -f "name=voting_redis" voting $ docker stack ps -f "name=voting_redis" voting
ID NAME IMAGE NODE DESIRED STATE CURRENTSTATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENTSTATE ERROR PORTS
w48spazhbmxc voting_redis.1 redis:alpine node2 Running Running 17 minutes ago w48spazhbmxc voting_redis.1 redis:alpine node2 Running Running 17 minutes ago
t72q3z038jeh voting_redis.2 redis:alpine node3 Running Running 17 minutes ago t72q3z038jeh voting_redis.2 redis:alpine node3 Running Running 17 minutes ago
@ -93,8 +96,9 @@ t72q3z038jeh voting_redis.2 redis:alpine node3 Running
The `node` filter matches on a node name or a node ID. The `node` filter matches on a node name or a node ID.
```bash ```console
$ docker stack ps -f "node=node1" voting $ docker stack ps -f "node=node1" voting
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
q7yik0ks1in6 voting_result.1 dockersamples/examplevotingapp_result:before node1 Running Running 18 minutes ago q7yik0ks1in6 voting_result.1 dockersamples/examplevotingapp_result:before node1 Running Running 18 minutes ago
tz6j82jnwrx7 voting_db.1 postgres:9.4 node1 Running Running 18 minutes ago tz6j82jnwrx7 voting_db.1 postgres:9.4 node1 Running Running 18 minutes ago
@ -105,8 +109,9 @@ tz6j82jnwrx7 voting_db.1 postgres:9.4
The `desired-state` filter can take the values `running`, `shutdown`, `ready` or `accepted`. The `desired-state` filter can take the values `running`, `shutdown`, `ready` or `accepted`.
```bash ```console
$ docker stack ps -f "desired-state=running" voting $ docker stack ps -f "desired-state=running" voting
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
xim5bcqtgk1b voting_worker.1 dockersamples/examplevotingapp_worker:latest node2 Running Running 21 minutes ago xim5bcqtgk1b voting_worker.1 dockersamples/examplevotingapp_worker:latest node2 Running Running 21 minutes ago
q7yik0ks1in6 voting_result.1 dockersamples/examplevotingapp_result:before node1 Running Running 21 minutes ago q7yik0ks1in6 voting_result.1 dockersamples/examplevotingapp_result:before node1 Running Running 21 minutes ago
@ -142,8 +147,9 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`Name` and `Image` entries separated by a colon (`:`) for all tasks: `Name` and `Image` entries separated by a colon (`:`) for all tasks:
```bash ```console
$ docker stack ps --format "{{.Name}}: {{.Image}}" voting $ docker stack ps --format "{{.Name}}: {{.Image}}" voting
voting_worker.1: dockersamples/examplevotingapp_worker:latest voting_worker.1: dockersamples/examplevotingapp_worker:latest
voting_result.1: dockersamples/examplevotingapp_result:before voting_result.1: dockersamples/examplevotingapp_result:before
voting_vote.1: dockersamples/examplevotingapp_vote:before voting_vote.1: dockersamples/examplevotingapp_vote:before
@ -158,8 +164,9 @@ voting_redis.2: redis:alpine
The `--no-resolve` option shows IDs for task name, without mapping IDs to Names. The `--no-resolve` option shows IDs for task name, without mapping IDs to Names.
```bash ```console
$ docker stack ps --no-resolve voting $ docker stack ps --no-resolve voting
ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS
xim5bcqtgk1b 10z9fjfqzsxnezo4hb81p8mqg.1 dockersamples/examplevotingapp_worker:latest qaqt4nrzo775jrx6detglho01 Running Running 30 minutes ago xim5bcqtgk1b 10z9fjfqzsxnezo4hb81p8mqg.1 dockersamples/examplevotingapp_worker:latest qaqt4nrzo775jrx6detglho01 Running Running 30 minutes ago
q7yik0ks1in6 hbxltua1na7mgqjnidldv5m65.1 dockersamples/examplevotingapp_result:before mxpaef1tlh23s052erw88a4w5 Running Running 30 minutes ago q7yik0ks1in6 hbxltua1na7mgqjnidldv5m65.1 dockersamples/examplevotingapp_result:before mxpaef1tlh23s052erw88a4w5 Running Running 30 minutes ago
@ -178,8 +185,9 @@ image, and pins the service to that digest. The digest is not shown by
default, but is printed if `--no-trunc` is used. The `--no-trunc` option default, but is printed if `--no-trunc` is used. The `--no-trunc` option
also shows the non-truncated task IDs, and error-messages, as can be seen below: also shows the non-truncated task IDs, and error-messages, as can be seen below:
```bash ```console
$ docker stack ps --no-trunc voting $ docker stack ps --no-trunc voting
ID NAME IMAGE NODE DESIRED STATE CURREN STATE ERROR PORTS ID NAME IMAGE NODE DESIRED STATE CURREN STATE ERROR PORTS
xim5bcqtgk1bxqz91jzo4a1s5 voting_worker.1 dockersamples/examplevotingapp_worker:latest@sha256:3e4ddf59c15f432280a2c0679c4fc5a2ee5a797023c8ef0d3baf7b1385e9fed node2 Running Runnin 32 minutes ago xim5bcqtgk1bxqz91jzo4a1s5 voting_worker.1 dockersamples/examplevotingapp_worker:latest@sha256:3e4ddf59c15f432280a2c0679c4fc5a2ee5a797023c8ef0d3baf7b1385e9fed node2 Running Runnin 32 minutes ago
q7yik0ks1in6kv32gg6y6yjf7 voting_result.1 dockersamples/examplevotingapp_result:before@sha256:83b56996e930c292a6ae5187fda84dd6568a19d97cdb933720be15c757b7463 node1 Running Runnin 32 minutes ago q7yik0ks1in6kv32gg6y6yjf7 voting_result.1 dockersamples/examplevotingapp_result:before@sha256:83b56996e930c292a6ae5187fda84dd6568a19d97cdb933720be15c757b7463 node1 Running Runnin 32 minutes ago
@ -196,7 +204,7 @@ t72q3z038jehe1wbh9gdum076 voting_redis.2 redis:alpine@sha256:9cd405cd1e
The `-q ` or `--quiet` option only shows IDs of the tasks in the stack. The `-q ` or `--quiet` option only shows IDs of the tasks in the stack.
This example outputs all task IDs of the "voting" stack; This example outputs all task IDs of the "voting" stack;
```bash ```console
$ docker stack ps -q voting $ docker stack ps -q voting
xim5bcqtgk1b xim5bcqtgk1b
q7yik0ks1in6 q7yik0ks1in6
@ -212,14 +220,14 @@ This option can be used to perform batch operations. For example, you can use
the task IDs as input for other commands, such as `docker inspect`. The the task IDs as input for other commands, such as `docker inspect`. The
following example inspects all tasks of the "voting" stack; following example inspects all tasks of the "voting" stack;
```bash ```console
$ docker inspect $(docker stack ps -q voting) $ docker inspect $(docker stack ps -q voting)
[ [
{ {
"ID": "xim5bcqtgk1b1gk0krq1", "ID": "xim5bcqtgk1b1gk0krq1",
"Version": { "Version": {
(...) <...>
``` ```
## Related commands ## Related commands

View File

@ -38,7 +38,7 @@ Remove the stack from the swarm.
This will remove the stack with the name `myapp`. Services, networks, and secrets associated with the stack will be removed. This will remove the stack with the name `myapp`. Services, networks, and secrets associated with the stack will be removed.
```bash ```console
$ docker stack rm myapp $ docker stack rm myapp
Removing service myapp_redis Removing service myapp_redis
@ -52,7 +52,7 @@ Removing network myapp_frontend
This will remove all the specified stacks, `myapp` and `vossibility`. Services, networks, and secrets associated with all the specified stacks will be removed. This will remove all the specified stacks, `myapp` and `vossibility`. Services, networks, and secrets associated with all the specified stacks will be removed.
```bash ```console
$ docker stack rm myapp vossibility $ docker stack rm myapp vossibility
Removing service myapp_redis Removing service myapp_redis

View File

@ -36,7 +36,7 @@ Lists the services that are running as part of the specified stack.
The following command shows all services in the `myapp` stack: The following command shows all services in the `myapp` stack:
```bash ```console
$ docker stack services myapp $ docker stack services myapp
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE COMMAND
@ -52,7 +52,7 @@ Multiple filter flags are combined as an `OR` filter.
The following command shows both the `web` and `db` services: The following command shows both the `web` and `db` services:
```bash ```console
$ docker stack services --filter name=myapp_web --filter name=myapp_db myapp $ docker stack services --filter name=myapp_web --filter name=myapp_db myapp
ID NAME REPLICAS IMAGE COMMAND ID NAME REPLICAS IMAGE COMMAND
@ -103,7 +103,7 @@ output the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`ID`, `Mode`, and `Replicas` entries separated by a colon (`:`) for all services: `ID`, `Mode`, and `Replicas` entries separated by a colon (`:`) for all services:
```bash ```console
$ docker stack services --format "{{.ID}}: {{.Mode}} {{.Replicas}}" $ docker stack services --format "{{.ID}}: {{.Mode}} {{.Replicas}}"
0zmvwuiu3vue: replicated 10/10 0zmvwuiu3vue: replicated 10/10

View File

@ -20,6 +20,6 @@ Options:
## Examples ## Examples
```bash ```console
$ docker start my_container $ docker start my_container
``` ```

View File

@ -53,7 +53,7 @@ the `/containers/(id)/stats` API endpoint.
Running `docker stats` on all running containers against a Linux daemon. Running `docker stats` on all running containers against a Linux daemon.
```bash ```console
$ docker stats $ docker stats
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
@ -77,7 +77,7 @@ following columns are shown.
Running `docker stats` on multiple containers by name and id against a Linux daemon. Running `docker stats` on multiple containers by name and id against a Linux daemon.
```bash ```console
$ docker stats awesome_brattain 67b2525d8ad1 $ docker stats awesome_brattain 67b2525d8ad1
CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS CONTAINER ID NAME CPU % MEM USAGE / LIMIT MEM % NET I/O BLOCK I/O PIDS
@ -87,7 +87,7 @@ b95a83497c91 awesome_brattain 0.28% 5.629MiB / 1.952GiB
Running `docker stats` with customized format on all (Running and Stopped) containers. Running `docker stats` with customized format on all (Running and Stopped) containers.
```bash ```console
$ docker stats --all --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" fervent_panini 5acfcb1b4fd1 drunk_visvesvaraya big_heisenberg $ docker stats --all --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" fervent_panini 5acfcb1b4fd1 drunk_visvesvaraya big_heisenberg
CONTAINER CPU % MEM USAGE / LIMIT CONTAINER CPU % MEM USAGE / LIMIT
@ -151,7 +151,7 @@ outputs the data exactly as the template declares or, when using the
The following example uses a template without headers and outputs the The following example uses a template without headers and outputs the
`Container` and `CPUPerc` entries separated by a colon (`:`) for all images: `Container` and `CPUPerc` entries separated by a colon (`:`) for all images:
```bash ```console
$ docker stats --format "{{.Container}}: {{.CPUPerc}}" $ docker stats --format "{{.Container}}: {{.CPUPerc}}"
09d3bb5b1604: 6.61% 09d3bb5b1604: 6.61%
@ -162,7 +162,7 @@ $ docker stats --format "{{.Container}}: {{.CPUPerc}}"
To list all containers statistics with their name, CPU percentage and memory To list all containers statistics with their name, CPU percentage and memory
usage in a table format you can use: usage in a table format you can use:
```bash ```console
$ docker stats --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}" $ docker stats --format "table {{.Container}}\t{{.CPUPerc}}\t{{.MemUsage}}"
CONTAINER CPU % PRIV WORKING SET CONTAINER CPU % PRIV WORKING SET

View File

@ -25,6 +25,6 @@ instruction in the container's Dockerfile, or the `--stop-signal` option to
## Examples ## Examples
```bash ```console
$ docker stop my_container $ docker stop my_container
``` ```

View File

@ -38,8 +38,9 @@ View or rotate the current swarm CA certificate.
Run the `docker swarm ca` command without any options to view the current root CA certificate Run the `docker swarm ca` command without any options to view the current root CA certificate
in PEM format. in PEM format.
```bash ```console
$ docker swarm ca $ docker swarm ca
-----BEGIN CERTIFICATE----- -----BEGIN CERTIFICATE-----
MIIBazCCARCgAwIBAgIUJPzo67QC7g8Ebg2ansjkZ8CbmaswCgYIKoZIzj0EAwIw MIIBazCCARCgAwIBAgIUJPzo67QC7g8Ebg2ansjkZ8CbmaswCgYIKoZIzj0EAwIw
EzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwNTAzMTcxMDAwWhcNMzcwNDI4MTcx EzERMA8GA1UEAxMIc3dhcm0tY2EwHhcNMTcwNTAzMTcxMDAwWhcNMzcwNDI4MTcx
@ -55,7 +56,7 @@ lIwQqLkJ48SQqCjG1DBTSBsHmMSRT+6mE2My+Z3GKA==
Pass the `--rotate` flag (and optionally a `--ca-cert`, along with a `--ca-key` or Pass the `--rotate` flag (and optionally a `--ca-cert`, along with a `--ca-key` or
`--external-ca` parameter flag), in order to rotate the current swarm root CA. `--external-ca` parameter flag), in order to rotate the current swarm root CA.
``` ```console
$ docker swarm ca --rotate $ docker swarm ca --rotate
desired root digest: sha256:05da740cf2577a25224c53019e2cce99bcc5ba09664ad6bb2a9425d9ebd1b53e desired root digest: sha256:05da740cf2577a25224c53019e2cce99bcc5ba09664ad6bb2a9425d9ebd1b53e
rotated TLS certificates: [=========================> ] 1/2 nodes rotated TLS certificates: [=========================> ] 1/2 nodes
@ -65,7 +66,7 @@ desired root digest: sha256:05da740cf2577a25224c53019e2cce99bcc5ba09664ad6bb2a94
Once the rotation os finished (all the progress bars have completed) the now-current Once the rotation os finished (all the progress bars have completed) the now-current
CA certificate will be printed: CA certificate will be printed:
``` ```console
$ docker swarm ca --rotate $ docker swarm ca --rotate
desired root digest: sha256:05da740cf2577a25224c53019e2cce99bcc5ba09664ad6bb2a9425d9ebd1b53e desired root digest: sha256:05da740cf2577a25224c53019e2cce99bcc5ba09664ad6bb2a9425d9ebd1b53e
rotated TLS certificates: [==================================================>] 2/2 nodes rotated TLS certificates: [==================================================>] 2/2 nodes

View File

@ -37,8 +37,9 @@ in the newly created single-node swarm.
## Examples ## Examples
```bash ```console
$ docker swarm init --advertise-addr 192.168.99.121 $ docker swarm init --advertise-addr 192.168.99.121
Swarm initialized: current node (bvz81updecsj6wjz393c09vti) is now a manager. Swarm initialized: current node (bvz81updecsj6wjz393c09vti) is now a manager.
To add a worker to this swarm, run the following command: To add a worker to this swarm, run the following command:
@ -132,20 +133,21 @@ applies to all nodes that join the swarm.
The following example initializes a new Swarm, and configures the data path The following example initializes a new Swarm, and configures the data path
port to UDP port 7777; port to UDP port 7777;
```bash ```console
docker swarm init --data-path-port=7777 $ docker swarm init --data-path-port=7777
``` ```
After the swarm is initialized, use the `docker info` command to verify that After the swarm is initialized, use the `docker info` command to verify that
the port is configured: the port is configured:
```bash ```console
docker info $ docker info
... <...>
ClusterID: 9vs5ygs0gguyyec4iqf2314c0 ClusterID: 9vs5ygs0gguyyec4iqf2314c0
Managers: 1 Managers: 1
Nodes: 1 Nodes: 1
Data Path Port: 7777 Data Path Port: 7777
... <...>
``` ```
### `--default-addr-pool` ### `--default-addr-pool`

Some files were not shown because too many files have changed in this diff Show More