diff --git a/frontend/dockerfile/docs/reference.md b/frontend/dockerfile/docs/reference.md index 168758987898..99c868da0c4d 100644 --- a/frontend/dockerfile/docs/reference.md +++ b/frontend/dockerfile/docs/reference.md @@ -1059,8 +1059,8 @@ RUN apt-get update && apt-get install -y ... ADD has two forms: ```dockerfile -ADD [--chown=:] [--chmod=] [--checksum=] ... -ADD [--chown=:] [--chmod=] ["",... ""] +ADD [--chown=:] [--chmod= [--exclude=]... [--checksum=] ... +ADD [--chown=:] [--chmod= [--exclude=]... ["",... ""] ``` The latter form is required for paths containing whitespace. @@ -1079,6 +1079,11 @@ The latter form is required for paths containing whitespace. > Only octal notation is currently supported. Non-octal support is tracked in > [moby/buildkit#1951](https://github.com/moby/buildkit/issues/1951). +> **Note** +> +> The `--exclude` option can be specified multiple times and cause files matching its patterns not to be copied, +> even if the files paths match the pattern specified in ``. + The `ADD` instruction copies new files, directories or remote file URLs from `` and adds them to the filesystem of the image at the path ``. @@ -1086,13 +1091,13 @@ Multiple `` resources may be specified but if they are files or directories, their paths are interpreted as relative to the source of the context of the build. -Each `` may contain wildcards and matching will be done using Go's +Each `` and `` may contain wildcards and matching will be done using Go's [filepath.Match](https://golang.org/pkg/path/filepath#Match) rules. For example: -To add all files starting with "hom": +To add all files starting with "hom", excluding all files with `txt` and `.md` extensions: ```dockerfile -ADD hom* /mydir/ +ADD --exclude=*.txt --exclude=*.md hom* /mydir/ ``` In the example below, `?` is replaced with any single character, e.g., "home.txt". @@ -1291,8 +1296,8 @@ See [`COPY --link`](#copy---link). COPY has two forms: ```dockerfile -COPY [--chown=:] [--chmod=] ... -COPY [--chown=:] [--chmod=] ["",... ""] +COPY [--chown=:] [--chmod=] [--exclude=]... ... +COPY [--chown=:] [--chmod=] [--exclude=]... ["",... ""] ``` This latter form is required for paths containing whitespace @@ -1305,6 +1310,11 @@ This latter form is required for paths containing whitespace > translating user and group names to IDs restricts this feature to only be viable for > Linux OS-based containers. +> **Note** +> +> The `--exclude` option can be specified multiple times and cause files matching its patterns not to be copied, +> even if the files paths match the pattern specified in ``. + The `COPY` instruction copies new files or directories from `` and adds them to the filesystem of the container at the path ``. @@ -1315,10 +1325,10 @@ of the build. Each `` may contain wildcards and matching will be done using Go's [filepath.Match](https://golang.org/pkg/path/filepath#Match) rules. For example: -To add all files starting with "hom": +To add all files starting with "hom", excluding all files with `txt` and `.md` extensions: ```dockerfile -COPY hom* /mydir/ +COPY --exclude=*.txt --exclude=*.md hom* /mydir/ ``` In the example below, `?` is replaced with any single character, e.g., "home.txt".