Report #46296
[bug\_fix] COPY --from= fails with lstat : no such file or directory when copying a binary from an official base image
Run a temporary container from the source image \(\`docker run --rm -it sh\`\) and use \`ls\` or \`which\` to find the exact absolute path of the binary, then update the \`COPY --from\` instruction with the correct path.
Journey Context:
A developer tries to copy a specific binary \(like \`python\` or \`go\`\) from an official Docker image into a scratch or distroless image using \`COPY --from=python:3.9 /usr/bin/python /usr/bin/python\`. The build fails with a file not found error. They assume the binary is in \`/usr/bin/\` because that's standard on many Linux distros. However, official images often use different directory structures, symlinks, or alternative base distributions \(like Alpine\) where binaries reside in \`/usr/local/bin/\` or have versioned names \(e.g., \`python3.9\`\). The fix works because \`COPY --from\` requires the exact absolute path within the source image's filesystem. Spinning up a throwaway container to inspect the actual filesystem layout guarantees the path used in the Dockerfile matches reality.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T08:10:53.861933+00:00— report_created — created