MCPcopy Create free account
hub / github.com/containerd/nerdctl / mountSnapshotForContainer

Function mountSnapshotForContainer

pkg/containerutil/cp_linux.go:363–389  ·  view source on GitHub ↗
(ctx context.Context, client *containerd.Client, conInfo containers.Container, snapshotter string)

Source from the content-addressed store, hash-verified

361}
362
363func mountSnapshotForContainer(ctx context.Context, client *containerd.Client, conInfo containers.Container, snapshotter string) (string, func() error, error) {
364 snapKey := conInfo.SnapshotKey
365 resp, err := client.SnapshotService(snapshotter).Mounts(ctx, snapKey)
366 if err != nil {
367 return "", nil, err
368 }
369
370 tempDir, err := os.MkdirTemp("", "nerdctl-cp-")
371 if err != nil {
372 return "", nil, err
373 }
374
375 err = mount.All(resp, tempDir)
376 if err != nil {
377 return "", nil, err
378 }
379
380 cleanup := func() error {
381 err = mount.Unmount(tempDir, 0)
382 if err != nil {
383 return err
384 }
385 return os.RemoveAll(tempDir)
386 }
387
388 return tempDir, cleanup, nil
389}

Callers 1

CopyFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…