moby: Unable to map files into Windows container

Expected behavior

Mapping a file should show the file in the container.

Actual behavior

Mapping a file or a directory both work on Linux. Mapping a file fails on Windowsm with Windows Containers.

Information

Docker: 1.13.0-rc5-beta35 (9606) OS: Windows 10 (1607 - Anniversary edition) and Windows Server 2016 with containers (Azure)

Steps to reproduce the behavior

docker run -v C:\users\ramon\test:C:\test nanoserver cmd /c dir \

Error response from daemon: invalid bind mount spec "C:\\users\\ramon\\test.config:C:\\test.config": invalid volume specification: 'C:\users\ramon\test.config:C:\test.config': invalid mount config for type "bind": source path must be a directory.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I think mounting files is now possible in Windows Server 2019 (RS5 and up)

Unfortunately, it still doesn’t work. I gave it a try on Windows 10 version 1903 (aka Windows 10 May 2019 Update).

PS C:\> docker run --rm -it `
          -v "C:\Program Files\Docker\Docker\Resources\bin\docker.exe:C:\Program Files\Docker\Docker\Resources\bin\docker.exe:ro" `
          -v //./pipe/docker_engine://./pipe/docker_engine `
          mcr.microsoft.com/windows/servercore:1903

docker: Error response from daemon: invalid volume specification: 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe:C:\Program Files\Docker\Docker\Resources\bin\docker.exe:ro': invalid mount config for type "bind": source path must be a directory.
See 'docker run --help'.

For some context on my situtation–

We’re running apps in the legacy .NET framework world (/sad-face) – we have .config files mixed in with our application binaries. We don’t want to build environment-specific containers, so of course, we try to share config files that have been transformed per environment directly inside the container to the location our application expects them.

In case it helps anyone, I have a simple entrypoint.ps1 script hack to get around this issue for now. Share a directory to c:\conf with config files in it, the script will copy them into the app context folder on start:

if(Test-Path c:\conf){
    Copy-Item -path c:\conf\*.* -Recurse -Destination . -Force
}