ProjectStack
docker

Error response from daemon: dockerfile parse error at line X

Docker couldn't parse your Dockerfile because of a syntax error. Every instruction must follow the format INSTRUCTION arguments, and certain rules apply — like not putting instructions before the first FROM, using proper line continuation, or using valid instruction names.

Common causes

  • An unknown or misspelled instruction keyword (e.g., COPIES instead of COPY)
  • A line continuation backslash \ with trailing spaces or a Windows-style CRLF line ending after it
  • Instructions appearing before the first FROM (except ARG, which is allowed before FROM)
  • An empty or malformed instruction line

How to fix it

  1. Read the error line number and check that line in your Dockerfile
  2. Ensure all instructions use valid keywords: FROM, RUN, COPY, ADD, ENV, EXPOSE, CMD, ENTRYPOINT, WORKDIR, ARG, LABEL, USER, VOLUME
  3. Convert Windows line endings to Unix: sed -i 's/\r//' Dockerfile, or use dos2unix Dockerfile
  4. Validate the Dockerfile with: docker build --check . (Docker 24+) or a linter like hadolint

Example

$ docker build . Error response from daemon: dockerfile parse error line 5: unknown instruction: COPIES

Typo in the Dockerfile — COPIES instead of COPY on line 5

Browse more errors

The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.