Skip to content
This repository has been archived by the owner on Feb 1, 2021. It is now read-only.

docker volume ls -f dangling=true returns all volumes #1849

Closed
mrgnr opened this issue Feb 19, 2016 · 7 comments
Closed

docker volume ls -f dangling=true returns all volumes #1849

mrgnr opened this issue Feb 19, 2016 · 7 comments

Comments

@mrgnr
Copy link

mrgnr commented Feb 19, 2016

Description: Filtering doesn't work for the docker volume ls command when run via the Swarm manager. All volumes are returned, regardless of whether dangling=true or dangling=false.

System info:

$ docker version                    
Client:
 Version:      1.10.1
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   9e83765
 Built:        Thu Feb 11 19:27:08 2016
 OS/Arch:      linux/amd64

Server:
 Version:      swarm/1.1.2
 API version:  1.22
 Go version:   go1.5.3
 Git commit:   f947993
 Built:        Thu Feb 18 08:28:32 UTC 2016
 OS/Arch:      linux/amd64
$ docker info
Containers: 4
 Running: 4
 Paused: 0
 Stopped: 0
Images: 3
Server Version: swarm/1.1.2
Role: primary
Strategy: spread
Filters: health, port, dependency, affinity, constraint
Nodes: 2
 agent0: 192.168.99.103:2376
  └ Status: Healthy
  └ Containers: 3
  └ Reserved CPUs: 0 / 1
  └ Reserved Memory: 0 B / 1.021 GiB
  └ Labels: executiondriver=native-0.2, kernelversion=4.1.17-boot2docker, operatingsystem=Boot2Docker 1.10.1 (TCL 6.4.1); master : b03e158 - Thu Feb 11 22:34:01 UTC 2016, provider=virtualbox, storagedriver=aufs
  └ Error: (none)
  └ UpdatedAt: 2016-02-19T20:11:22Z
 agent1: 192.168.99.104:2376
  └ Status: Healthy
  └ Containers: 1
  └ Reserved CPUs: 0 / 1
  └ Reserved Memory: 0 B / 1.021 GiB
  └ Labels: executiondriver=native-0.2, kernelversion=4.1.17-boot2docker, operatingsystem=Boot2Docker 1.10.1 (TCL 6.4.1); master : b03e158 - Thu Feb 11 22:34:01 UTC 2016, provider=virtualbox, storagedriver=aufs
  └ Error: (none)
  └ UpdatedAt: 2016-02-19T20:11:01Z
Plugins: 
 Volume: 
 Network: 
Kernel Version: 4.1.17-boot2docker
Operating System: linux
Architecture: amd64
CPUs: 2
Total Memory: 2.043 GiB
Name: manager
$ uname -a
Linux manager 4.1.17-boot2docker #1 SMP Thu Feb 11 08:12:31 UTC 2016 x86_64 GNU/Linux

Steps to reproduce:

# - Create a Swarm cluster
# - Set DOCKER_HOST to point to the Swarm manager
# - Run the following:
$ docker volume create --name used
$ docker volume create --name unused
$ docker run -tid -v used:/v busybox cat
$ docker volume ls -f dangling=true
$ docker volume ls -f dangling=false

Results:
When docker volume ls -f dangling=true is run via the Swarm manager, all volumes are returned (including the used volume mounted by the busybox container). When docker volume ls -f dangling=true is run on the node with the busybox container, the used volume is not listed in the output (as expected).

Expected results:
When docker volume ls -f dangling=true is run via the Swarm manager, volumes that are in use (in this case the used volume) should not be returned.

@mrgnr mrgnr changed the title docker volumes ls -f dangling=true returns all volumes docker volume ls -f dangling=true returns all volumes Feb 19, 2016
@nishanttotla
Copy link
Contributor

@emrob thanks for reporting. Swarm does not support volume filters right now, so the output you're seeing makes sense. We're still working on supporting new Docker options with Swarm. Do you have a strong requirement for this feature right now?

@mrgnr
Copy link
Author

mrgnr commented Feb 22, 2016

@nishanttotla This feature would be very convenient to have, but I can work around it for now. Thanks!

@nishanttotla
Copy link
Contributor

@emrob I've been investigating it, and it's slightly more complex to implement than just a simple filtering, because the underlying client Swarm uses doesn't support filtering yet. I'll still try to see if there's an easy way to do it for now.

@nishanttotla
Copy link
Contributor

We'll be able to filter volumes once #1879 is through. This is scheduled for the 1.2 release.

@akireikin
Copy link

As for me, I want to use this feature for cleaning up unused images in swarm cluster.

docker -H :4000 rmi $(docker -H :4000 images --filter "dangling=true" -q --no-trunc)

@alexvy86
Copy link

@nishanttotla I see that #1879 was closed a while back but this apparently still doesn't work... in my case docker volume ls -f dangling=true from a swarm manager only returns one of two containers that exist in the swarm, both using the cloudstor driver and both in use by swarm services. Are there any updates on this functionality?

@trapier
Copy link

trapier commented Sep 15, 2018

Filter for dangling images in progress here #2831

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants