2015-04-27 12:25:38 -04:00
|
|
|
// +build windows
|
|
|
|
|
|
|
|
package daemon
|
|
|
|
|
2015-06-03 12:26:41 -04:00
|
|
|
import (
|
2015-11-03 14:25:22 -05:00
|
|
|
"sort"
|
|
|
|
|
2015-11-12 14:55:17 -05:00
|
|
|
"github.com/docker/docker/container"
|
2015-06-03 12:26:41 -04:00
|
|
|
"github.com/docker/docker/daemon/execdriver"
|
2015-09-09 22:23:06 -04:00
|
|
|
derr "github.com/docker/docker/errors"
|
|
|
|
"github.com/docker/docker/volume"
|
2015-06-03 12:26:41 -04:00
|
|
|
)
|
2015-05-19 16:05:25 -04:00
|
|
|
|
2015-09-09 22:23:06 -04:00
|
|
|
// setupMounts configures the mount points for a container by appending each
|
|
|
|
// of the configured mounts on the container to the execdriver mount structure
|
|
|
|
// which will ultimately be passed into the exec driver during container creation.
|
|
|
|
// It also ensures each of the mounts are lexographically sorted.
|
2015-11-12 14:55:17 -05:00
|
|
|
func (daemon *Daemon) setupMounts(container *container.Container) ([]execdriver.Mount, error) {
|
2015-09-09 22:23:06 -04:00
|
|
|
var mnts []execdriver.Mount
|
|
|
|
for _, mount := range container.MountPoints { // type is volume.MountPoint
|
2016-01-12 17:18:57 -05:00
|
|
|
if err := daemon.lazyInitializeVolume(container.ID, mount); err != nil {
|
|
|
|
return nil, err
|
2015-12-09 14:39:31 -05:00
|
|
|
}
|
2015-09-09 22:23:06 -04:00
|
|
|
// If there is no source, take it from the volume path
|
|
|
|
s := mount.Source
|
|
|
|
if s == "" && mount.Volume != nil {
|
|
|
|
s = mount.Volume.Path()
|
|
|
|
}
|
|
|
|
if s == "" {
|
|
|
|
return nil, derr.ErrorCodeVolumeNoSourceForMount.WithArgs(mount.Name, mount.Driver, mount.Destination)
|
|
|
|
}
|
|
|
|
mnts = append(mnts, execdriver.Mount{
|
|
|
|
Source: s,
|
|
|
|
Destination: mount.Destination,
|
|
|
|
Writable: mount.RW,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Sort(mounts(mnts))
|
|
|
|
return mnts, nil
|
2015-04-29 18:53:35 -04:00
|
|
|
}
|
2015-06-08 16:45:28 -04:00
|
|
|
|
2015-09-09 22:23:06 -04:00
|
|
|
// setBindModeIfNull is platform specific processing which is a no-op on
|
|
|
|
// Windows.
|
|
|
|
func setBindModeIfNull(bind *volume.MountPoint) *volume.MountPoint {
|
|
|
|
return bind
|
|
|
|
}
|