windowsdockerdockerfilewindows-server-container

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


I just installed the latest Windows 10 Pro 20H2. After installing Docker Desktop and switching it for Windows containers, it asked me to do the following

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. I build this Dockerfile with success in a CI system before, but I want to build in my machine for quicker development cycle.

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:

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' ?

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

I also followed the docs here: https://learn.microsoft.com/en-us/virtualization/windowscontainers/quick-start/building-sample-app but still got the same invalid windows mount type: 'bind' error.


Solution

  • image

    In docker settings, make sure to have buildkit set to false as below:

      "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/

    Unfortunately in a fresh install it's value defaults to true and doesn't change to false when switching to Windows Containers.