简体   繁体   English

错误无效 windows 安装类型:Windows 上的“绑定”10 docker 构建 ZAEA23489CE3AA9B63406EBA 容器

[英]error invalid windows mount type: 'bind' on Windows 10 docker build of Windows container

I just installed the latest Windows 10 Pro 20H2.我刚刚安装了最新的 Windows 10 Pro 20H2。 After installing Docker Desktop and switching it for Windows containers, it asked me to do the following安装 Docker Desktop 并将其切换为 Windows 容器后,它要求我执行以下操作

Enable-WindowsOptionalFeature -Online -FeatureName $("Microsoft-Hyper-V", "Containers") -All

After this was done, my PC restarted and all seem good.完成后,我的电脑重新启动,一切看起来都很好。 Then I saved the Dockerfile below in an empty directory under my Documents.然后我将下面的Dockerfile保存在我的 Documents 下的一个空目录中。 I build this Dockerfile with success in a CI system before, but I want to build in my machine for quicker development cycle.我之前在 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 ;

I want to build this Dockerfile, so on the directory that contains it, in Powershell I typed:我想构建这个 Dockerfile,所以在包含它的目录上,在 Powershell 中我输入:

docker build .

But I got the error:但我得到了错误:

[+] 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'

What is this error invalid windows mount type: 'bind' ?这个错误是什么invalid windows mount type: 'bind'

docker --version
Docker version 19.03.13, build 4484c46d9d`

I also followed the docs here: https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/building-sample-app but still got the same invalid windows mount type: 'bind' error.我还关注了这里的文档: https://docs.microsoft.com/en-us/virtualization/windowscontainers/quick-start/building-sample-app但仍然得到相同的invalid windows mount type: 'bind'错误。

图片

In docker settings, make sure to have buildkit set to false as below:在 docker 设置中,确保将buildkit设置为false ,如下所示:

  "features": {
    "buildkit": false
  }

After this is applied and successfully restarted, the build should proceed.在应用并成功重新启动后,构建应该继续。

In the docs, it's currently mentioned BuildKit is a feature "only supported for building Linux containers": https://docs.docker.com/develop/develop-images/build_enhancements/在文档中,目前提到 BuildKit 是“仅支持构建 Linux 容器”的功能: https://docs.docker.com/build/develop-images/build-images/enhance

Unfortunately in a fresh install it's value defaults to true and doesn't change to false when switching to Windows Containers.不幸的是,在全新安装中,它的值默认为 true,并且在切换到 Windows 容器时不会更改为 false。

This is also impacted by the environment variable DOCKER_BUILDKIT , which can override the setting in the config file.这也受到环境变量DOCKER_BUILDKIT的影响,它可以覆盖配置文件中的设置。

A value of 1 enables it, a value of 0 disables it.1启用它,值0禁用它。

If flipping buildkit to false doesn't work for you:如果将 buildkit 翻转为 false 对您不起作用:

You should also be sure that your Visual Studio is running as Administrator.您还应该确保您的 Visual Studio 以管理员身份运行。 The Docker files for binding are not accessible otherwise.否则无法访问用于绑定的 Docker 文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM