Files inside a docker image are 0 byte but docker engine still considers it being downloaded successfully

Hi,

During pulling a docker image from docker hub, my device accidentally went off. After I turned it on again, the docker image was shown as downloaded. When I ran my application, it kept failing. So I logged into the container and found all the files inside a folder are 0 byte (see attached screenshot). After I deleted the image and pulled it again, everything is back to normal.

Why the docker engine think the image is downloaded successfully even though there is obvious file corruption? How can I check this before running my application?

My docker version: 26.1.4, build 5650f9b

Thanks

Lincoln

A container is made of filesystem layers including the image filesystem layers. So it is possible that some base layers were downloaded but the last layer was just partially so you can run a shell, but other files donā€™t work. Delete the image completely. Delete all the containers using that image first (check stopped containers), delete the image (the delete command must show ā€œdeletedā€ not just ā€œuntaggedā€ and try to pull the image again.

Thanks for the reply. If I am running docker pull as part of a automated software update process, how to make sure the image is downloaded completely?

There are some things that cannot be automated or hard to do and may not be worth it. If Docker canā€™t recognize incomplete downloads, you can run a container from the pulled image and execute some test command in it before replacing the image with the new one. Since you canā€™t think of evrything, you could have problems like now and manually fix the issue. These things can happen even in highly available systems, but when you have multiple replicas on different nodes, you can disable one node until you fix the issue and your application continues to work.

I just noticed that your original post actually contained what I suggested (deleting and pulling the image again), so I think you did what you could. I never had issue slike this, although I heard about some in this forum too. Iā€™m a little surprised the docker command lets you start a container without running some integrity check.

I would search for existing issues in the Moby repository and open a new issue if there is none.

1 Like

I have a similar situation. Sometimes my docker images are pulled with random files with 0 bytes size. I have ~20 nodes in k8s and happens randomly on different nodes.
I thought that it was a problem related to Linux kernel Very specific set of circumstances leads to zero-byte (empty) file being created Ā· Issue #1015 Ā· docker/for-linux Ā· GitHub but the affected versions donā€™t match so I stuck with searching for some resolutions and extra monitoring to catch the case asap and manually fix itā€¦

And you use dockerd as container runtime for Kubernetes? If not (and the current default is containerd, not dockerd), it is not just a Docker issue. Where you should report it, could depend on what actually causes it.

Yeah sure I have containerd, I think is some Linux/kernel/dependency problem but with the same result so just mentioning it.
It is not reproducible in any predictable way so no good way to report :slight_smile:

I am even more surprised that incomplete layers passed the integrity check for the layer before its content was extracted, and even more surprised this lead to a registered image in the local image cache.

Doesnā€™t this smell like a bug?