Memory issue while building docker image

Docker dangling images are being created, which is leading to below error while building the image:

Step 26/42 : RUN curl.exe --version
 ---> Running in 26630f973213
curl 8.13.0 (Windows) libcurl/8.13.0 Schannel zlib/1.3.1 WinIDN
Release-Date: 2025-04-02
Protocols: dict file ftp ftps http https imap imaps ipfs ipns mqtt pop3 pop3s smb smbs smtp smtps telnet tftp ws wss
Features: alt-svc AsynchDNS HSTS HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM SPNEGO SSL SSPI threadsafe Unicode UnixSockets
hcsshim::UnprepareLayer failed in Win32: The specified network resource or device is no longer available. (0x37)
REPOSITORY                             TAG        IMAGE ID       CREATED       SIZE
azp-agent                              latest     dc97919a4510   2 hours ago   29.5GB
<none>                                 <none>     9db00f1f5a3d   3 days ago    4.97GB
<none>                                 <none>     545c1b2925ff   3 days ago    5.01GB
<none>                                 <none>     d434599e8d82   4 days ago    4.97GB
<none>                                 <none>     950bb40d7f6c   4 days ago    4.97GB
<none>                                 <none>     b777784d587f   4 days ago    4.97GB
<none>                                 <none>     de2a9b248d5c   4 days ago    11.3GB
<none>                                 <none>     bf5f35f8135b   4 days ago    11.1GB
<none>                                 <none>     3e6b597833fb   4 days ago    11.1GB
<none>                                 <none>     8c4136be8f04   5 days ago    6.37GB
mcr.microsoft.com/windows/servercore   ltsc2019   18e77de47740   3 weeks ago   4.97GB

FYI: it is windows container:

why these images are being created? how it can be avoided, because it is occupying storage and leading above error frequently. I tried to delete manually but that is not permanent solution

A dangling image is left behind when a new image of the same name is created, So the dangling images are your previous images every time you create a new one.

To remove them just use:

docker image prune

This will ask you if you are sure (y/n?), and then prune any dangling images. If you don’t want to be asked, then use the -f option to force the prune. Deleting/pruning them manually is the only option.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.