From 2f1a32e3e50df6e15e6d295a2f14ddf40190434a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Thu, 7 Mar 2024 16:22:32 +0100 Subject: [PATCH] c8d/list: Skip images with non matching platform MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Currently this won't have any real effect because the platform matcher matches all platform and is only used for sorting. Signed-off-by: Paweł Gronowski --- daemon/containerd/image_list.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/daemon/containerd/image_list.go b/daemon/containerd/image_list.go index d1ff7cd7b1..3a6e370248 100644 --- a/daemon/containerd/image_list.go +++ b/daemon/containerd/image_list.go @@ -262,6 +262,14 @@ func (i *ImageService) imageSummary(ctx context.Context, img images.Image, platf platform = dockerImage.Platform } + // Filter out platforms that don't match the requested platform. Do it + // after the size, container count and chainIDs are summed up to have + // the single combined entry still represent the whole multi-platform + // image. + if !platformMatcher.Match(platform) { + return nil + } + if best == nil || platformMatcher.Less(platform, bestPlatform) { best = img bestPlatform = platform