diff --git a/buildfile.go b/buildfile.go index 959b085685..e4b3d28e9c 100644 --- a/buildfile.go +++ b/buildfile.go @@ -374,7 +374,7 @@ func (b *buildFile) checkPathForAddition(orig string) error { func (b *buildFile) addContext(container *runtime.Container, orig, dest string, remote bool) error { var ( origPath = path.Join(b.contextPath, orig) - destPath = path.Join(container.BasefsPath(), dest) + destPath = path.Join(container.RootfsPath(), dest) ) // Preserve the trailing '/' if strings.HasSuffix(dest, "/") { diff --git a/integration/utils_test.go b/integration/utils_test.go index 88f2cc49c3..53b4674df7 100644 --- a/integration/utils_test.go +++ b/integration/utils_test.go @@ -71,7 +71,7 @@ func containerFileExists(eng *engine.Engine, id, dir string, t utils.Fataler) bo t.Fatal(err) } defer c.Unmount() - if _, err := os.Stat(path.Join(c.BasefsPath(), dir)); err != nil { + if _, err := os.Stat(path.Join(c.RootfsPath(), dir)); err != nil { if os.IsNotExist(err) { return false } diff --git a/runtime/container.go b/runtime/container.go index 2a98149f27..ee545db201 100644 --- a/runtime/container.go +++ b/runtime/container.go @@ -532,7 +532,7 @@ func (container *Container) Start() (err error) { populateCommand(container) container.command.Env = env - if err := mountVolumesForContainer(container, envPath); err != nil { + if err := setupMountsForContainer(container, envPath); err != nil { return err } @@ -843,8 +843,6 @@ func (container *Container) cleanup() { } } - unmountVolumesForContainer(container) - if err := container.Unmount(); err != nil { log.Printf("%v: Failed to umount filesystem: %v", container.ID, err) } @@ -1039,12 +1037,6 @@ func (container *Container) EnvConfigPath() (string, error) { // This method must be exported to be used from the lxc template // This directory is only usable when the container is running func (container *Container) RootfsPath() string { - return path.Join(container.root, "root") -} - -// This is the stand-alone version of the root fs, without any additional mounts. -// This directory is usable whenever the container is mounted (and not unmounted) -func (container *Container) BasefsPath() string { return container.basefs } diff --git a/runtime/runtime.go b/runtime/runtime.go index 28e7bbd1e4..b364d1d270 100644 --- a/runtime/runtime.go +++ b/runtime/runtime.go @@ -174,7 +174,6 @@ func (runtime *Runtime) Register(container *Container) error { runtime.execDriver.Kill(command, 9) } // ensure that the filesystem is also unmounted - unmountVolumesForContainer(container) if err := container.Unmount(); err != nil { utils.Debugf("ghost unmount error %s", err) } @@ -185,7 +184,6 @@ func (runtime *Runtime) Register(container *Container) error { utils.Debugf("Container %s was supposed to be running but is not.", container.ID) if runtime.config.AutoRestart { utils.Debugf("Restarting") - unmountVolumesForContainer(container) if err := container.Unmount(); err != nil { utils.Debugf("restart unmount error %s", err) } diff --git a/runtime/volumes.go b/runtime/volumes.go index 81a305f72c..9cb66aae44 100644 --- a/runtime/volumes.go +++ b/runtime/volumes.go @@ -4,10 +4,8 @@ import ( "fmt" "github.com/dotcloud/docker/archive" "github.com/dotcloud/docker/execdriver" - "github.com/dotcloud/docker/pkg/mount" "github.com/dotcloud/docker/utils" "io/ioutil" - "log" "os" "path/filepath" "strings" @@ -35,29 +33,9 @@ func prepareVolumesForContainer(container *Container) error { return nil } -func mountVolumesForContainer(container *Container, envPath string) error { - // Setup the root fs as a bind mount of the base fs - var ( - root = container.RootfsPath() - runtime = container.runtime - ) - if err := os.MkdirAll(root, 0755); err != nil && !os.IsExist(err) { - return nil - } - - // Create a bind mount of the base fs as a place where we can add mounts - // without affecting the ability to access the base fs - if err := mount.Mount(container.basefs, root, "none", "bind,rw"); err != nil { - return err - } - - // Make sure the root fs is private so the mounts here don't propagate to basefs - if err := mount.ForceMount(root, root, "none", "private"); err != nil { - return err - } - +func setupMountsForContainer(container *Container, envPath string) error { mounts := []execdriver.Mount{ - {runtime.sysInitPath, "/.dockerinit", false, true}, + {container.runtime.sysInitPath, "/.dockerinit", false, true}, {envPath, "/.dockerenv", false, true}, {container.ResolvConfPath, "/etc/resolv.conf", false, true}, } @@ -80,12 +58,6 @@ func mountVolumesForContainer(container *Container, envPath string) error { return nil } -func unmountVolumesForContainer(container *Container) { - if err := mount.Unmount(container.RootfsPath()); err != nil { - log.Printf("Failed to umount container: %v", err) - } -} - func applyVolumesFrom(container *Container) error { if container.Config.VolumesFrom != "" { for _, containerSpec := range strings.Split(container.Config.VolumesFrom, ",") {