github.com/moby/docker@v26.1.3+incompatible/daemon/containerd/service_windows.go (about)

     1  package containerd
     2  
     3  import (
     4  	"context"
     5  
     6  	"github.com/docker/docker/image"
     7  	"github.com/docker/docker/layer"
     8  	"github.com/pkg/errors"
     9  )
    10  
    11  // GetLayerFolders returns the layer folders from an image RootFS.
    12  func (i *ImageService) GetLayerFolders(img *image.Image, rwLayer layer.RWLayer, containerID string) ([]string, error) {
    13  	if rwLayer != nil {
    14  		return nil, errors.New("RWLayer is unexpectedly not nil")
    15  	}
    16  
    17  	snapshotter := i.client.SnapshotService(i.StorageDriver())
    18  	mounts, err := snapshotter.Mounts(context.TODO(), containerID)
    19  	if err != nil {
    20  		return nil, errors.Wrapf(err, "snapshotter.Mounts failed: container %s", containerID)
    21  	}
    22  
    23  	// This is the same logic used by the hcsshim containerd runtime shim's createInternal
    24  	// to convert an array of Mounts into windows layers.
    25  	// See https://github.com/microsoft/hcsshim/blob/release/0.11/cmd/containerd-shim-runhcs-v1/service_internal.go
    26  	parentPaths, err := mounts[0].GetParentPaths()
    27  	if err != nil {
    28  		return nil, errors.Wrapf(err, "GetParentPaths failed: container %s", containerID)
    29  	}
    30  	return append(parentPaths, mounts[0].Source), nil
    31  }