Skip to content

Conversation

@vvoland
Copy link
Collaborator

@vvoland vvoland commented Dec 12, 2025

Fix `docker image ls` dangling image handling

image: Fix dangling image detection with graphdrivers

The isDangling function was incorrectly identifying images as dangling
when they had no RepoTags but had valid RepoDigests.

This can occur when the graphdrivers are used instead of the containerd
image store.

An image should only be considered dangling if it has no RepoTags,
regardless of whether it has RepoDigests.

image/tree: Extract untagged image name to const

image/tree: Fix width calculation for untagged images

When calculating column widths for the tree view, untagged images
weren't being properly accounted for in the width calculation.

This caused layout issues when there were tagged images were shorter
than the <untagged> string.

image/tree: Remove --all flag check for untagged images in non-expanded view

This reverts part of the logic introduced in 207bf52 which
incorrectly gated untagged images behind the --all flag in non-expanded
view.

The original fix was addressing the wrong layer of the problem.

The actual issue was that dangling images were being incorrectly passed
to the tree code in the first place.

This was properly fixed in 67f5e34 which corrected the dangling image
detection logic to properly filter them out before reaching the tree
display code.

Now that dangling images are correctly filtered upstream, untagged
images that reach the tree view should be displayed regardless of the
--all flag setting.

image/tree: Add golden test

The isDangling function was incorrectly identifying images as dangling
when they had no RepoTags but had valid RepoDigests.

This can occur when the graphdrivers are used instead of the containerd
image store.

An image should only be considered dangling if it has no RepoTags,
regardless of whether it has RepoDigests.

Signed-off-by: Paweł Gronowski <[email protected]>
When calculating column widths for the tree view, untagged images
weren't being properly accounted for in the width calculation.

This caused layout issues when there were tagged images were shorter
than the `<untagged>` string.

Signed-off-by: Paweł Gronowski <[email protected]>
…ed view

This reverts part of the logic introduced in 207bf52 which
incorrectly gated untagged images behind the --all flag in non-expanded
view.

The original fix was addressing the wrong layer of the problem.

The actual issue was that dangling images were being incorrectly passed
to the tree code in the first place.

This was properly fixed in 67f5e34 which corrected the dangling image
detection logic to properly filter them out before reaching the tree
display code.

Now that dangling images are correctly filtered upstream, untagged
images that reach the tree view should be displayed regardless of the
--all flag setting.

Signed-off-by: Paweł Gronowski <[email protected]>
Signed-off-by: Paweł Gronowski <[email protected]>
@vvoland vvoland added this to the 29.1.3 milestone Dec 12, 2025
@vvoland vvoland self-assigned this Dec 12, 2025
@codecov-commenter
Copy link

Codecov Report

❌ Patch coverage is 71.42857% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
cli/command/image/list.go 0.00% 1 Missing ⚠️
cli/command/image/tree.go 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@vvoland vvoland requested a review from thaJeztah December 12, 2025 12:15
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@thaJeztah thaJeztah merged commit 4d6fc33 into docker:master Dec 12, 2025
115 of 116 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docker image ls -f dangling=true shows no images unless -a is also specified

3 participants