Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Oct 19, 2024

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)

@thaJeztah thaJeztah added this to the 28.0.0 milestone Oct 19, 2024
@thaJeztah thaJeztah self-assigned this Oct 19, 2024
@codecov-commenter
Copy link

codecov-commenter commented Oct 19, 2024

Codecov Report

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

Project coverage is 59.54%. Comparing base (062eecf) to head (7187c78).
Report is 91 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #5556      +/-   ##
==========================================
- Coverage   59.57%   59.54%   -0.04%     
==========================================
  Files         345      345              
  Lines       29088    29105      +17     
==========================================
  Hits        17330    17330              
- Misses      10788    10805      +17     
  Partials      970      970              

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 <[email protected]>
Copy link
Collaborator

@vvoland vvoland left a comment

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
Member Author

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
Member Author

Wrote down a somewhat alternative on #5560 (comment)

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.

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