cli icon indicating copy to clipboard operation
cli copied to clipboard

fix(image): don't treat digest-only images as dangling in list output

Open mohithshuka opened this issue 7 months ago • 3 comments

Problem

docker images was hiding images that have a digest but no tag, treating them as dangling. This caused valid images to silently disappear from default output.

The local isDangling function in list.go was missing the len(img.RepoDigests) == 0 check, so any image with no tags but a valid digest was incorrectly filtered out.

Fix

Align list.go's isDangling with the definition already correct in formatter/image.go — an image is only dangling if it has both no tags AND no digests.

Before / After

Before: Images with digest but no tag silently hidden from docker images
After: Those images appear in output as expected

Fixes #6650

mohithshuka avatar Apr 29 '26 13:04 mohithshuka

This needs a rebase as it has unrelated commits in the PR, but I think this was an intentional change;

  • https://github.com/docker/cli/pull/5924

thaJeztah avatar May 04 '26 13:05 thaJeztah

This needs a rebase as it has unrelated commits in the PR, but I think this was an intentional change;

* [docker images --tree: hide both untagged and dangling images by default #5924](https://github.com/docker/cli/pull/5924)

I've read the so-called "intentional" change, and I'm asking myself some serious questions :

  • dangling images were visible without the -a parameter (or some of them, I had multiple <none>:<none> visible immediately)
  • the builder, legacy or not, is not the only one able to create untagged image. An image with the latest tag, replaced by a newest version on a docker pull will lose its tag, replaced by <none>
  • same when rebuilding the same image, buildx, which is not legacy, will untag the older image.
  • docker system prune is not enough for untagged images, which is the problem : if you don't see them, you won't remove them. Beside, I had my share of horror stories with prune up to the point of not using it blindly in production, if not at all.
  • docker has no automatic removal of untagged image (dangling or not). Hiding them from the user is a very bad move. Many of them does not have enough knowledge of docker to understand those fine prints. Hiding all untagged images just because, even the legit one, is a recipe for disaster.
  • the change itself is seriously breaking from years of consistent behaviors, while bringing no real reason on the table.

Btw, just curious, but what is usually the review process for any breaking change on a critical component ?

Daryes avatar May 23 '26 20:05 Daryes

This needs a rebase as it has unrelated commits in the PR, but I think this was an intentional change;

I'd also like to know what the process was for introducing changes like this that fundamentally change the expected behavior of important commands. I also had several hours of tearing my hair out trying to figure out why my untagged images weren't showing, and also have several pipelines using the cli to list images that broke with that change.

Who wanted that change? What was the process for deciding if it was necessary? Same questions for the format change that was introduced, although at least that one has a configuration setting to revert back to the better behavior.

maxweisspoker avatar May 27 '26 09:05 maxweisspoker