Docker "failed to solve: dockerignore parse error" in CI
BuildKit compiles .dockerignore into a pattern matcher before sending the context. A pattern it cannot parse - a stray bracket, a malformed negation, or an illegal path syntax - fails the whole build before any layer is built.
What this error means
A docker build/buildx build aborts very early with failed to solve: dockerignore parse error or error checking context: can't parse .dockerignore.
docker
ERROR: failed to solve: dockerignore parse error: syntax error in patternCommon causes
An unbalanced bracket or wildcard
A pattern like src/[a-z with an unclosed character class cannot compile.
A misplaced negation
A bare ! with no following pattern, or a negation before any include, confuses the parser.
A non-UTF8 or CRLF-mangled file
Carriage returns or stray bytes can produce patterns the matcher rejects.
How to fix it
Write valid ignore patterns
- Close any character classes and remove stray punctuation.
- Put a real pattern after every
!negation.
.dockerignore
# .dockerignore
node_modules
**/*.log
!keep.log
src/[a-z]*.tmpNormalize line endings to LF
- Convert the file to Unix line endings to drop stray CR bytes.
Terminal
sed -i 's/\r$//' .dockerignoreHow to prevent it
- Keep
.dockerignoreLF-only and free of unbalanced wildcards. - Test a context build locally after editing ignore patterns.
Related guides
Docker .dockerignore Silently Excludes a Needed File in CIFix builds where .dockerignore silently drops a file the Dockerfile needs in CI - an over-broad pattern exclu…
Docker "dockerfile parse error" - Fix Dockerfile Syntax in CIFix Docker "failed to solve: dockerfile parse error" in CI - unknown instructions, bad line continuations, or…
Docker "failed to solve: ResourceExhausted: grpc message exceeds max" in CIFix BuildKit "failed to solve: ResourceExhausted: grpc: received message larger than max" in CI - a single bu…