docker
build_error
ai_generated
true
使用前端 dockerfile.v0 解决失败:读取 dockerfile 失败:解析 dockerfile 错误:未知指令:\
failed to solve with frontend dockerfile.v0: failed to read dockerfile: error parsing dockerfile: unknown instruction: \
ID: docker/dockerfile-parse-error-line-continuation
88%修复率
84%置信度
1证据数
2024-02-18首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Docker 24.0.7 | active | — | — | — |
| Docker 25.0.1 | active | — | — | — |
根因分析
Dockerfile 中用于续行的尾随反斜杠未正确转义或后跟空格,导致解析器将其视为指令。
English
Trailing backslash used for line continuation in Dockerfile is not properly escaped or is followed by a space, causing parser to treat it as an instruction.
官方文档
https://docs.docker.com/engine/reference/builder/#run解决方案
-
确保反斜杠后没有尾随空格:将 'RUN apt-get update && \\n apt-get install -y curl' 替换为使用单行或数组语法的正确格式。
-
使用 JSON 数组语法进行 RUN 以避免续行问题:'RUN ["apt-get", "update"]'。
无效尝试
常见但无效的做法:
-
70% 失败
Removing the backslash entirely breaks multi-line RUN commands, causing syntax errors in shell.
-
90% 失败
Adding more backslashes compounds the parsing error without fixing the root cause.