clarify independence of volume lifecycle (#6563)

This commit is contained in:
Trapier Marshall 2018-04-27 12:44:21 -04:00 committed by Gwendolynne Barr
parent 2a62bcf235
commit 45350ed397
2 changed files with 22 additions and 12 deletions

View File

@ -851,9 +851,14 @@ don't specify a type.
#### Data volumes
Data volumes are storage that remain alive after a container for a task has
been removed. The preferred method to mount volumes is to leverage an existing
volume:
Data volumes are storage that exist independently of a container. The
lifecycle of data volumes under swarm services is similar to that under
containers. Volumes outlive tasks and services, so their removal must be
managed separately. Volumes can be created before deploying a service, or if
they don't exist on a particular host when a task is scheduled there, they are
created automatically according to the volume specification on the service.
To use existing data volumes with a service use the `--mount` flag:
```bash
$ docker service create \
@ -862,11 +867,10 @@ $ docker service create \
<IMAGE>
```
For more information on how to create a volume, see the `volume create`
[CLI reference](/engine/reference/commandline/volume_create.md).
The following method creates the volume at deployment time when the scheduler
dispatches a task, just before starting the container:
If a volume with the same `<VOLUME-NAME>` does not exist when a task is
scheduled to a particular host, then one is created. The default volume
driver is `local`. To use a different volume driver with this create-on-demand
pattern, specify the driver and its options with the `--mount` flag:
```bash
$ docker service create \

View File

@ -190,7 +190,8 @@ correctly. Look for the `Mounts` section:
This shows that the mount is a volume, it shows the correct source and
destination, and that the mount is read-write.
Stop the container and remove the volume.
Stop the container and remove the volume. Note volume removal is a separate
step.
```bash
$ docker container stop devtest
@ -233,6 +234,9 @@ Remove the service, which stops all its tasks:
$ docker service rm devtest-service
```
Removing the service does not remove any volumes created by the service.
Volume removal is a separate step.
#### Syntax differences for services
The `docker service create` command does not support the `-v` or `--volume` flag.
@ -281,8 +285,9 @@ $ docker run -d \
</div><!--volume-->
</div><!--tab-content-->
After running either of these examples, run the following commands to clean up the
containers and volumes.
After running either of these examples, run the following commands to clean up
the containers and volumes. Note volume removal is a separate step.
```bash
$ docker container stop nginxtest
@ -352,7 +357,8 @@ correctly. Look for the `Mounts` section:
],
```
Stop and remove the container, and remove the volume:
Stop and remove the container, and remove the volume. Volume removal is a
separate step.
```bash
$ docker container stop nginxtest