0

I am trying to run multiple Linux containers in Docker EE running on Windows server 2019. Everything is going well until I mount a single file to a container, like:

VOLUME:
 - c:\xxx\yyy.xml:/app/yyy.xml

When I spun up an instance I receive an error:

ERROR: for xxx Cannot create container for service s1: invalid volume specification: 'C:\Users\xxx\yyy.xml:/app/yyy.xml' invalid mount config for type "bind": source path must be a directory

Mounting a single file is possible in running Docker CE (on windows).

Is there a way get this working without too many custom workarounds?

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
tadejcek
  • 49
  • 1
  • 5
  • if any of the answers solved your issue please accept the appropriate answer to share the resolution with the community. If not please provide further information or share your own solution. Thank you – ckaserer Dec 23 '19 at 08:54

2 Answers2

0

Sadly no - Here is the link to the relevant issue on github.

https://github.com/moby/moby/issues/30555

The gist of it...

thaJeztah wrote

Correct, bind-mounting files is not possible on Windows. On Linux, there's also quite some pitfalls though, so mounting a directory is preferred in many situations.

However, Drewster727 pointed out the following

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 }

ckaserer
  • 4,827
  • 3
  • 18
  • 33
0

For Windows bound volumes, you have to format the path like this:

VOLUME:
 - /c/xxx/yyy.xml:/app/yyy.xml

I created a handy AutoHotkey script to make creating Docker-formatted Windows paths a lot easier in Windows:

How to mount a host directory in a Docker container

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94