Merge pull request #2160 from ijc/ctr-run-unpack

ctr: unpack the image on run if necessary
This commit is contained in:
Stephen Day 2018-03-06 19:29:43 -08:00 committed by GitHub
commit 5368984859
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,14 +68,24 @@ func NewContainer(ctx gocontext.Context, client *containerd.Client, context *cli
if context.Bool("rootfs") {
opts = append(opts, oci.WithRootFSPath(ref))
} else {
snapshotter := context.String("snapshotter")
image, err := client.GetImage(ctx, ref)
if err != nil {
return nil, err
}
unpacked, err := image.IsUnpacked(ctx, snapshotter)
if err != nil {
return nil, err
}
if !unpacked {
if err := image.Unpack(ctx, snapshotter); err != nil {
return nil, err
}
}
opts = append(opts, oci.WithImageConfig(image))
cOpts = append(cOpts,
containerd.WithImage(image),
containerd.WithSnapshotter(context.String("snapshotter")),
containerd.WithSnapshotter(snapshotter),
// Even when "readonly" is set, we don't use KindView snapshot here. (#1495)
// We pass writable snapshot to the OCI runtime, and the runtime remounts it as read-only,
// after creating some mount points on demand.