docker / cli

The Docker CLI
Apache License 2.0
4.91k stars 1.92k forks source link

Filter args are inconsistent and poorly documented #3696

Open macdjord opened 2 years ago

macdjord commented 2 years ago

A number of Docker commands take --filter arguments, however the way these arguments work is radically inconsistent between the commands, and the documentation for them is insufficient in several ways. There are various tickets which discuss some of the issues, but I believe that the core issue is that the different filter arguments were implemented separately and grew organically individually over time; the only solution is to overhaul them all at once to provide a consistent interface using a shared codebase.

Problems include:

The whole system should be revamped as follows:

Related issues:

ndeloof commented 2 years ago

Agree. --filter is one of the worst part of the docker UX. Better documentation (at least) and better consistency would be a nice enhancement

victor-timofei commented 2 years ago

Agree, I would also want this to be documented either in the manpages or in the --help, or maybe both.

maques1 commented 1 year ago

An additional "observation" on this inconsistent behavior:

docker volume ls --filter dangling=true --filter name="f464107006296e7623ed30aa1c4c66f0f7384e5398c59fae684be7e25b9d7d82"
DRIVER    VOLUME NAME
local     f464107006296e7623ed30aa1c4c66f0f7384e5398c59fae684be7e25b9d7d82

docker volume prune --filter dangling=true --filter name="f464107006296e7623ed30aa1c4c66f0f7384e5398c59fae684be7e25b9d7d82"
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Error response from daemon: Invalid filter 'dangling'

So "--filter" (even combined ones) works for volume ls, also volume prune accepts it and asks for confirmation, then bails out with the "Invalid filter" error, not even complaining for the "--filter" option, but the "filter" value (though it doesn't seem to accept any other filter value as well). The result is the same even if just one filter (name or dangling state) specified.