Skip to content

feature request: import images without unpacking using ctr #3258

@BenTheElder

Description

@BenTheElder

👋 First off, thanks for all the awesome work on containerd!

Feature Request

I'd like to add the ability to call Import from the ctr command line without calling Unpack.
Specifically I'd like to add a --no-unpack option to ctr images load, in which case the command would return after:

imgs, err := client.Import(ctx, r, opts...)
closeErr := r.Close()
if err != nil {
return err
}
if closeErr != nil {
return closeErr
}

skipping the following:

log.G(ctx).Debugf("unpacking %d images", len(imgs))
for _, img := range imgs {
// TODO: Allow configuration of the platform
image := containerd.NewImage(client, img)
// TODO: Show unpack status
fmt.Printf("unpacking %s (%s)...", img.Name, img.Target.Digest)
err = image.Unpack(ctx, context.String("snapshotter"))
if err != nil {
return err
}
fmt.Println("done")
}
return nil

Why?

I'm building node images where Kubernetes's component images are preloaded into the containerd content store to provide fast air-gapped startup. In this case I only want to load images into the content store without unpacking them to a snapshotter.

Doing this results in a smaller image while still avoiding the need to pull images, the runtime cost of unpacking to the snapshotter seems to be small and preferable to the image size increase. I imagine this would be useful for others building airgapped images.

Context: https://github.com/kubernetes-sigs/kind, https://kind.sigs.k8s.io/

Why Not?

I could maintain a different tool specifically for this purpose, but I think this would fit into the existing ctr command trivially. If this feature is rejected I will likely wind up implementing such a tool instead.


Thanks!

cc @Random-Liu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions