docker config_error ai_generated true

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

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

Also available as: JSON · Markdown · 中文
90%Fix Rate
88%Confidence
1Evidence
2024-01-10First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Docker 20.10.24 active
Docker 24.0.7 active

Root Cause

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

generic

中文

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

Official Documentation

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

Workarounds

  1. 95% success Inspect the image with 'docker run --rm <image> ls /usr/local/bin/' to list actual binaries, then correct the CMD path.
    Inspect the image with 'docker run --rm <image> ls /usr/local/bin/' to list actual binaries, then correct the CMD path.
  2. 90% success Use absolute path in ENTRYPOINT and ensure the binary is installed via RUN commands, e.g., COPY --from=builder /app/myapp /usr/local/bin/myapp.
    Use absolute path in ENTRYPOINT and ensure the binary is installed via RUN commands, e.g., COPY --from=builder /app/myapp /usr/local/bin/myapp.

中文步骤

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

Dead Ends

Common approaches that don't work:

  1. 70% fail

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

  2. 50% fail

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