|
@@ -774,14 +774,14 @@ func (container *Container) getBindMap() (map[string]BindMap, error) {
|
|
|
}
|
|
|
binds[path.Clean(dst)] = bindMap
|
|
|
}
|
|
|
- return binds, nil
|
|
|
+ return binds, nil
|
|
|
}
|
|
|
|
|
|
func (container *Container) createVolumes() error {
|
|
|
- binds, err := container.getBindMap()
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
+ binds, err := container.getBindMap()
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
volumesDriver := container.runtime.volumes.driver
|
|
|
// Create the requested volumes if they don't exist
|
|
|
for volPath := range container.Config.Volumes {
|
|
@@ -824,26 +824,25 @@ func (container *Container) createVolumes() error {
|
|
|
}
|
|
|
container.Volumes[volPath] = srcPath
|
|
|
container.VolumesRW[volPath] = srcRW
|
|
|
+
|
|
|
// Create the mountpoint
|
|
|
- rootVolPath := path.Join(container.RootfsPath(), volPath)
|
|
|
- if volIsDir {
|
|
|
- if err := os.MkdirAll(rootVolPath, 0755); err != nil {
|
|
|
- return err
|
|
|
- }
|
|
|
+ volPath = path.Join(container.RootfsPath(), volPath)
|
|
|
+ rootVolPath, err := utils.FollowSymlink(volPath, container.RootfsPath())
|
|
|
+ if err != nil {
|
|
|
+ panic(err)
|
|
|
}
|
|
|
|
|
|
- volPath = path.Join(container.RootfsPath(), volPath)
|
|
|
- if _, err := os.Stat(volPath); err != nil {
|
|
|
+ if _, err := os.Stat(rootVolPath); err != nil {
|
|
|
if os.IsNotExist(err) {
|
|
|
if volIsDir {
|
|
|
- if err := os.MkdirAll(volPath, 0755); err != nil {
|
|
|
+ if err := os.MkdirAll(rootVolPath, 0755); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
} else {
|
|
|
- if err := os.MkdirAll(path.Dir(volPath), 0755); err != nil {
|
|
|
+ if err := os.MkdirAll(path.Dir(rootVolPath), 0755); err != nil {
|
|
|
return err
|
|
|
}
|
|
|
- if f, err := os.OpenFile(volPath, os.O_CREATE, 0755); err != nil {
|
|
|
+ if f, err := os.OpenFile(rootVolPath, os.O_CREATE, 0755); err != nil {
|
|
|
return err
|
|
|
} else {
|
|
|
f.Close()
|