dockerwindows-server-2019

Docker on Windows Server 2019: failed to register layer: Cannot create layer with missing parent


A while back I had installed Docker and created some base images. I noticed a lot of folders were being created in folders C:\ProgramData\docker\containers and C:\ProgramData\docker\windowsfilter. Besides that I don't know exactly how these folders are different, I wanted to start from scratch, just so I know exactly when and how these folders were created and also to make sure I know how to limit the amount of folders. For that I need a deeper understanding of what happened and how I got here. So I removed all folders from both of the above folders.

Then in PowerShell ran command docker image pull mcr.microsoft.com/windows/servercore:ltsc2019 (as described here).

However, then I get error:

ltsc2019: Pulling from windows/servercore
4612f6d0b889: Already exists
c67ded6868b6: Extracting [==================================================>]  967.7MB/967.7MB
failed to register layer: Cannot create layer with missing parent b30ce8240c3d9379bedb21d473387a1511327572e7f1721c32ca01b0b1f7fac9: CreateFile C:\ProgramData\docker\windowsfilter\b30ce8240c3d9379bedb21d473387a1511327572e7f1721c32ca01b0b1f7fac9: The system cannot find the file specified.

I Googled that error and checked here.

So I ran docker images:

REPOSITORY                             TAG        IMAGE ID       CREATED        SIZE
scrapy                                 latest     d6cfd054a887   3 months ago   5.9GB
<none>                                 <none>     edb9e1b2db76   3 months ago   5.27GB
hello-world                            latest     096dec0e4e75   4 months ago   252MB

mcr.microsoft.com/windows/servercore ltsc2019 152749f71f8f 4 months ago 5.27GB

I'm an absolute newbie to Docker, so which step am I missing above? I basically want to create a completely new Docker image and install Scrapy in it.

PS. I posted earlier on something similar, but am unsure how to start from where I am now.


Solution

  • This error occurs because data for a layer already pulled and extracted (b30ce824...) was found to be missing when registering a layer based on it. The missing layer data was a windowsfilter subfolder with the same 64-character name.

    When the windowsfilter folder is cleared, you need to also delete the images shown by docker image ls. This removes docker's links to the windowsfilter cached layers and will let you re-pull new images successfully.

    N.B. that the docker image * commands are the intended way to manage this folder.