-
Notifications
You must be signed in to change notification settings - Fork 18.9k
[epic] builder: collected issues on improving .dockerignore #40319
Copy link
Copy link
Open
Labels
area/builderBuildBuildarea/docsexp/expertexp/intermediatekind/enhancementEnhancements are not bugs or new features but can improve usability or performance.Enhancements are not bugs or new features but can improve usability or performance.kind/epicEpics to track work on related ticketsEpics to track work on related tickets
Description
The .dockerignore file has been around for a while, but there's still room for improvement. Opening this as a ticket, based on some notes I had, and some existing issues. I can break down this issue further (and open separate tickets where needed)
Some related issues:
- Verify parity between .dockerignore and .gitignore syntax #40318 Verify parity between .dockerignore and .gitignore syntax (duplicated by .dockerignore does not recursively include with negated exclusion docker/cli#2847 .dockerignore does not recursively include with negated exclusion)
- Exception patterns in .dockerignore do not support wildcard directories #30018 Exception patterns in .dockerignore do not support wildcard directories
- wildcard directories not implemented correctly in dockerignore #41433 wildcard directories not implemented correctly in dockerignore
- Global .dockerignore #12843 Global .dockerignore
- (re)consider nested .dockerignore files Proposal: recursive .dockerignore files #20944, and Added recursive .dockerignore capabilities #21020 (comment)
- Output the reason while cache need to be invalidated on docker build #9294 "Output the reason while cache need to be invalidated on docker build"
- COPY with excluded files is not possible #15771 COPY with excluded files is not possible
- .dockerignore with '*' wildcard doesn't work as documented docker/for-linux#585 .dockerignore with '*' wildcard doesn't work as documented
Assorted issues / suggestions / topics
- Improve performance where possible. Ignoring files should make builds smaller and faster, not cause builds to be slow.
- Would be great if it's possible to profile builds, and see how much time was taken by excluding files. Having this would allow users to make better informed decisions wether or not
.dockerignoreis the right solution. - The dockerignore file is often used to make the build-context smaller in order to speed up builds, but with the introduction of BuildKit, some of those may no longer be relevant (and
.dockerignorecould actually have a negative impact in some situations)
- Would be great if it's possible to profile builds, and see how much time was taken by excluding files. Having this would allow users to make better informed decisions wether or not
- Make
.dockerignorefollow the exact same patterns as.gitignore(which it was originally modeled after).gitignorepattern reference: https://git-scm.com/docs/gitignore#_pattern_format- if possible, run the .git test-suite / tests to verify this
- Add a global
.dockerignoreto allow excluding common files (.idea,Thumbs.dbfiles and such). See [Global .dockerignore #12843](Global .dockerignore #12843 Global .dockerignore)- allow easy discovery why a file or directory was ignored (which becomes more important if a global ignore file is active). Also see next bullet
- Introduce a command similar to
git check-ignorefor debugging- related: Output the reason while cache need to be invalidated on docker build #9294 "Output the reason while cache need to be invalidated on docker build"
- Note: recursive
.dockerignorefiles were proposed at some point, but were considered a risky, breaking change (see Proposal: recursive .dockerignore files #20944, and Added recursive .dockerignore capabilities #21020 (comment))- should this be reconsidered?
- Improve and validate the
.dockerignoredocumentation- document the per-Dockerfile dockerignore (when using BuildKit and Docker 19.03 or up: Add support for specifying .dockerignore file with -i/--ignore #12886 (comment), Add support for specifying .dockerignore file with -i/--ignore #12886 (comment))
- improve docs by referring to / borrowing from
.gitignore(where applicable) (see Verify parity between .dockerignore and .gitignore syntax #40318 "BUG:.dockerignoresometimes ignores**") - could be moved to a separate page if needed
- provide better examples (also for Windows platforms)
- best practices (what files to consider for excluding to optimize caching; when to use
.dockerignore, when not to use and (e.g.) use BuildKit, optimize your Dockerfile, use multi-stage builds etc.) - common pitfalls
- (related) consider implementing
COPY --excludeto allow specifying ignore-rules in the Dockerfile itself; this can help with situations where (e.g.) frequently changing files are mixed with "cacheable" files (proposal in COPY with excluded files is not possible #15771). Allowing such files to beCOPY'd separately would give more control over layers/caching. - (Slightly related) improve errors produced due to files that were excluded. The current error for missing files is confusing (as it mentions the file path on the daemon side), therefore making it hard to trace the error back to
.dockerignore(see the discussion on /var/lib/docker/tmp/docker-builderXXXXXXX/... no such file or directory docker/for-mac#1922, and need more relevant directory in failure message whenDockerfileis missing buildkit#4248) - Feature: improve debugging of COPY failures docker/cli#2690
- Improve error messages for non-existing or excluded files buildkit#1647
- Unable to unignore using wildcards with .dockerignore #23693
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/builderBuildBuildarea/docsexp/expertexp/intermediatekind/enhancementEnhancements are not bugs or new features but can improve usability or performance.Enhancements are not bugs or new features but can improve usability or performance.kind/epicEpics to track work on related ticketsEpics to track work on related tickets