diff options
author | David Calavera <david.calavera@gmail.com> | 2016-03-01 17:11:37 -0800 |
---|---|---|
committer | David Calavera <david.calavera@gmail.com> | 2016-03-01 17:11:37 -0800 |
commit | 7f223b72dd826c1f925b01d159a97c28983ed07b (patch) | |
tree | df1d85950d475836543a5d318288e6ffdfa980bd | |
parent | 3c4d093babb6f4f4f8343f5c364c5229a9d96ba3 (diff) | |
parent | 5849a5537607f991898247c75e9298492318c7b1 (diff) | |
download | docker-nl.tar.gz |
Merge pull request #20828 from Microsoft/jjh/xenonworkdirfixnl
Windows: Don't create working dir for Hyper-V Containers
-rw-r--r-- | container/container.go | 7 | ||||
-rw-r--r-- | container/container_unix.go | 6 | ||||
-rw-r--r-- | container/container_windows.go | 11 |
3 files changed, 22 insertions, 2 deletions
diff --git a/container/container.go b/container/container.go index ad4e728663..4c577695d5 100644 --- a/container/container.go +++ b/container/container.go @@ -188,6 +188,13 @@ func (container *Container) SetupWorkingDirectory() error { if container.Config.WorkingDir == "" { return nil } + + // If can't mount container FS at this point (eg Hyper-V Containers on + // Windows) bail out now with no action. + if !container.canMountFS() { + return nil + } + container.Config.WorkingDir = filepath.Clean(container.Config.WorkingDir) pth, err := container.GetResourcePath(container.Config.WorkingDir) diff --git a/container/container_unix.go b/container/container_unix.go index ab4fb4154e..3fdafbffcc 100644 --- a/container/container_unix.go +++ b/container/container_unix.go @@ -727,3 +727,9 @@ func (container *Container) TmpfsMounts() []execdriver.Mount { func cleanResourcePath(path string) string { return filepath.Join(string(os.PathSeparator), path) } + +// canMountFS determines if the file system for the container +// can be mounted locally. A no-op on non-Windows platforms +func (container *Container) canMountFS() bool { + return true +} diff --git a/container/container_windows.go b/container/container_windows.go index a0ca88b3d3..18c7e0b0ff 100644 --- a/container/container_windows.go +++ b/container/container_windows.go @@ -9,7 +9,7 @@ import ( "github.com/docker/docker/daemon/execdriver" "github.com/docker/docker/volume" - "github.com/docker/engine-api/types/container" + containertypes "github.com/docker/engine-api/types/container" ) // Container holds fields specific to the Windows implementation. See @@ -47,7 +47,7 @@ func (container *Container) TmpfsMounts() []execdriver.Mount { } // UpdateContainer updates configuration of a container -func (container *Container) UpdateContainer(hostConfig *container.HostConfig) error { +func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfig) error { container.Lock() defer container.Unlock() resources := hostConfig.Resources @@ -83,3 +83,10 @@ func cleanResourcePath(path string) string { } return filepath.Join(string(os.PathSeparator), path) } + +// canMountFS determines if the file system for the container +// can be mounted locally. In the case of Windows, this is not possible +// for Hyper-V containers during WORKDIR execution for example. +func (container *Container) canMountFS() bool { + return !containertypes.Isolation.IsHyperV(container.HostConfig.Isolation) +} |