windows - 错误无效的 Windows 挂载类型:Windows 容器的 Windows 10 docker 构建上的“绑定”
问题描述
我刚刚安装了最新的 Windows 10 Pro 20H2。安装 Docker Desktop 并将其切换为 Windows 容器后,它要求我执行以下操作
Enable-WindowsOptionalFeature -Online -FeatureName $("Microsoft-Hyper-V", "Containers") -All
完成后,我的电脑重新启动,一切看起来都很好。然后我将以下内容保存Dockerfile
在我的文档下的一个空目录中。我之前在 CI 系统中成功构建了这个 Dockerfile,但我想在我的机器中构建以加快开发周期。
FROM mcr.microsoft.com/windows/servercore:ltsc2019
RUN powershell -NoLogo -NoProfile -Command \
netsh interface ipv4 show interfaces ; \
netsh interface ipv4 set subinterface 18 mtu=1460 store=persistent ; \
netsh interface ipv4 show interfaces ; \
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) ; \
choco install -y --no-progress git --params "/GitAndUnixToolsOnPath" ; \
choco install -y --no-progress 7zip ; \
Remove-Item C:\ProgramData\chocolatey\logs -Force -Recurse ;
我想构建这个 Dockerfile,所以在包含它的目录上,在 Powershell 中我输入:
docker build .
但我得到了错误:
[+] Building 0.0s (2/2) FINISHED
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 646B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
failed to solve with frontend dockerfile.v0: failed to read dockerfile: failed to mount C:\ProgramData\Docker\tmp\buildkit-mount316756066: [{Type:bind Source:C:\ProgramData\Docker\windowsfilter\exjneuxdwo67rh9g5rfomdpc2 Options:[rbind ro]}]: invalid windows mount type: 'bind'
这是什么错误invalid windows mount type: 'bind'
?
docker --version
Docker version 19.03.13, build 4484c46d9d`
我还关注了这里的文档:https ://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/building-sample-app但仍然遇到同样的invalid windows mount type: 'bind'
错误。
解决方案
在 docker 设置中,确保buildkit
设置false
如下:
"features": {
"buildkit": false
}
在应用并成功重新启动后,构建应该继续。
在文档中,目前提到 BuildKit 是“仅支持构建 Linux 容器”的功能:https ://docs.docker.com/develop/develop-images/build_enhancements/
不幸的是,在全新安装中,它的值默认为 true,并且在切换到 Windows 容器时不会更改为 false。
推荐阅读
- html - 无法根据中心原点旋转齿轮
- virtual-reality - 是否可以使用 openvr 为 HMD 中的显示添加失真?
- c# - ASP .NET Core:如何缓存依赖于用户输入的数据?
- jquery - kendo ui jquery工具栏按钮徽章不起作用
- c++ - 按其子元素之一对 QJsonArray 进行排序
- computer-vision - RetinaNet 中的焦点损失
- mongodb - 如何在 MongoDB 中将集合导出到 TSV
- axis2 - 无法使用 jibx 解析解组 xsi:nil=true
- github - 如何使用 ssh_rsa 密钥对创建从 jupyter notebook 到 github 的永久登录
- mysql - 按两个表分组,然后附加结果并删除重复项