|
@@ -10,8 +10,6 @@ import (
|
|
"github.com/docker/docker/container"
|
|
"github.com/docker/docker/container"
|
|
"github.com/docker/docker/daemon/execdriver"
|
|
"github.com/docker/docker/daemon/execdriver"
|
|
"github.com/docker/docker/volume"
|
|
"github.com/docker/docker/volume"
|
|
- volumedrivers "github.com/docker/docker/volume/drivers"
|
|
|
|
- "github.com/docker/docker/volume/local"
|
|
|
|
)
|
|
)
|
|
|
|
|
|
// setupMounts iterates through each of the mount points for a container and
|
|
// setupMounts iterates through each of the mount points for a container and
|
|
@@ -70,53 +68,6 @@ func sortMounts(m []execdriver.Mount) []execdriver.Mount {
|
|
return m
|
|
return m
|
|
}
|
|
}
|
|
|
|
|
|
-// migrateVolume links the contents of a volume created pre Docker 1.7
|
|
|
|
-// into the location expected by the local driver.
|
|
|
|
-// It creates a symlink from DOCKER_ROOT/vfs/dir/VOLUME_ID to DOCKER_ROOT/volumes/VOLUME_ID/_container_data.
|
|
|
|
-// It preserves the volume json configuration generated pre Docker 1.7 to be able to
|
|
|
|
-// downgrade from Docker 1.7 to Docker 1.6 without losing volume compatibility.
|
|
|
|
-func migrateVolume(id, vfs string) error {
|
|
|
|
- l, err := volumedrivers.Lookup(volume.DefaultDriverName)
|
|
|
|
- if err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- newDataPath := l.(*local.Root).DataPath(id)
|
|
|
|
- fi, err := os.Stat(newDataPath)
|
|
|
|
- if err != nil && !os.IsNotExist(err) {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if fi != nil && fi.IsDir() {
|
|
|
|
- return nil
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return os.Symlink(vfs, newDataPath)
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-// validVolumeLayout checks whether the volume directory layout
|
|
|
|
-// is valid to work with Docker post 1.7 or not.
|
|
|
|
-func validVolumeLayout(files []os.FileInfo) bool {
|
|
|
|
- if len(files) == 1 && files[0].Name() == local.VolumeDataPathName && files[0].IsDir() {
|
|
|
|
- return true
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if len(files) != 2 {
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- for _, f := range files {
|
|
|
|
- if f.Name() == "config.json" ||
|
|
|
|
- (f.Name() == local.VolumeDataPathName && f.Mode()&os.ModeSymlink == os.ModeSymlink) {
|
|
|
|
- // Old volume configuration, we ignore it
|
|
|
|
- continue
|
|
|
|
- }
|
|
|
|
- return false
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return true
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
// setBindModeIfNull is platform specific processing to ensure the
|
|
// setBindModeIfNull is platform specific processing to ensure the
|
|
// shared mode is set to 'z' if it is null. This is called in the case
|
|
// shared mode is set to 'z' if it is null. This is called in the case
|
|
// of processing a named volume and not a typical bind.
|
|
// of processing a named volume and not a typical bind.
|