'Docker build fails always with error hcsshim::PrepareLayer - failed failed in Win32: Incorrect function. (0x1) Windows Containers

Steps to reproduce are very easy.

Create a Dockerfile.

My Dockerfile has many more lines, but I have trimmed them so we can focus in the source of the problem.

Said that, these two lines alone (without anything more) show the problem.

FROM microsoft/iis
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue'; $VerbosePreference = 'Continue'; "]

Run docker build . and you get hcsshim::PrepareLayer - failed failed in Win32: Función incorrecta. (0x1).

Windows 10 Pro 1909 (but it happened too in 1903)

Docker version: 2.1.0.5

Engine: 19.03.5

Machine: 0.16.2



Solution 1:[1]

I have found the solution to the problem.

Reading all the https://github.com/docker/for-win/issues/3884 bug, some have found a simple solution: rename C:\windows\system32\driver\cbfsconnect2017.sys so it isn't loaded the next boot.

Disabling that driver enables me to do a docker build for the first time in windows containers in almost a year.

In my case Box Sync was the one using that driver.

EDIT: @GustavoTM have found that pCloud raises the same problem. EDIT2: @VonC have noticed that some people in the issue in GitHub has solved it deleting this other file: C:\Windows\System32\drivers\cbfs6.sys. I haven't tried that, but i put it if it helps others.

The good thing is that I don't need to uninstall Box, but only rename that file.

Solution 2:[2]

This is still an issue (still open) with Win10. Looks like uninstalling cloud storage providers with file system filters like Dropbox, Box, etc. as a workaround is an option for some users.

Deinstall cloud storage providers or virus scanners; if you identify which one is not working please share in https://github.com/docker/for-win/issues/3884

Solution 3:[3]

In my case was the problem similar but the file cbfs6.sys was placed somewhere in the rest of uninstalled application Jungle disk, somewhere in the folder c:\Program files\Jungle disk .... It's part of Callback File System signed by EldoS Corporation.

The folder could be rename only and not delete directly. So I could delete its immediately after the PC restart, before running the Docker. So it could be delete during the Docker service restart too.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Diego B
Solution 3 Tom