docker
config_error
ai_generated
true
解析 Dockerfile 失败:意外的文件结尾,期望 FROM
failed to parse Dockerfile: unexpected end of file, expected from
ID: docker/dockerfile-parse-error-missing-from
95%修复率
90%置信度
1证据数
2023-09-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| Docker 24.0.5 | active | — | — | — |
| Docker 25.0.2 | active | — | — | — |
根因分析
Dockerfile 为空或没有以 FROM 指令开头,FROM 是第一个非注释行所必需的。
English
The Dockerfile is empty or does not start with a FROM instruction, which is mandatory as the first non-comment line.
官方文档
https://docs.docker.com/engine/reference/builder/#from解决方案
-
Ensure Dockerfile starts with a valid FROM instruction, e.g.: FROM ubuntu:22.04
-
Check if Dockerfile is empty: cat Dockerfile. If empty, add FROM instruction.
-
Use -f flag to specify a non-standard Dockerfile path: docker build -f /path/to/Dockerfile .
无效尝试
常见但无效的做法:
-
# comment
80% 失败
Adding a comment before FROM is allowed, but an empty file or missing FROM still fails.
-
FROM scratch
70% 失败
Using a different base image syntax (e.g., 'FROM scratch') is valid, but if missing entirely it still fails.