mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
system: df: fix SharedUsage on non-containerd
The value was calculated, but due to 0af2962fdd
changing to a non-pointer, the value was not written back to the resulting
slice.
Before this patch:
docker pull nginx:alpine
docker pull alpine
docker system df -v
Images space usage:
REPOSITORY TAG IMAGE ID CREATED SIZE SHARED SIZE UNIQUE SIZE CONTAINERS
nginx alpine cbad6347cca2 4 weeks ago 53.4MB N/A N/A 0
alpine latest 171e65262c80 7 weeks ago 8.51MB N/A N/A 0
With this patch:
docker system df -v
Images space usage:
REPOSITORY TAG IMAGE ID CREATED SIZE SHARED SIZE UNIQUE SIZE CONTAINERS
nginx alpine cbad6347cca2 4 weeks ago 53.4MB 8.512MB 44.91MB 0
alpine latest 171e65262c80 7 weeks ago 8.51MB 8.512MB 0B 0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -103,8 +103,7 @@ func (i *ImageService) Images(ctx context.Context, opts imagebackend.ListOptions
|
||||
}
|
||||
|
||||
var (
|
||||
summaries = make([]imagetypes.Summary, 0, len(selectedImages))
|
||||
summaryMap = make(map[*image.Image]imagetypes.Summary, len(selectedImages))
|
||||
summaryMap = make(map[*image.Image]*imagetypes.Summary, len(selectedImages))
|
||||
allContainers []*container.Container
|
||||
)
|
||||
for id, img := range selectedImages {
|
||||
@@ -210,8 +209,7 @@ func (i *ImageService) Images(ctx context.Context, opts imagebackend.ListOptions
|
||||
}
|
||||
}
|
||||
summary.Containers = containersCount
|
||||
summaryMap[img] = *summary
|
||||
summaries = append(summaries, *summary)
|
||||
summaryMap[img] = summary
|
||||
}
|
||||
|
||||
if opts.SharedSize {
|
||||
@@ -257,6 +255,10 @@ func (i *ImageService) Images(ctx context.Context, opts imagebackend.ListOptions
|
||||
}
|
||||
}
|
||||
|
||||
summaries := make([]imagetypes.Summary, 0, len(summaryMap))
|
||||
for _, summary := range summaryMap {
|
||||
summaries = append(summaries, *summary)
|
||||
}
|
||||
sort.Sort(sort.Reverse(byCreated(summaries)))
|
||||
|
||||
return summaries, nil
|
||||
|
||||
Reference in New Issue
Block a user