volumes_windows.go 1.5 KB

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