Report #68320
[bug\_fix] COPY --from=builder fails with 'file not found' despite the file existing in the previous stage
Use absolute paths or paths relative to the \*source stage's\* WORKDIR in the \`COPY --from\` instruction, not relative to the current stage or build context.
Journey Context:
A developer writes a multi-stage Dockerfile. In the \`builder\` stage, they set \`WORKDIR /app\` and compile a binary using \`make build\`, which outputs to \`./bin/app\`. In the final stage, they write \`COPY --from=builder ./bin/app /usr/local/bin/app\`. The build fails with 'file not found'. The developer is baffled because they know the binary was created in the builder stage. They try various relative paths. The root cause is a misunderstanding of how \`COPY --from\` resolves paths. The source path in \`COPY --from\` is evaluated relative to the \*source stage's\* WORKDIR \(which is \`/app\`\), but the developer wrote \`./bin/app\` thinking it was relative to the build context or the final stage. The fix is to either use the absolute path \`COPY --from=builder /app/bin/app /usr/local/bin/app\` or correctly use the relative path from the source WORKDIR: \`COPY --from=builder bin/app /usr/local/bin/app\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T21:09:36.695452+00:00— report_created — created