Docker Community Forums

Share and learn in the Docker community.

Overwriting a directory and effect on layers/size for multistage builds

I’ve been looking into efficient ways of reducing bloat when building an image manually.

I wanted to ask if anyone had insight on what happens when the COPY command is issued on a directory that already exists in the build where a lot of the files are exact duplicates of each other.

Does the image growth reflect:

  1. the difference between the changed files after the overwrite?
  2. the entire size of the directory being copied?

If it’s the second case are there any efficient ways to update an entire directory recursively from another build stage?