When the COPY directive is executed in the BUILD process, if there were already some of the files copied in the container where the files were copied, but not all the files were changed, but only some of them were copied, all the files that are copied or only changed / added files? The question is whether there will be problems with “blowing up” of images with each image update.

    1 answer 1

    It seems that you are not at all interested in what you asked.

    Collect updated images not on top of previous ones, but on the same basis .

    By the way, collecting the updated image for the same Dockerfile , you will do it, because there are no directives in it to take the previous version of the image as a basis.

    In any case, initially. The first version of the previous one can not be collected, right?


    And by the fact that they asked, I am not sure that this behavior is generally defined and does not depend on the driver of the disk volumes.

    But the problem of blow-up will definitely take place, because as a result of overwriting a file from the previous layer when assembling an image, it is still necessary to have the previous layer, even if its contents will be partially erased. Therefore, the best option if the previous layer has most of the unnecessary or redundant data is to get rid of it. See above.

    • Thanks for the answer! Why the question was exactly this way - I want to minimize the time for creating images with a new version of the service (container image), and in the new layer only change what was changed and not go from scratch the whole process of recreating the environment for the service inside the container. On the other hand, there is a requirement to have images for each version of the service so that you can roll back. At the same time, commands to recreate the environment (such as apt-get install) are planned to be placed into separate scripts that will be called from the Dockerfile, and the scripts may change as the service develops. - Damir Garifullin
    • @Bambuk To keep all versions, it is enough not to delete the old ones. Measure, how much faster in your case to make an image from the previous state - most likely, approximately to zero. You can also think about preparing your basic image. - D-side