Add name/driver filter support for volume

This change include filter `name` and `driver`,
and also update related docs to reflect that filters usage.

Closes: #21243

Signed-off-by: Kai Qiang Wu(Kennan) <wkqwu@cn.ibm.com>
master
Kai Qiang Wu(Kennan) 2016-03-21 07:39:48 +00:00 committed by Tibor Vass
parent 386acc792b
commit d69044537c
1 changed files with 51 additions and 8 deletions

View File

@ -14,28 +14,71 @@ parent = "smn_cli"
List volumes
-f, --filter=[] Provide filter values (i.e. 'dangling=true')
-f, --filter=[] Filter output based on these conditions:
- dangling=<boolean> a volume if referenced or not
- driver=<string> a volume's driver name
- name=<string> a volume's name
--help Print usage
-q, --quiet Only display volume names
Lists all the volumes Docker knows about. You can filter using the `-f` or `--filter` flag. The filtering format is a `key=value` pair. To specify more than one filter, pass multiple flags (for example, `--filter "foo=bar" --filter "bif=baz"`)
There is a single supported filter `dangling=value` which takes a boolean of `true` or `false`.
Lists all the volumes Docker knows about. You can filter using the `-f` or `--filter` flag. Refer to the [filtering](#filtering) section for more information about available filter options.
Example output:
$ docker volume create --name rose
rose
$ docker volume create --name rosemary
rosemary
$docker volume create --name tyler
tyler
$ docker volume ls
DRIVER VOLUME NAME
local rose
local rosemary
local tyler
## Filtering
The filtering flag (`-f` or `--filter`) format is of "key=value". If there is more
than one filter, then pass multiple flags (e.g., `--filter "foo=bar" --filter "bif=baz"`)
The currently supported filters are:
* dangling (boolean - true or false, 0 or 1)
* driver (a volume driver's name)
* name (a volume's name)
### dangling
The `dangling` filter matches on all volumes not referenced by any containers
$ docker run -d -v tyler:/tmpwork busybox
f86a7dd02898067079c99ceacd810149060a70528eff3754d0b0f1a93bd0af18
$ docker volume ls -f dangling=true
DRIVER VOLUME NAME
local rosemary
### driver
The `driver` filter matches on all or part of a volume's driver name.
The following filter matches all volumes with a driver name containing the `local` string.
$ docker volume ls -f driver=local
DRIVER VOLUME NAME
local rosemary
local tyler
### name
The `name` filter matches on all or part of a volume's name.
The following filter matches all volumes with a name containing the `rose` string.
$ docker volume ls -f name=rose
DRIVER VOLUME NAME
local rosemary
## Related information
* [volume create](volume_create.md)
* [volume inspect](volume_inspect.md)
* [volume rm](volume_rm.md)
* [Understand Data Volumes](../../userguide/containers/dockervolumes.md)
* [Understand Data Volumes](../../userguide/containers/dockervolumes.md)