docker config_error ai_generated true

docker:守护进程错误响应:容器命令 '/usr/local/bin/myapp' 未找到或不存在。

docker: Error response from daemon: Container command '/usr/local/bin/myapp' not found or does not exist.

ID: docker/executable-not-found-in-path

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

版本兼容性

版本状态引入弃用备注
Docker 20.10.24 active
Docker 24.0.7 active

根因分析

Dockerfile 中的 CMD 或 ENTRYPOINT 引用了容器镜像中不存在的二进制文件路径。

English

CMD or ENTRYPOINT in Dockerfile references a binary path that does not exist inside the container image.

generic

官方文档

https://docs.docker.com/engine/reference/builder/#cmd

解决方案

  1. 使用 'docker run --rm <image> ls /usr/local/bin/' 检查镜像中的实际二进制文件,然后更正 CMD 路径。
  2. 在 ENTRYPOINT 中使用绝对路径,并通过 RUN 命令确保二进制文件已安装,例如 COPY --from=builder /app/myapp /usr/local/bin/myapp。

无效尝试

常见但无效的做法:

  1. 70% 失败

    Changing CMD to a different path without verifying the file's existence in the built image repeats the same error.

  2. 50% 失败

    Adding RUN ls /usr/local/bin/ in the Dockerfile may not reflect the final image if later stages modify the filesystem.