mirror of
https://github.com/docker/cli.git
synced 2026-09-28 02:06:53 -04:00
On container rm, don't remove named mountpoints
This makes it so when calling `docker run --rm`, or `docker rm -v`, only volumes specified without a name, e.g. `docker run -v /foo` instead of `docker run -v awesome:/foo` are removed. Note that all volumes are named, some are named by the user, some get a generated name. This is specifically about how the volume was specified on `run`, assuming that if the user specified it with a name they expect it to persist after the container is cleaned up. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
This commit is contained in:
@@ -48,6 +48,22 @@ command. The use that name as follows:
|
||||
|
||||
docker rm hopeful_morse
|
||||
|
||||
## Removing a container and all associated volumes
|
||||
|
||||
$ docker rm -v redis
|
||||
redis
|
||||
|
||||
This command will remove the container and any volumes associated with it.
|
||||
Note that if a volume was specified with a name, it will not be removed.
|
||||
|
||||
$ docker create -v awesome:/foo -v /bar --name hello redis
|
||||
hello
|
||||
$ docker rm -v hello
|
||||
|
||||
In this example, the volume for `/foo` will remain in tact, but the volume for
|
||||
`/bar` will be removed. The same behavior holds for volumes inherited with
|
||||
`--volumes-from`.
|
||||
|
||||
# HISTORY
|
||||
April 2014, Originally compiled by William Henry (whenry at redhat dot com)
|
||||
based on docker.com source material and internal work.
|
||||
|
||||
Reference in New Issue
Block a user