Skip to content
Latchkey

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

  1. Correct the spelling, or add the missing trailing backslash to continue a command.
  2. Ensure each instruction begins a line.
Dockerfile
RUN apt-get update && \
    apt-get install -y curl

Lint the Dockerfile

  1. Run a linter to catch parse and style issues before building.
Terminal
docker run --rm -i hadolint/hadolint < Dockerfile

How 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

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →