docker build_error ai_generated true

求解失败:第 5 行 Dockerfile 解析错误:未知指令:ESCAPE

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

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

其他格式: JSON · Markdown 中文 · English
95%修复率
87%置信度
1证据数
2024-06-01首次发现

版本兼容性

版本状态引入弃用备注
Docker 25.0.3 active
BuildKit 0.12.5 active

根因分析

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

English

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

官方文档

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

解决方案

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

无效尝试

常见但无效的做法:

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

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

  2. Change the line to 'RUN ESCAPE' 90% 失败

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

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

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