Connection reset by peer

I’m trying to build an image using docker on Debian Linux. When I run docker build, everything seems to proceed as normal, but the process suddenly terminates with a “connection reset by peer” error.

Dockerd gives the following logs. Several INFO warnings like this one:
INFO[2024-10-10T22:52:26.105956276-05:00] Download failed, retrying (2/5): failed to copy: read tcp [2600:6c44:3f:9dbb:1dda:6dec:9b24:adda]:49892->[2606:4700::6810:64d7]:443: read: connection reset by peer

And occasional errors:
ERRO[2024-10-10T22:52:33.073787757-05:00] Download failed after 5 attempts: failed to copy: read tcp [2600:6c44:3f:9dbb:1dda:6dec:9b24:adda]:41514->[2606:4700::6810:61d7]:443: read: connection reset by peer

eventually, the build process gives a similar error and terminates:
ERROR: failed to solve: failed to copy: read tcp [2600:6c44:3f:9dbb:1dda:6dec:9b24:adda]:47142->[2606:4700::6810:62d7]:443: read: connection reset by peer

I know these errors can come from unusual places, and I’m sure I have a misconfiguration somewhere… but I can’t figure out what it is. I disabled my firewall and my connection is pretty stable/strong. Are there other logs files I can investigate for more information, or maybe some configurations I can check?

I was able to successfully build my docker image on another machine on my network, but I can’t push it to DockerHub for the same errors. I successfully pushed it to ghrc.io however, which makes me suspect that my error is very particular to some aspect of my docker config. I’m feeling clueless otherwise. Ideas?

The IPv6 address seems to be from cloud flare

Can you build an image based on another image? For example can you build this?

FROM ubuntu:24.04

RUN apt-get update && apt-get install -y curl

Trying this was a good idea, thank you; it seems this build is small enough that I’m able to finish it, though I got the following:

INFO[2024-10-12T10:41:13.273405323-05:00] Download failed, retrying (1/5): failed to copy: read tcp [2600:6c44:3f:9dbb:1dda:6dec:9b24:adda]:53902->[2606:4700::6810:62d7]:443: read: connection reset by peer

once during my build. I suspect that had the build gone on longer it would’ve failed.

Then there must be some network issue on your machine. Check the MTU size on the network interfaces. Runnint ip link will show you the mtu sizes too. If it there is a big difference between on the docker interfaces and your lan/wan interface, it can cause problems.

Seems my docker interface and my lan interface (and all my other interfaces except loopback) are 1500. Thanks for your help by the way—I didn’t know about MTU.

Maybe the issue is not on your machine but somewhere in your network? I don’t know. You can try playing with nicolaka/netshoot which also recommends some tools to discover network issues

Thank you for the reference, it looks useful. I will update this thread if I identify the source of my issue!

@maanderson22 , did you ever figure out the problem?