@@ -43,6 +43,7 @@ import (
4343
4444 "github.com/containerd/nerdctl/v2/pkg/api/types"
4545 "github.com/containerd/nerdctl/v2/pkg/errutil"
46+ nerdconverter "github.com/containerd/nerdctl/v2/pkg/imgutil/converter"
4647 "github.com/containerd/nerdctl/v2/pkg/imgutil/dockerconfigresolver"
4748 "github.com/containerd/nerdctl/v2/pkg/imgutil/push"
4849 "github.com/containerd/nerdctl/v2/pkg/ipfs"
@@ -119,7 +120,12 @@ func Push(ctx context.Context, client *containerd.Client, rawRef string, options
119120 pushRef = ref + "-tmp-reduced-platform"
120121 // Push fails with "400 Bad Request" when the manifest is multi-platform but we do not locally have multi-platform blobs.
121122 // So we create a tmp reduced-platform image to avoid the error.
122- platImg , err := converter .Convert (ctx , client , pushRef , ref , converter .WithPlatform (platMC ))
123+ // Ensure all the layers are here: https://github.com/containerd/nerdctl/issues/3425
124+ err = EnsureAllContent (ctx , client , ref , platMC , options .GOptions )
125+ if err != nil {
126+ return err
127+ }
128+ platImg , err := nerdconverter .Convert (ctx , client , pushRef , ref , converter .WithPlatform (platMC ))
123129 if err != nil {
124130 if len (options .Platforms ) == 0 {
125131 return fmt .Errorf ("failed to create a tmp single-platform image %q: %w" , pushRef , err )
@@ -132,7 +138,7 @@ func Push(ctx context.Context, client *containerd.Client, rawRef string, options
132138
133139 if options .Estargz {
134140 pushRef = ref + "-tmp-esgz"
135- esgzImg , err := converter .Convert (ctx , client , pushRef , ref , converter .WithPlatform (platMC ), converter .WithLayerConvertFunc (eStargzConvertFunc ()))
141+ esgzImg , err := nerdconverter .Convert (ctx , client , pushRef , ref , converter .WithPlatform (platMC ), converter .WithLayerConvertFunc (eStargzConvertFunc ()))
136142 if err != nil {
137143 return fmt .Errorf ("failed to convert to eStargz: %v" , err )
138144 }
0 commit comments