Docker prune - Negative filters - Invalid filter error

Who knows why a negative filters are not working in accordance with official guide?

WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Error response from daemon: Invalid filter 'reference!'```

Looked at the docs as well. the syntax seems correct, ie. you’re passing multiple filters in separate --filter clauses. The only thing i think of is that it’s complaining about the wildcard (ie. it would allow portainer but coughs with portainer/*)

so then you’d may have to run a separate docker image ls bash script first to get your prune-list how you want it

The issue is arriving only when use the negative filter !=
it works well using =

I got nothing :slight_smile: um , seems like a pretty good but report

I’ve created an issue Yesterday
I got response that the negative filters aren’t supported at the moment.

Then why is it in the docs?

Did you try with operator separated as "reference != portainer/*" ? Maybe it’s trying to use reference! as a filter key when written sticked.

You’ll get the following error using it:
Error response from daemon: Invalid filter 'reference !'

Hmm no more idea for now then. Sorry

I’ve solved this by the following crutch
docker rmi —force $(docker images --filter "dangling=true" | awk '!(/portainer/||/REPOSITORY/){print $3}')

Great! Bash always works :+1::skin-tone-2:

It’s a good fix – i find myself doing the same sort of thing with nested cli calls when mucking around AWS cli