This feature will be useful for multi stage builds, where some files should be copied in some stages but not others.
I imagine it looking like it follows:
FROM myimage AS not_py
COPY --exclude=sources/*.py sources /src
FROM myimage AS not_cpp_or_txt
COPY --exclude=sources/*.cpp --exclude=/sources/*.txt sources /src
In such example, /sources has some files required by not_py but not by not_cpp_or_txt, and vice-versa.
As far as I am aware, such construct at the moment cannot be accomplished with .dockerignore, which seems to prevent files to be copied to the context, whereas the exclude proposed adds files to the context, but not to the commands that use it.
This feature will be useful for multi stage builds, where some files should be copied in some stages but not others.
I imagine it looking like it follows:
In such example,
/sourceshas some files required bynot_pybut not bynot_cpp_or_txt, and vice-versa.As far as I am aware, such construct at the moment cannot be accomplished with
.dockerignore, which seems to prevent files to be copied to the context, whereas theexcludeproposed adds files to the context, but not to the commands that use it.