github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/daemon/volumes_windows.go (about)

     1  // +build windows
     2  
     3  package daemon
     4  
     5  import (
     6  	"fmt"
     7  	"sort"
     8  
     9  	"github.com/docker/docker/container"
    10  	"github.com/docker/docker/volume"
    11  )
    12  
    13  // setupMounts configures the mount points for a container by appending each
    14  // of the configured mounts on the container to the OCI mount structure
    15  // which will ultimately be passed into the oci runtime during container creation.
    16  // It also ensures each of the mounts are lexographically sorted.
    17  
    18  // BUGBUG TODO Windows containerd. This would be much better if it returned
    19  // an array of windowsoci mounts, not container mounts. Then no need to
    20  // do multiple transitions.
    21  
    22  func (daemon *Daemon) setupMounts(c *container.Container) ([]container.Mount, error) {
    23  	var mnts []container.Mount
    24  	for _, mount := range c.MountPoints { // type is volume.MountPoint
    25  		if err := daemon.lazyInitializeVolume(c.ID, mount); err != nil {
    26  			return nil, err
    27  		}
    28  		// If there is no source, take it from the volume path
    29  		s := mount.Source
    30  		if s == "" && mount.Volume != nil {
    31  			s = mount.Volume.Path()
    32  		}
    33  		if s == "" {
    34  			return nil, fmt.Errorf("No source for mount name '%s' driver %q destination '%s'", mount.Name, mount.Driver, mount.Destination)
    35  		}
    36  		mnts = append(mnts, container.Mount{
    37  			Source:      s,
    38  			Destination: mount.Destination,
    39  			Writable:    mount.RW,
    40  		})
    41  	}
    42  
    43  	sort.Sort(mounts(mnts))
    44  	return mnts, nil
    45  }
    46  
    47  // setBindModeIfNull is platform specific processing which is a no-op on
    48  // Windows.
    49  func setBindModeIfNull(bind *volume.MountPoint) *volume.MountPoint {
    50  	return bind
    51  }