Mounting single file in docker running on windows server 2019 (error: Invalid volume specification...)
Mounting single file in docker running on windows server 2019 (error: Invalid volume specification...)
我正在尝试 运行 Linux 容器 Docker EE 运行ning on Windows服务器 2019。一切顺利,直到我将单个文件挂载到容器,例如:
VOLUME:
- c:\xxx\yyy.xml:/app/yyy.xml
当我启动实例时收到错误消息:
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
在 运行ning Docker CE(在 windows 上)可以挂载单个文件。
有没有办法在没有太多自定义解决方法的情况下使它工作?
遗憾的是没有 - 这是 github 上相关问题的 link。
https://github.com/moby/moby/issues/30555
要点...
thaJeztah 写道
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.
然而,Drewster727 指出了以下内容
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 }
对于 Windows 绑定卷,您必须像这样格式化路径:
VOLUME:
- /c/xxx/yyy.xml:/app/yyy.xml
我创建了一个方便的 AutoHotkey 脚本,使在 Windows 中创建 Docker 格式的 Windows 路径变得容易得多:
How to mount a host directory in a Docker container
我正在尝试 运行 Linux 容器 Docker EE 运行ning on Windows服务器 2019。一切顺利,直到我将单个文件挂载到容器,例如:
VOLUME:
- c:\xxx\yyy.xml:/app/yyy.xml
当我启动实例时收到错误消息:
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
在 运行ning Docker CE(在 windows 上)可以挂载单个文件。
有没有办法在没有太多自定义解决方法的情况下使它工作?
遗憾的是没有 - 这是 github 上相关问题的 link。
https://github.com/moby/moby/issues/30555
要点...
thaJeztah 写道
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.
然而,Drewster727 指出了以下内容
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 }
对于 Windows 绑定卷,您必须像这样格式化路径:
VOLUME:
- /c/xxx/yyy.xml:/app/yyy.xml
我创建了一个方便的 AutoHotkey 脚本,使在 Windows 中创建 Docker 格式的 Windows 路径变得容易得多:
How to mount a host directory in a Docker container