diff --git a/container/container.go b/container/container.go index 35f9b38685..fc4fe2717f 100644 --- a/container/container.go +++ b/container/container.go @@ -229,12 +229,6 @@ func (container *Container) SetupWorkingDirectory(rootUID, rootGID int) error { container.Config.WorkingDir = filepath.Clean(container.Config.WorkingDir) - // 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 - } - pth, err := container.GetResourcePath(container.Config.WorkingDir) if err != nil { return err diff --git a/container/container_unix.go b/container/container_unix.go index f92d586204..4f6b795d2c 100644 --- a/container/container_unix.go +++ b/container/container_unix.go @@ -442,12 +442,6 @@ 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 -} - // EnableServiceDiscoveryOnDefaultNetwork Enable service discovery on default network func (container *Container) EnableServiceDiscoveryOnDefaultNetwork() bool { return false diff --git a/container/container_windows.go b/container/container_windows.go index b24aa3d845..1025836f1f 100644 --- a/container/container_windows.go +++ b/container/container_windows.go @@ -105,13 +105,6 @@ func (container *Container) BuildHostnameFile() error { return nil } -// 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) -} - // EnableServiceDiscoveryOnDefaultNetwork Enable service discovery on default network func (container *Container) EnableServiceDiscoveryOnDefaultNetwork() bool { return true diff --git a/daemon/oci_windows.go b/daemon/oci_windows.go index 778bb41c95..6e264243b4 100644 --- a/daemon/oci_windows.go +++ b/daemon/oci_windows.go @@ -18,11 +18,9 @@ func (daemon *Daemon) createSpec(c *container.Container) (*specs.Spec, error) { return nil, err } - // TODO Windows - this can be removed. Not used (UID/GID) - rootUID, rootGID := daemon.GetRemappedUIDGID() - if err := c.SetupWorkingDirectory(rootUID, rootGID); err != nil { - return nil, err - } + // Note, unlike Unix, we do NOT call into SetupWorkingDirectory as + // this is done in VMCompute. Further, we couldn't do it for Hyper-V + // containers anyway. // In base spec s.Hostname = c.FullHostname() diff --git a/docs/reference/builder.md b/docs/reference/builder.md index 369b25f9d1..6fa5a24150 100644 --- a/docs/reference/builder.md +++ b/docs/reference/builder.md @@ -1268,19 +1268,6 @@ For example: The output of the final `pwd` command in this `Dockerfile` would be `/path/$DIRNAME` -On Windows, `WORKDIR` behaves differently depending on whether using Windows -Server containers or Hyper-V containers. For Hyper-V containers, the engine -is, for architectural reasons, unable to create the directory if it does not -previously exist. For Windows Server containers, the directory is created -if it does not exist. Hence, for consistency between Windows Server and -Hyper-V containers, it is strongly recommended to include an explicit instruction -to create the directory in the Dockerfile. For example: - - # escape=` - FROM microsoft/nanoserver - RUN mkdir c:\myapp - WORKDIR c:\myapp - ## ARG ARG [=] diff --git a/integration-cli/docker_cli_run_test.go b/integration-cli/docker_cli_run_test.go index 58aec393c8..9462aef800 100644 --- a/integration-cli/docker_cli_run_test.go +++ b/integration-cli/docker_cli_run_test.go @@ -1787,7 +1787,7 @@ func (s *DockerSuite) TestRunWorkdirExistsAndIsFile(c *check.C) { expected := "not a directory" if daemonPlatform == "windows" { existingFile = `\windows\system32\ntdll.dll` - expected = `Cannot mkdir: \windows\system32\ntdll.dll is not a directory.` + expected = `The directory name is invalid.` } out, exitCode, err := dockerCmdWithError("run", "-w", existingFile, "busybox")