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

- **ID:** `docker/executable-not-found-in-path`
- **领域:** docker
- **类别:** config_error
- **验证级别:** ai_generated
- **修复率:** 90%

## 根因

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

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Docker 20.10.24 | active | — | — |
| Docker 24.0.7 | active | — | — |

## 解决方案

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

## 无效尝试

- **** — Changing CMD to a different path without verifying the file's existence in the built image repeats the same error. (70% 失败率)
- **** — Adding RUN ls /usr/local/bin/ in the Dockerfile may not reflect the final image if later stages modify the filesystem. (50% 失败率)
