Docker Community Forums

Share and learn in the Docker community.

Noob question: Partial image download

I have a deployed edge server running on cellular only. A docker image that I am using is 1GB.

If I update just a single line of code it seems as if I need to download the complete image again.

Is there any way to be able to just download changes in an image rather than the whole thing?

Hello and good evening,

a Docker-image consists of multiple layers.
If you pull an image from a registry only the layers not yet available on the local machine are requested.

If you build an image based on another image one should think about the order of commands within the Dockerfile - as each command creates a new layer for the image.
Therefore adding your code to the image should be the last command (or the last possible command) within the Dockerfile.

Another idea (which I haved used in the past) is creating one image for the application (which only changes if the base-image is updated) and another image containing my code (PHP, HTML, JavaScript, …) and mounting the desired directory from the “data-only-image” into the application’s container.
Therefore I only have to pull the data-only-image if I changed my code instead of the complete application-container(s).

But to the best of my knowledge, it is not possible to only synchronize changes to one image(-layer).

Recently another user brought up the balenaEngine, which seems to base on Moby and is optimized for IoT devices. It might be a better fit for your usecase.

This would be the case if the image is from scratch and adds all bits and pieces required to run you custom application or if you update the base image together with your code changes.

Changing a single line of code still requires a whole layer to be replaced or at least a new layer with the changes needs to be added on top.