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

- **ID:** `docker/dockerfile-parse-error-invalid-escape`
- **领域:** docker
- **类别:** build_error
- **验证级别:** ai_generated
- **修复率:** 95%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Docker 25.0.3 | active | — | — |
| BuildKit 0.12.5 | active | — | — |

## 解决方案

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

## 无效尝试

- **Add a backslash before ESCAPE to escape it** — Backslash does not change the parser directive; ESCAPE is not a valid instruction in any context. (85% 失败率)
- **Change the line to 'RUN ESCAPE'** — RUN ESCAPE is still invalid; ESCAPE is not a shell command. (90% 失败率)
- **Ignore the error and continue building with --force-rm** — BuildKit stops on parse errors; --force-rm only cleans intermediate containers, not fix syntax. (95% 失败率)
