hcsshim: hcsshim::ImportLayer failed in Win32: The system cannot find the path specified. (0x3) on Docker Desktop for Windows Community edition 2.3.0.3(45519)

I am/we are encountering “hcsshim::ImportLayer failed in Win32: The system cannot find the path specified. (0x3)” on Windows 10 Pro 1909 with Docker Community 19.03.8:

re-exec error: exit status 1: output: time="2020-06-05T14:05:25+09:00" level=error msg="hcsshim::ImportLayer - failed failed in Win32: The system cannot find the path specified. (0x3)" error="hcsshim::ImportLayer - failed failed in Win32: The system cannot find the path specified. (0x3)" importFolderPath="C:\\ProgramData\\Docker\\tmp\\hcs949648159" path="\\\\?\\C:\\ProgramData\\Docker\\windowsfilter\\3a7d2d6226be0f3cca2d17d5b29069918b0f14dd889484ecd8bb208329d382b8"
hcsshim::ImportLayer - failed failed in Win32: The system cannot find the path specified. (0x3)
> docker version
Client: Docker Engine - Community
 Version:           19.03.8
 API version:       1.40
 Go version:        go1.12.17
 Git commit:        afacb8b
 Built:             Wed Mar 11 01:23:10 2020
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          19.03.8
  API version:      1.40 (minimum version 1.24)
  Go version:       go1.12.17
  Git commit:       afacb8b
  Built:            Wed Mar 11 01:37:20 2020
  OS/Arch:          windows/amd64
  Experimental:     false

It happens during msys2 installation of the minimal reproducible Dockerfile:

# Reproducible (0x3) error docker file

FROM mcr.microsoft.com/windows/servercore:ltsc2019

# Do not split this into multiple RUN!
# Docker creates a layer for every RUN-Statement
RUN powershell -Command "Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"

# Fluentd depends on cool.io whose fat gem is only available for Ruby < 2.5, so need to specify --platform ruby when install Ruby > 2.5 and install msys2 to get dev tools
RUN choco install -y ruby --version 2.6.5.1 --params "'/InstallDir:C:\ruby26'" \

This issue is also happen with using mcr.microsoft.com/windows/servercore:1909 and mcr.microsoft.com/windows/servercore:1903 base images.

We also hit this issue with this Dockerfile.

And I didn’t solve this issue with using https://github.com/jhowardmsft/docker-ci-zap and delete all docker related data.

How should we avoid this issue?

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 18
  • Comments: 54 (4 by maintainers)

Most upvoted comments

I had this problem and solved it with the following steps: 1 ° I executed the following commands: to clear the images: docker images prune 2 ° I executed the one that cleans everything (Images, Containers, Cache and Networks) docker system prune

Why stop on that? Let’s reinstall Windows or even buy a new computer each time we want to build an image with VS Build Tools!

The goal is not to find a workaround. One of them is simply switching to Linux. The goal is to get adequate error reporting and to figure out why things cannot Just Work.

We’re still randomly facing this issue when building images based servercore:ltsc2022 images on EC2 build agents. None of the workarounds listed in this thread seem to have helped. What we tried:

  • Increasing VM CPU and memory
  • Storage-opts up to 150GB
  • Sleep at the end finishing the problematic build step
  • docker system prune and other system cleanups

This error does pop up randomly (about 30% of times) and we really can’t figure out what’s causing it.

I’m also experiencing this issue intermittently while trying to build a C++ buildtools image based on windows/servercore:ltsc2022. Sometimes the build succeeds and the resulting image works fine, but the vast majority of the time the build fails.

I’ve tried all the workarounds listed in this thread, assigning a larger data-root, increasing the storage-opts size, specifying a higher memory limit for the docker build, adding a sleep command, calling docker prune, allocating more resources to the VM, etc.

Nothing seems to reliably resolve the problem, but all the abovementioned changes sometimes will appear to work, giving a false sense of having finally solved the problem… only for the same error to occur again during the next image rebuild a few days later.

From me its a definite +1 to the idea of changing the error message to be less cryptic, or at least a way to inspect a detailed log of the conditions that lead to the error.

I solved this problem by allocating a 64 GB disk for my VMware Workstation Pro and initializing it as drive F:. In the DockerEngine settings, I provided Docker with a place to do its work with the data-root entry. { "registry-mirrors": [], "insecure-registries": [], "debug": false, "experimental": false, "data-root": "F:\\docker-root" }

I am experiencing exactly the same issue as @cosmo0920 when trying to create a docker container that uses choco install msys2. The docker version also matches. It runs on Windows 10 Enterprise 1809 and the base images is mcr.microsoft.com/dotnet/framework/runtime:4.8

I have some anecdotal evidence that may or may not be useful here.

We have a Dockerfile that writes a fairly large amount of data (installing Unity). Several of our on-premise Windows Server 2022 build machines (fully up-to-date, running Docker 27) are consistently failing to build the image with hcsshim::ImportLayer failed in Win32: The system cannot find the path specified during the layer commit stage. We have fully re-imaged and re-provisioned these machines from scratch multiple times, but still run into the issue each time.

Today, we took delivery of several new on-premise machines with updated specs, and provisioned them using an identical process to the old machines. The image built successfully first time on all of the new machines, and again multiple times each time after that. We’re at 10 out of 10 successful builds on each of the new machines now.

Our older machines were having issues with their NVMe drives, which is the reason we replaced them. I don’t currently have any real evidence to support this, but I suspect the health of the underlying disk could be a factor.

I’m not familiar enough with Windows to know how to debug the issue any further, but maybe this could be a clue for someone else.

@skaravos

I know you weren’t replying to me but I know that at least in my case I’m using windows/servercore:ltsc2022 as the base image and immediately installing visual studio build tools as the very first RUN instruction in the dockerfile, and yet I still get this error.

https://learn.microsoft.com/en-us/visualstudio/install/build-tools-container?view=vs-2022

If you base your image directly on microsoft/windowsservercore, the .NET Framework might not install properly and no install error is indicated. Managed code might not run after the install is complete. Instead, base your image on microsoft/dotnet-framework:4.8 or later. Also note that images that are tagged version 4.8 or later might use PowerShell as the default SHELL, which will cause the RUN and ENTRYPOINT instructions to fail.

That is, do not use windows/servercore:ltsc2022

mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022 - It looks preferable

Anyway, this error message is too cryptic and should better indicate what is the root of the problem. At least it should say what file it cannot find.

@kempniu @farzonl @schribl I run into same problem trying build an image with Cygwin. It seems that it is hardlinks which Cygwin uses a lot are not handled correctly by Docker. After I got rid of the hardlinks in Cygwin installation I was able to commit the image without problems. To get rid of the hardlinks I have zipped and unzipped Cygwin folder.

https://developercommunity.visualstudio.com/t/cant-install-build-tools-for-c-in-docker-container/1611877

@skaravos It helped me --installPath "%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools"

and I am outraged that this is not described anywhere in the documentation

I’ve encountered this with Engine 20.10.9 on Windows Server 2019 while building Boost libraries with VS Build Tools and Windows PowerShell. The data root is set to a directory on a secondary drive that’s dedicated to Docker and has plenty of free space. Increasing the storage-opts, pruning or a complete reinstall (including removal of files under Program Files, ProgramData and the data root) didn’t help. Both the dockerd process and data root are excluded from Defender scans.

What helped, was adding a wait at the end of the RUN script:

sleep -Seconds 300

Why does that work, I have no idea. There shouldn’t be anything interfering with the filesystem.

Paradoxically the VS Build Tools and Chocolatey + CMake installation in one of the previous steps is not a problem.

I got to a point where I had an image that kept dying at build time after a few steps even though I had just about enough free space as the last final image size from the previous build, but it seems a lot of extra space is necessary while building and while running.

Neither hcsshim nor Docker Desktop for Windows gave any comprehensive errors that space was an issue. 🤷‍♂️

As pointed above, I too solved this error by pointing "data-root" to a bigger drive and rebuilding my images.

For the Cygwin folks, my workaround looks like this:

RUN setx /M CYGWIN "winsymlinks:lnk"

RUN curl -SL --output %TEMP%\cygsetup.exe https://cygwin.com/setup-x86_64.exe `
    && powershell -Command `
        Start-Process %TEMP%\cygsetup.exe -Wait -ArgumentList '--quiet-mode --wait --root c:\cygwin --local-package-dir c:\cygwin --site http://mirrors.kernel.org/sourceware/cygwin/ --packages autoconf' `
    && C:\cygwin\bin\bash.exe -c 'for i in `/bin/find / -xdev -type l`; do j=`/bin/readlink $i`; /bin/rm -f $i; /bin/ln -sf $j $i; done' `
    && powershell -Command `
        Remove-Item -Recurse -Force c:\cygwin\http*

This forces Cygwin to use legacy (.lnk) based links, then recursively goes through Cygwin’s directory tree & recreates every symlink (some of which are NTFS junction points), such that there are no junction points on disk when docker tries to commit the RUN step’s changes. It works for me locally.

Sadly, I’m getting the same hcsshim error trying to install MSVC build tools on Server Core (but NOT on regular server) images. I checked, and there are no stray junction points created.

I’m experiencing this exact issue on a Windows Server 2019 (10.0.17763) instance running Docker 19.03.5, too.