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
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions cli/command/image/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,30 @@ func runTree(ctx context.Context, dockerCLI command.Cli, opts treeOptions) error

details.ContentSize = units.HumanSizeWithPrecision(float64(totalContent), 3)

view.images = append(view.images, topImage{
Names: img.RepoTags,
Details: details,
Children: children,
created: img.Created,
})
if len(img.RepoTags) == 0 {
// Untagged image
view.images = append(view.images, topImage{
Names: img.RepoTags,
Details: details,
Children: children,
created: img.Created,
})
} else {
// Sort same images alphabetically to keep a consistent sort order.
// We can remove this if we decide to sort the list by name, instead
// of by "created" date.
sort.Strings(img.RepoTags)

// Present images tagged under multiple names as separate images.
for _, n := range img.RepoTags {
view.images = append(view.images, topImage{
Names: []string{n}, // Consider changing Names to be a single name for purpose of this presentation.
Details: details,
Children: children,
created: img.Created,
})
}
}
}

sort.Slice(view.images, func(i, j int) bool {
Expand Down
Loading