diff --git a/daemon/containerd/image_history.go b/daemon/containerd/image_history.go index e9a4738c68..a49cdd0ad8 100644 --- a/daemon/containerd/image_history.go +++ b/daemon/containerd/image_history.go @@ -121,7 +121,8 @@ func (i *ImageService) ImageHistory(ctx context.Context, name string) ([]*imaget foundNext := false for _, img := range parents { - if _, ok := img.Labels[imageLabelClassicBuilderParent]; ok { + _, hasLabel := img.Labels[imageLabelClassicBuilderParent] + if !foundNext || hasLabel { currentImg = img foundNext = true }