Skip to content

feat(image): add --tree flag to image list - #5092

Open
ekalinin wants to merge 1 commit into
containerd:mainfrom
ekalinin:feat/images-tree
Open

feat(image): add --tree flag to image list#5092
ekalinin wants to merge 1 commit into
containerd:mainfrom
ekalinin:feat/images-tree

Conversation

@ekalinin

Copy link
Copy Markdown

Add a tree view to nerdctl images compatible with docker image ls --tree: a top-level row per image and one child row per platform, with columns IMAGE, ID, DISK USAGE, CONTENT SIZE and IN USE.

IN USE is derived from existing containers by matching (image name, platform). The tree view is incompatible with --quiet and --format. Per-platform rows now carry their own manifest digest as the ID instead of the shared index digest.

Closes #5005

Add a tree view to `nerdctl images` compatible with `docker image ls --tree`:
a top-level row per image and one child row per platform, with columns
IMAGE, ID, DISK USAGE, CONTENT SIZE and IN USE.

IN USE is derived from existing containers by matching (image name, platform).
The tree view is incompatible with --quiet and --format. Per-platform rows now
carry their own manifest digest as the ID instead of the shared index digest.

Closes containerd#5005

Signed-off-by: Eugene Kalinin <e.v.kalinin@gmail.com>
Comment thread pkg/cmd/image/list.go
name string // familiar "repo:tag" or "<none>:<none>"
id string // target (index or manifest) digest, truncated unless --no-trunc
diskUsage int64 // sum of the platforms' unpacked snapshot sizes
blobSize int64 // sum of the platforms' content-store blob sizes

@AkihiroSuda AkihiroSuda Jul 22, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Non-tree mode should use the new size definition too

So I suggest working on it before --tree

Expected: func(data test.Data, helpers test.Helpers) *test.Expected {
return &test.Expected{
Output: expect.All(
expect.Contains("IMAGE", "ID", "DISK USAGE", "CONTENT SIZE", "IN USE"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

DISK USAGE and CONTENT SIZE should be tested.
The expected sizes should be defined in testutil.

testCase := &test.Case{
// `docker image ls --tree` is experimental and requires the containerd
// image store, so keep this test nerdctl-only.
Require: require.Not(nerdtest.Docker),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the containerd image store is now enabled in Docker, so this test should not be skipped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

nerdctl images lacks --tree

2 participants