mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Windows: Don't create working dir for Hyper-V Containers
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
parent
bcc59fc951
commit
5849a55376
3 changed files with 22 additions and 2 deletions
|
@ -188,6 +188,13 @@ func (container *Container) SetupWorkingDirectory() error {
|
||||||
if container.Config.WorkingDir == "" {
|
if container.Config.WorkingDir == "" {
|
||||||
return nil
|
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)
|
container.Config.WorkingDir = filepath.Clean(container.Config.WorkingDir)
|
||||||
|
|
||||||
pth, err := container.GetResourcePath(container.Config.WorkingDir)
|
pth, err := container.GetResourcePath(container.Config.WorkingDir)
|
||||||
|
|
|
@ -727,3 +727,9 @@ func (container *Container) TmpfsMounts() []execdriver.Mount {
|
||||||
func cleanResourcePath(path string) string {
|
func cleanResourcePath(path string) string {
|
||||||
return filepath.Join(string(os.PathSeparator), path)
|
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
|
||||||
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
|
|
||||||
"github.com/docker/docker/daemon/execdriver"
|
"github.com/docker/docker/daemon/execdriver"
|
||||||
"github.com/docker/docker/volume"
|
"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
|
// 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
|
// UpdateContainer updates configuration of a container
|
||||||
func (container *Container) UpdateContainer(hostConfig *container.HostConfig) error {
|
func (container *Container) UpdateContainer(hostConfig *containertypes.HostConfig) error {
|
||||||
container.Lock()
|
container.Lock()
|
||||||
defer container.Unlock()
|
defer container.Unlock()
|
||||||
resources := hostConfig.Resources
|
resources := hostConfig.Resources
|
||||||
|
@ -83,3 +83,10 @@ func cleanResourcePath(path string) string {
|
||||||
}
|
}
|
||||||
return filepath.Join(string(os.PathSeparator), path)
|
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)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue