Docker Community Forums

Share and learn in the Docker community.

Do multiple docker filter options perform a local AND or OR operation?


#1

I am trying to perform a prune operation with multiple filters. This is covered in the docs here:

The filtering flag (–filter) format is of “key=value”. If there is more than one filter, then pass multiple flags (e.g., --filter “foo=bar” --filter “bif=baz”)

The docs fail to mention if using multiple filters like this combining them using a logical AND or OR operation.

I would like it to be an AND operation so that I can do something like this:

docker image prune --all --force --filter="label=com.company.product=myproduct" \
    --filter="label!=com.company.project=proj2"

and a Dockerfile with the following labels would not be pruned:

LABEL com.company.product="myproduct" com.company.project="proj2"

Is this possible?


#2

After doing some testing it appears to be an AND operation, so something like this should work:

docker image prune --all --force --filter="label=com.company.product=myproduct" \
    --filter="label=com.company.project=proj2"