Docker.DotNet
Docker.DotNet copied to clipboard
CreateImageAsync silently fails
What version of Docker.DotNet?:
Tip
Steps to reproduce the issue:
- Pull the microsoft/aspnet image (or any other large image).
This is the code basic snippet I used to reproduce.
m_DockerClient.Images.CreateImageAsync(new ImagesCreateParameters { FromImage = "microsoft/aspnet", Tag = "latest", }, new AuthConfig(), new Progress<JSONMessage>(), CancellationToken.None).Wait();
- CreateImageAsync eventually returns without any exception.
- The image is not available.
What actually happened?: Using the Docker CLI to pull the image, you can see that the pull actually fails at the end of the extraction with the following error: failed to register layer: re-exec error: exit status 1: output: remove \?\C:\ProgramData\Docker\windowsfilter\0706a66d9dee465807b9534864c545f20e5fb2b3a428b722902fea7648a111d3\UtilityVM\Files\Windows\servicing\Packages\Microsoft-NanoServer-Win32Compat-Package~31bf3856ad364e35~amd64~en-US~10.0.14393.0.cat: The process cannot access the file because it is being used by another process.
In the past, I have seen this problem caused by an antivirus trying to scan C:\ProgramData\Docker. This time, it was caused by Everything (https://www.voidtools.com/) trying to index this same folder.
To be clear, I'm not opening this issue to fix this problem. The situation is obviously not caused by the .Net Client. The client needs to throw when this happens though.
Full output of docker pull when the error occurs: $ docker pull microsoft/aspnet Using default tag: latest latest: Pulling from microsoft/aspnet 3889bb8d808b: Already exists 8df8e568af76: Extracting [==================================================>] 1.281GB/1.281GB 2358a8661e1b: Download complete b96ca9f924e0: Download complete 77783e7dbe33: Download complete d53b605d237c: Download complete eda3ee0214b3: Download complete 4522ec028340: Download complete 56bfffcc3f40: Download complete 11c167c5788b: Download complete failed to register layer: re-exec error: exit status 1: output: remove \?\C:\ProgramData\Docker\windowsfilter\0706a66d9dee465807b9534864c545f20e5fb2b3a428b722902fea7648a111d3\UtilityVM\Files\Windows\servicing\Packages\Microsoft-NanoServer-Win32Compat-Package~31bf3856ad364e35~amd64~en-US~10.0.14393.0.cat: The process cannot access the file because it is being used by another process.
I also discovered the hard way that when CreateImageAsync fails, no exception gets thrown. You need to observe the IProgress entries and throw an exception on your own. Possibly a more obvious pattern could be used here, though the current design is obviously modeled after Docker's own API which acts like this.
I ran into this issue when pulling a Linux image with Docker set to use Windows containers. As @sandersaares says, it's detectable by monitoring the progress ErrorMessage.
We also ran into this. The API currently expects the caller to install a progress message and listen to error messages. Any chance this could return the image id and an error (if it occurs?)
I spent a frustration few hours on a similar problem which turned out to be because I was attempting to get an image from a private repository without any authentication parameters. That returned a 500 from the API which apparently wasn't caught, nor did it return any output in the progress. It's pretty easy to reproduce so I'll see if I can get a pull request in for that, but in case anyone runs into silent failures of CreateImageAsync it might be because the API is returning a 500...
(I ended up downloading the sources, dropping that into my project and debugging through it)
This appears to also happen if the disk doesn't have enough space for the image pulled.