Originally reported by @twooster in https://github.com/moby/moby/issues/31122#issuecomment-313872632
When running docker system prune with an until filter, pruning fails and does not remove images, volumes, and networks.
Error response from daemon: Invalid filter 'until'
The cause of this is that all resources (containers, images, networks) support filtering by until _except_ volumes. The docker system prune sequentially calls the various prune commands, and when it calls the docker volume prune endpoint, an error is returned by the daemon, and pruning stops;
# docker system prune --filter until=24h
WARNING! This will remove:
- all stopped containers
- all volumes not used by at least one container
- all networks not used by at least one container
- all dangling images
Are you sure you want to continue? [y/N] y
Error response from daemon: Invalid filter 'until'
Daemon logs;
DEBU[1185] Calling POST /v1.30/containers/prune?filters=%7B%22label%22%3A%7B%22label.foo%3D%3Dbar%22%3Atrue%7D%2C%22until%22%3A%7B%2224h%22%3Atrue%7D%7D
DEBU[1185] Calling POST /v1.30/volumes/prune?filters=%7B%22label%22%3A%7B%22label.foo%3D%3Dbar%22%3Atrue%7D%2C%22until%22%3A%7B%2224h%22%3Atrue%7D%7D
ERRO[1185] Handler for POST /v1.30/volumes/prune returned error: Invalid filter 'until'
Error response from daemon: Invalid filter 'until'
# docker version
Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:23:31 2017
OS/Arch: linux/amd64
Server:
Version: 17.06.0-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:19:04 2017
OS/Arch: linux/amd64
Experimental: false
We need to remove the until filter for the "volume prune" endpoint (but only when called as part of system prune, not when directly calling docker volume prune).
Given that we don't support a client talking to a _newer_ API version, it should not be a problem to simply remove the filter, as long as we don't forget to remove that part of the code once volumes _do_ support the until filter.
Perhaps we need to print a warning if the filter is used, because skipping the filter may result in removing more volumes than the user possibly intended?
/cc @cpuguy83 wdyt?
Why would it end up removing more volumes if we don't support it anyway?
In this case, because the until filter was provided, but will be used by all "objects", _except_ volumes. I can see this being confusing, e.g., running this
docker system prune --volumes --filter until=24h
I would expect all unused objects created longer than 24 hr ago to be pruned; but effectively, volumes created within the last 24hr are also removed.
I can push a PR for discussion
prune with the until filter only works with docker system prune but not other prune commands?
I'm on Docker version 18.03.1-ce, build 9ee9f40, and the until filter isn't working:
$ docker images prune --filter until=48h
Error response from daemon: Invalid filter 'until'
Does this count as an issue? If so, should I open up another issue on this, or re-open this issue and change the description? @thaJeztah
@timfeirg looks like you typed docker images prune (images; plural); docker images is the old equivalent of docker image ls. You're probably looking for docker image prune
This really makes me laugh.
But from the CLI or API design perspective, I really think this prune command ought to be in the form of docker prune [resource] rather than docker [resource] prune, I think people can really make creative and hard-to-find mistakes with the latter.
I personally wasted a afternoon trying to seek reason why my prune command won't work, and invent shell scripts to do the same job, because I failed to notice that I was typing plural, even though I've been staring at the docs constantly.
Most helpful comment
This really makes me laugh.
But from the CLI or API design perspective, I really think this prune command ought to be in the form of
docker prune [resource]rather thandocker [resource] prune, I think people can really make creative and hard-to-find mistakes with the latter.I personally wasted a afternoon trying to seek reason why my prune command won't work, and invent shell scripts to do the same job, because I failed to notice that I was typing plural, even though I've been staring at the docs constantly.