Also download container images during restore
If restoring a container from a checkpoint it was necessary that the
image the container is based was already available (podman pull).
This commit adds the image download to podman container restore if it
does not exist.
@@ -5,10 +5,12 @@ package adapter
import (
"context"
"github.com/containers/libpod/libpod"
+ "github.com/containers/libpod/libpod/image"
"github.com/containers/storage/pkg/archive"
jsoniter "github.com/json-iterator/go"
spec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/pkg/errors"
+ "io"
"io/ioutil"
"os"
"path/filepath"
@@ -83,6 +85,20 @@ func crImportCheckpoint(ctx context.Context, runtime *libpod.Runtime, input stri
return nil, errors.Errorf("Cannot import checkpoints of containers with named volumes or dependencies")
}
+ // The code to load the images is copied from create.go
+ var writer io.Writer
+ // In create.go this only set if '--quiet' does not exist.
+ writer = os.Stderr
+ rtc, err := runtime.GetConfig()
+ if err != nil {
+ return nil, err
+ }
+
+ _, err = runtime.ImageRuntime().New(ctx, config.RootfsImageName, rtc.SignaturePolicyPath, "", writer, nil, image.SigningOptions{}, false, nil)
+ if err != nil {
+ return nil, err
+ }
+
// Now create a new container from the just loaded information
container, err := runtime.RestoreContainer(ctx, spec, config)
if err != nil {
