Skip to content

Commit cbd5c85

Browse files
committed
build: global .dockerignore
Document the Buildx global ignore file location, supported contexts, and additive precedence with repository ignore rules. Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 4e9a575 commit cbd5c85

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

‎content/manuals/build/concepts/context.md‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,29 @@ ignore-file with the name of the Dockerfile, as shown in the following example.
508508
A Dockerfile-specific ignore-file takes precedence over the `.dockerignore`
509509
file at the root of the build context if both exist.
510510

511+
### Global ignore file
512+
513+
To exclude files created by your local tools without changing each project's
514+
`.dockerignore`, add patterns to `$BUILDX_CONFIG/.dockerignore`. If
515+
`BUILDX_CONFIG` is unset, use `$DOCKER_CONFIG/buildx/.dockerignore` (or
516+
`~/.docker/buildx/.dockerignore` when `DOCKER_CONFIG` is unset).
517+
518+
Buildx applies the global file to local directory contexts and local named
519+
contexts before sending files to the builder. It doesn't apply to remote Git,
520+
HTTP, or tarball contexts, image contexts, or `target:` contexts.
521+
522+
The global file uses the [same pattern syntax](#syntax) as a context
523+
`.dockerignore`. Buildx applies global and context-specific ignore rules
524+
independently. A path excluded by either file stays out of the build
525+
context. For example, if the global file excludes `*.log`, a repository
526+
`!build.log` can't restore `build.log`. Use a later `!` pattern in the
527+
global file to make an exception to a global rule.
528+
529+
The context root `.dockerignore` is an exception: global patterns don't
530+
exclude it because Buildx keeps it available for the builder to read.
531+
Exclude it in the applicable context or Dockerfile-specific ignore file
532+
if it should not be copied into the image.
533+
511534
### Syntax
512535

513536
The `.dockerignore` file is a newline-separated list of patterns similar to the

0 commit comments

Comments
 (0)