Docker build and UilttiuyVM: The parameter is incorrect - Failed to regis error

The following error can occur when doing a Docker build.

Docker image

Docker . failed to register layer: re-exec error: exit status 1: output: processUtilityWImage

[\\?\C:\ProgramData\docker\windowsfilter](file:///\%3f\C:\ProgramData\docker\windowsfilter) \UtilityVM: The parameter is incorrect.

At line: 2 char: 1

+ Docker build - -tag tw/gp2018 .

+ CategoryInfo :NotSpecified: (failed to regis…r is incorrect.:String) []. Remote Exception

+FullyQualifiedErrorId : NativeCommnadError

On a windows build, this is often due to the base image not being compatible with operating system of the Docker host machine.

For example, I moved my dockerfile and build directory from Windows 10 to Windows Server 2016 and experienced this error.

Turns out that the windowscore I was attempting to use was not compatible.

See here https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/version-compatibility for the guide on the windows container versions compatible with different hosts.

dockercompat

I was attempting to use microsoft/windowsservercore:1803, but the only version that is compatible on Server 2016, from the above table, without using Hyper-V isolation (where a small Linux machine is used to host container), is build 14393.

Thus in my dockerfile, changing the base image instruction to

FROM microsoft/windowsservercore:ltsc2016

solved the above error on the server host.

The reason is obvious really, Docker works by sharing the underlying kernel from the host with the containers, overlaying layers of files until you reach the image. Changes to the host operating system will adversely affect this layering, as expected components may not be present that were there when the image was created. The container my start but fail later.

Using Hyper-V isolation works, as the Hyper-V isolation introduces its own kernel instead of the host’s thus isolating the container from the host operating system. This still gives us benefits if multiple containers are ran, and the benefits of portability are still present, but less efficient on disk storage. Use the switch parameter –isolation=hyperv to enable this isolation.