Skip to content

Commit 8ba7ce7

Browse files
committed
EnsureAllContent on commit
Signed-off-by: apostasie <[email protected]>
1 parent 9539f6b commit 8ba7ce7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

pkg/imgutil/commit/commit.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import (
4646

4747
"github.com/containerd/nerdctl/v2/pkg/api/types"
4848
"github.com/containerd/nerdctl/v2/pkg/clientutil"
49+
"github.com/containerd/nerdctl/v2/pkg/cmd/image"
4950
"github.com/containerd/nerdctl/v2/pkg/containerutil"
5051
imgutil "github.com/containerd/nerdctl/v2/pkg/imgutil"
5152
"github.com/containerd/nerdctl/v2/pkg/labels"
@@ -126,6 +127,13 @@ func Commit(ctx context.Context, client *containerd.Client, container containerd
126127
return emptyDigest, err
127128
}
128129

130+
// Ensure all the layers are here: https://github.com/containerd/nerdctl/issues/3425
131+
err = image.EnsureAllContent(ctx, client, baseImg.Name(), globalOptions)
132+
if err != nil {
133+
log.G(ctx).Warn("Unable to fetch missing layers before committing. " +
134+
"If you try to save or push this image, it might fail. See https://github.com/containerd/nerdctl/issues/3439.")
135+
}
136+
129137
if opts.Pause {
130138
task, err := container.Task(ctx, cio.Load)
131139
if err != nil {

0 commit comments

Comments
 (0)