docker build_error ai_generated true

failed to solve: dockerfile parse error on line 5: unknown instruction: ESCAPE

ID: docker/dockerfile-parse-error-invalid-escape

Also available as: JSON · Markdown · 中文
95%Fix Rate
87%Confidence
1Evidence
2024-06-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Docker 25.0.3 active
BuildKit 0.12.5 active

Root Cause

The Dockerfile contains a syntax error where 'ESCAPE' is used incorrectly, likely a typo for 'SHELL' or a misplaced escape directive, causing the parser to treat it as an unknown instruction.

generic

中文

Dockerfile 包含语法错误,'ESCAPE' 被错误使用,可能是 'SHELL' 的拼写错误或转义指令放置不当,导致解析器将其视为未知指令。

Official Documentation

https://docs.docker.com/engine/reference/builder/#parser-directives

Workarounds

  1. 95% success Remove the erroneous 'ESCAPE' line. If the intent was to change the escape character, use the parser directive '# escape=`' at the top of the Dockerfile (before any instructions).
    Remove the erroneous 'ESCAPE' line. If the intent was to change the escape character, use the parser directive '# escape=`' at the top of the Dockerfile (before any instructions).
  2. 90% success Replace 'ESCAPE' with the correct instruction, e.g., if it was meant to be a shell command, use 'RUN echo hello'.
    Replace 'ESCAPE' with the correct instruction, e.g., if it was meant to be a shell command, use 'RUN echo hello'.

中文步骤

  1. 删除错误的 'ESCAPE' 行。如果目的是更改转义字符,请在 Dockerfile 顶部使用解析器指令 '# escape=`'(在所有指令之前)。
  2. 将 'ESCAPE' 替换为正确的指令,例如,如果本意是 shell 命令,使用 'RUN echo hello'。

Dead Ends

Common approaches that don't work:

  1. Add a backslash before ESCAPE to escape it 85% fail

    Backslash does not change the parser directive; ESCAPE is not a valid instruction in any context.

  2. Change the line to 'RUN ESCAPE' 90% fail

    RUN ESCAPE is still invalid; ESCAPE is not a shell command.

  3. Ignore the error and continue building with --force-rm 95% fail

    BuildKit stops on parse errors; --force-rm only cleans intermediate containers, not fix syntax.