Docker "Dockerfile parse error: unknown instruction" in CI
The Dockerfile parser hit a line whose first token is not a valid instruction. Usually it is a typo, a missing line-continuation backslash, or shell text that leaked onto its own line.
What this error means
A build fails before any step with dockerfile parse error on line N: unknown instruction: <TOKEN>. The named token is the offending word.
docker
ERROR: failed to solve: dockerfile parse error on line 7: unknown instruction: RUNN (did you mean RUN?)Common causes
Misspelled instruction
A typo like RUNN, COPYY, or ENVV is not a recognized instruction.
Missing line continuation
A multi-line RUN without a trailing backslash leaves the next line parsed as a new instruction.
Stray text or wrong file
A non-Dockerfile (a shell script or YAML) was passed as the Dockerfile, so its first words are not instructions.
How to fix it
Fix the offending line
- Correct the spelling, or add the missing trailing backslash to continue a command.
- Ensure each instruction begins a line.
Dockerfile
RUN apt-get update && \
apt-get install -y curlLint the Dockerfile
- Run a linter to catch parse and style issues before building.
Terminal
docker run --rm -i hadolint/hadolint < DockerfileHow to prevent it
- Lint Dockerfiles in CI (hadolint), and use multi-line continuations carefully so RUN blocks stay intact. This is a syntax error, not transient, so a retry cannot fix it.
Related guides
Docker "failed to solve: dockerfile.v0: not found" in CIFix the Docker BuildKit "failed to solve with frontend dockerfile.v0: failed to read dockerfile" error in CI,…
Docker "failed to compute cache key: not found" in CIFix the Docker "failed to compute cache key: ... not found" build error in CI, caused by a COPY or ADD source…
Docker "returned a non-zero code: 1" on a RUN step in CIFix the Docker "The command ... returned a non-zero code: 1" build error in CI, where a RUN instruction itsel…