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.
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
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.
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.