docker image ls --filter "label=testuseradd"
REPOSITORY TAG IMAGE ID CREATED SIZE
testuseradd/simple example 74707eaff6fd 8 minutes ago 14.9MB
<none> <none> 00a050d211ee 12 minutes ago 14.9MB
testuseradd/custom_salt example 8b3b4ca37de1 22 minutes ago 14.6MB
testuseradd test 59af5882f846 23 hours ago 14.9MB
docker image prune --force --all --filter "label=testuseradd"
Total reclaimed space: 0B
docker image ls --filter "label=testuseradd"
REPOSITORY TAG IMAGE ID CREATED SIZE
testuseradd/simple example 74707eaff6fd 13 minutes ago 14.9MB
<none> <none> 00a050d211ee 17 minutes ago 14.9MB
testuseradd/custom_salt example 8b3b4ca37de1 27 minutes ago 14.6MB
testuseradd test 59af5882f846 23 hours ago 14.9MB
docker image prune --force --all --filter "label=testuseradd"
Total reclaimed space: 0B
The images are filterable and found, but when docker image prune is forced to delete them, it does not find any.
Are you sure there are no stopped containers that use those images?
I just tried docker image prune --filter label=org.opencontainers.image.title on docker 20.10.14 to test if the basic prune and filter method has an issue. The command pruned orphaned images having that label.
As a further check I re-ran the command without the filter and it deleted all other orphaned images. At least for me the behavior is as expected.
Note: I didn’t use --all, as I have some unused images in the local cache I don’t want to loose.
Just tested it. Works. I had misunderstood the force option.
Thank you!
P.S.:
I re-read the documentation.
--all , -a Remove all unused images, not just dangling ones
This was the line that caused me to think, that it does not matter if there are stopped containers associated with the to be pruned images. It in fact mentions, that it still only removes unused images. Okay, got it. I initially had skimmed it too quickly, it seems.