mirror of https://github.com/docker/docs.git
add support ps --filter volume
Signed-off-by: Xian Chaobo <xianchaobo@huawei.com>
This commit is contained in:
parent
d0bc1833d0
commit
f39ac0e2c2
|
@ -400,7 +400,20 @@ func getContainersJSON(c *context, w http.ResponseWriter, r *http.Request) {
|
|||
if !filters.Match("node", container.Engine.Name) {
|
||||
continue
|
||||
}
|
||||
|
||||
if filters.Include("volume") {
|
||||
volumeExist := fmt.Errorf("volume mounted in container")
|
||||
err := filters.WalkValues("volume", func(value string) error {
|
||||
for _, mount := range container.Info.Mounts {
|
||||
if mount.Name == value || mount.Destination == value {
|
||||
return volumeExist
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != volumeExist {
|
||||
continue
|
||||
}
|
||||
}
|
||||
if len(filtExited) > 0 {
|
||||
shouldSkip := true
|
||||
for _, code := range filtExited {
|
||||
|
|
|
@ -157,3 +157,22 @@ function teardown() {
|
|||
[[ "${output}" == *"node-0/c1"* ]]
|
||||
[[ "${output}" != *"node-1/c2"* ]]
|
||||
}
|
||||
|
||||
@test "docker ps --filter node" {
|
||||
run docker --version
|
||||
if [[ "${output}" == "Docker version 1.9"* || "${output}" == "Docker version 1.10"* ]]; then
|
||||
skip
|
||||
fi
|
||||
start_docker_with_busybox 2
|
||||
swarm_manage
|
||||
|
||||
docker_swarm run --name c1 -v test_volume1:/abc -d busybox:latest sleep 100
|
||||
docker_swarm run --name c2 -v test_volume2:/def -d busybox:latest sleep 100
|
||||
docker_swarm run --name c3 -v test_volume3:/ghi -d busybox:latest sleep 100
|
||||
|
||||
run docker_swarm ps --filter volume=test_volume1 --filter volume=/def
|
||||
[ "$status" -eq 0 ]
|
||||
[[ "${output}" == *"node-0/c1"* ]]
|
||||
[[ "${output}" == *"node-1/c2"* ]]
|
||||
[[ "${output}" != *"node-1/c3"* ]]
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue