Skip to content

image ls: show each tag for an image as a separate entry - #5556

Open
thaJeztah wants to merge 1 commit into
docker:masterfrom
thaJeztah:tree_ungroup
Open

image ls: show each tag for an image as a separate entry#5556
thaJeztah wants to merge 1 commit into
docker:masterfrom
thaJeztah:tree_ungroup

Conversation

@thaJeztah

@thaJeztahthaJeztah commented Oct 19, 2024

Copy link
Copy Markdown
Member

A single image can be tagged under multiple names. While they are the same image under the hood (same digest), we always presented these as separate images in the list.

This patch applies the same behavior for the tree view; we can consider having some "compact" presentation in future where we collapse these iamges (perhaps introducing a "names" column?)

Before this patch:

$ docker pull --quiet alpine:3.20
docker.io/library/alpine:3.20
$ docker pull --quiet alpine:latest
docker.io/library/alpine:latest
$ docker image ls --tree
IMAGE ID DISK USAGE CONTENT SIZE USED
alpine:3.20
alpine:latest beefdbd8a1da 13.6MB 4.09MB
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 0B 0B
└─ linux/s390x 2b5b26e09ca2 0B 0B

With this patch applied:

$ docker image ls --tree
IMAGE ID DISK USAGE CONTENT SIZE USED
alpine:3.20 beefdbd8a1da 13.6MB 4.09MB
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 0B 0B
└─ linux/s390x 2b5b26e09ca2 0B 0B
alpine:latest beefdbd8a1da 13.6MB 4.09MB
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 0B 0B
└─ linux/s390x 2b5b26e09ca2 0B 0B

- What I did

- How I did it

- How to verify it

- Description for the changelog

The `docker image ls --tree` output now shows images that are tagged under multiple names as separate images.

- A picture of a cute animal (not mandatory but encouraged)

@codecov-commenter

codecov-commenter commented Oct 19, 2024

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.

Files with missing linesPatch %Lines
cli/command/image/tree.go0.00%23 Missing ⚠️

📢 Thoughts on this report? Let us know!

A single image can be tagged under multiple names. While they are the
same image under the hood (same digest), we always presented these as
separate images in the list.
This patch applies the same behavior for the tree view; we can consider
having some "compact" presentation in future where we collapse these iamges
(perhaps introducing a "names" column?)
Before this patch:
$ docker pull --quiet alpine:3.20
docker.io/library/alpine:3.20
$ docker pull --quiet alpine:latest
docker.io/library/alpine:latest
$ docker image ls --tree
IMAGE ID DISK USAGE CONTENT SIZE USED
alpine:3.20
alpine:latest beefdbd8a1da 13.6MB 4.09MB
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 0B 0B
└─ linux/s390x 2b5b26e09ca2 0B 0B
With this patch applied:
$ docker image ls --tree
IMAGE ID DISK USAGE CONTENT SIZE USED
alpine:3.20 beefdbd8a1da 13.6MB 4.09MB
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 0B 0B
└─ linux/s390x 2b5b26e09ca2 0B 0B
alpine:latest beefdbd8a1da 13.6MB 4.09MB
├─ linux/arm64/v8 9cee2b382fe2 13.6MB 4.09MB
├─ linux/amd64 33735bd63cf8 0B 0B
├─ linux/arm/v6 50f635c8b04d 0B 0B
├─ linux/arm/v7 f2f82d424957 0B 0B
├─ linux/386 b3e87f642f5c 0B 0B
├─ linux/ppc64le c7a6800e3dc5 0B 0B
├─ linux/riscv64 80cde017a105 0B 0B
└─ linux/s390x 2b5b26e09ca2 0B 0B
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

@vvolandvvoland left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I don't see any benefit to showing them as a separate entities:

  • It duplicates a lot of information
  • There are no separate content for each of the images. The underlying content is the same and there's no way to modify the image without either creating a new content or mutating other images with the same target.

The reason we always presented these as separate images in the list is also not convincing 🙈

@thaJeztah

Copy link
Copy Markdown
MemberAuthor

Hmmm.. yeah, not sure I agree; yes, it's more verbose (and yes, content is duplicated).

I think for most intents and purposes users would consider them separate things. You need to pull them separately (which may be from different registries), delete them separately, and push them separately.

It can be useful to know that some images may have names (or tags) that point to the same digest but, somewhat similar to tags on a Git repository, where (as a user) I would look at the tag / version, before considering if they could be pointing to the same commit.

The image name often has a meaningful purpose; both to find the image when browsing the list (which could be relevant to, e.g. "remove that temporary image name"), but also, for example, Docker Content Trust, which signs images by name (so signing may apply to one name, but not the other).

We also don't do the same for the platform variants underneath, those variants could be referenced in multiple images (not always in the same combination), or it could be that I have a single-platform image that is also contained as a variant in a multi-platform one.

All that said 👉 we should look if could somehow indicate that they're identical to another image (perhaps also from a perspective of size/usage being "shared" or not).

If we do consider them "same image", we should flip to use ID in the list, and tag(s) as secondary

ID TAGS DISK USAGE CONTENT SIZE USED
ae65dbf8749a alpine:3.20, alpine:3.20.1, alpine:latest, localhost:5000/alpine:latest 11.8MB 3.36MB

But no idea how to present the --tree view for that one? Something like this?

ID TAGS DISK USAGE CONTENT SIZE USED
ae65dbf8749a alpine:3.20, alpine:3.20.1, alpine:latest, localhost:5000/alpine:latest 11.8MB 3.36MB
├─ e910e9408f39 (linux/arm64/v8) 11.8MB 3.36MB
├─ f11993ab46a7 (linux/amd64) 0B 0B
├─ ac81a83e76e0 (linux/arm/v6) 0B 0B
├─ bf26745c2687 (linux/arm/v7) 0B 0B
├─ 7487bdbed5b1 (linux/386) 0B 0B
├─ 81f21d25e89f (linux/ppc64le) 0B 0B
└─ 9f5d32a173f5 (linux/s390x) 0B 0B

The tricky bit with "grouping" them is that if we would decide to show images alphabetically, what should we show?

/ # docker image ls --tree
IMAGE ID DISK USAGE CONTENT SIZE USED
alpine:3.20
├─ linux/arm64/v8 e910e9408f39 11.8MB 3.36MB
├─ linux/amd64 f11993ab46a7 0B 0B
├─ linux/arm/v6 ac81a83e76e0 0B 0B
├─ linux/arm/v7 bf26745c2687 0B 0B
├─ linux/386 7487bdbed5b1 0B 0B
├─ linux/ppc64le 81f21d25e89f 0B 0B
└─ linux/s390x 9f5d32a173f5 0B 0B
alpine:3.20.1
localhost:5000/alpine:latest

@thaJeztah

Copy link
Copy Markdown
MemberAuthor

Wrote down a somewhat alternative on #5560 (comment)

@thaJeztahthaJeztah modified the milestones: 28.0.0, 28.0.5Mar 31, 2025
@thaJeztahthaJeztah modified the milestones: 28.1.1, 28.1.2Apr 23, 2025
@thaJeztahthaJeztah modified the milestones: 28.1.2, 28.2.0, 29.0.0May 15, 2025
@thaJeztahthaJeztah modified the milestones: 29.0.0, 29.2.0Jan 13, 2026
@thaJeztahthaJeztah modified the milestones: 29.2.0, 29.3.0Jan 26, 2026
@thaJeztahthaJeztah modified the milestones: 29.3.0, 29.4.0Mar 4, 2026
@vvolandvvoland removed this from the 29.4.1 milestone Apr 16, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/uxcontainerd-integrationIssues and PRs related to containerd integrationkind/enhancementstatus/2-code-review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[c8d] improve docker image ls --tree for images with multiple names/tags

3 participants

@thaJeztah@codecov-commenter@vvoland