MCPcopy
hub / github.com/containerd/containerd / WithSnapshot

Function WithSnapshot

client/container_opts.go:203–221  ·  view source on GitHub ↗

WithSnapshot uses an existing root filesystem for the container

(id string)

Source from the content-addressed store, hash-verified

201
202// WithSnapshot uses an existing root filesystem for the container
203func WithSnapshot(id string) NewContainerOpts {
204 return func(ctx context.Context, client *Client, c *containers.Container) error {
205 // check that the snapshot exists, if not, fail on creation
206 var err error
207 c.Snapshotter, err = client.resolveSnapshotterName(ctx, c.Snapshotter)
208 if err != nil {
209 return err
210 }
211 s, err := client.getSnapshotter(ctx, c.Snapshotter)
212 if err != nil {
213 return err
214 }
215 if _, err := s.Mounts(ctx, id); err != nil {
216 return err
217 }
218 c.SnapshotKey = id
219 return nil
220 }
221}
222
223// WithSnapshotCleanup deletes the rootfs snapshot allocated for the container
224func WithSnapshotCleanup(ctx context.Context, client *Client, c containers.Container) error {

Callers

nothing calls this directly

Calls 3

MountsMethod · 0.65
getSnapshotterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…