|
@@ -6,6 +6,7 @@ import (
|
|
"os"
|
|
"os"
|
|
"path/filepath"
|
|
"path/filepath"
|
|
|
|
|
|
|
|
+ "github.com/Sirupsen/logrus"
|
|
"github.com/docker/docker/container"
|
|
"github.com/docker/docker/container"
|
|
derr "github.com/docker/docker/errors"
|
|
derr "github.com/docker/docker/errors"
|
|
"github.com/docker/docker/image"
|
|
"github.com/docker/docker/image"
|
|
@@ -60,14 +61,24 @@ func (daemon *Daemon) createContainerPlatformSpecificSettings(container *contain
|
|
return err
|
|
return err
|
|
}
|
|
}
|
|
|
|
|
|
- // never attempt to copy existing content in a container FS to a shared volume
|
|
|
|
- if v.DriverName() == volume.DefaultDriverName {
|
|
|
|
- if err := container.CopyImagePathContent(v, destination); err != nil {
|
|
|
|
- return err
|
|
|
|
- }
|
|
|
|
|
|
+ container.AddMountPointWithVolume(destination, v, true)
|
|
|
|
+ }
|
|
|
|
+ return daemon.populateVolumes(container)
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// populateVolumes copies data from the container's rootfs into the volume for non-binds.
|
|
|
|
+// this is only called when the container is created.
|
|
|
|
+func (daemon *Daemon) populateVolumes(c *container.Container) error {
|
|
|
|
+ for _, mnt := range c.MountPoints {
|
|
|
|
+ // skip binds and volumes referenced by other containers (ie, volumes-from)
|
|
|
|
+ if mnt.Driver == "" || mnt.Volume == nil || len(daemon.volumes.Refs(mnt.Volume)) > 1 {
|
|
|
|
+ continue
|
|
}
|
|
}
|
|
|
|
|
|
- container.AddMountPointWithVolume(destination, v, true)
|
|
|
|
|
|
+ logrus.Debugf("copying image data from %s:%s, to %s", c.ID, mnt.Destination, mnt.Name)
|
|
|
|
+ if err := c.CopyImagePathContent(mnt.Volume, mnt.Destination); err != nil {
|
|
|
|
+ return err
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|