Skip to content

Feature request: On Dockerfiles, allow filepaths to be excluded from ADD and COPY commands #4439

@leandrosansilva

Description

@leandrosansilva

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions