diff --git a/cli/command/image/tree.go b/cli/command/image/tree.go index a4f0761e92..64d32cd0e3 100644 --- a/cli/command/image/tree.go +++ b/cli/command/image/tree.go @@ -39,25 +39,30 @@ func runTree(ctx context.Context, dockerCLI command.Cli, opts treeOptions) error Used: img.Containers > 0, } + var totalContent int64 children := make([]subImage, 0, len(img.Manifests)) for _, im := range img.Manifests { if im.Kind != imagetypes.ManifestKindImage { continue } + im := im sub := subImage{ Platform: platforms.Format(im.ImageData.Platform), Available: im.Available, Details: imageDetails{ - ID: im.ID, - DiskUsage: units.HumanSizeWithPrecision(float64(im.Size.Total), 3), - Used: len(im.ImageData.Containers) > 0, + ID: im.ID, + DiskUsage: units.HumanSizeWithPrecision(float64(im.Size.Total), 3), + Used: len(im.ImageData.Containers) > 0, + ContentSize: units.HumanSizeWithPrecision(float64(im.Size.Content), 3), }, } + totalContent += im.Size.Content children = append(children, sub) } + details.ContentSize = units.HumanSizeWithPrecision(float64(totalContent), 3) view = append(view, topImage{ Names: img.RepoTags, Details: details, @@ -69,9 +74,10 @@ func runTree(ctx context.Context, dockerCLI command.Cli, opts treeOptions) error } type imageDetails struct { - ID string - DiskUsage string - Used bool + ID string + DiskUsage string + Used bool + ContentSize string } type topImage struct { @@ -125,6 +131,13 @@ func printImageTree(dockerCLI command.Cli, images []topImage) error { return d.DiskUsage }, }, + { + Title: "Content size", + Width: 12, + DetailsValue: func(d *imageDetails) string { + return d.ContentSize + }, + }, { Title: "Used", Width: 4,