github.com/ojongerius/docker@v1.11.2/daemon/create_windows.go (about) 1 package daemon 2 3 import ( 4 "fmt" 5 6 "github.com/docker/docker/container" 7 "github.com/docker/docker/pkg/stringid" 8 "github.com/docker/docker/volume" 9 containertypes "github.com/docker/engine-api/types/container" 10 ) 11 12 // createContainerPlatformSpecificSettings performs platform specific container create functionality 13 func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig) error { 14 for spec := range config.Volumes { 15 16 mp, err := volume.ParseMountSpec(spec, hostConfig.VolumeDriver) 17 if err != nil { 18 return fmt.Errorf("Unrecognised volume spec: %v", err) 19 } 20 21 // If the mountpoint doesn't have a name, generate one. 22 if len(mp.Name) == 0 { 23 mp.Name = stringid.GenerateNonCryptoID() 24 } 25 26 // Skip volumes for which we already have something mounted on that 27 // destination because of a --volume-from. 28 if container.IsDestinationMounted(mp.Destination) { 29 continue 30 } 31 32 volumeDriver := hostConfig.VolumeDriver 33 34 // Create the volume in the volume driver. If it doesn't exist, 35 // a new one will be created. 36 v, err := daemon.volumes.CreateWithRef(mp.Name, volumeDriver, container.ID, nil, nil) 37 if err != nil { 38 return err 39 } 40 41 // FIXME Windows: This code block is present in the Linux version and 42 // allows the contents to be copied to the container FS prior to it 43 // being started. However, the function utilizes the FollowSymLinkInScope 44 // path which does not cope with Windows volume-style file paths. There 45 // is a separate effort to resolve this (@swernli), so this processing 46 // is deferred for now. A case where this would be useful is when 47 // a dockerfile includes a VOLUME statement, but something is created 48 // in that directory during the dockerfile processing. What this means 49 // on Windows for TP4 is that in that scenario, the contents will not 50 // copied, but that's (somewhat) OK as HCS will bomb out soon after 51 // at it doesn't support mapped directories which have contents in the 52 // destination path anyway. 53 // 54 // Example for repro later: 55 // FROM windowsservercore 56 // RUN mkdir c:\myvol 57 // RUN copy c:\windows\system32\ntdll.dll c:\myvol 58 // VOLUME "c:\myvol" 59 // 60 // Then 61 // docker build -t vol . 62 // docker run -it --rm vol cmd <-- This is where HCS will error out. 63 // 64 // // never attempt to copy existing content in a container FS to a shared volume 65 // if v.DriverName() == volume.DefaultDriverName { 66 // if err := container.CopyImagePathContent(v, mp.Destination); err != nil { 67 // return err 68 // } 69 // } 70 71 // Add it to container.MountPoints 72 container.AddMountPointWithVolume(mp.Destination, v, mp.RW) 73 } 74 return nil 75 }