Report #104297
[bug\_fix] COPY from a previous stage fails silently when the stage does not produce the expected file
Ensure the source stage actually builds the file or directory you are trying to copy. Add explicit \`RUN ls -la\` or \`RUN test -f\` in the source stage to verify the file exists. Use \`COPY --from= /path/to/file /dest\` with an absolute path. If the file is missing, the build will fail with a clear error, but if the stage exits successfully without producing the file, the error can be misleading.
Journey Context:
A developer had a multi-stage Dockerfile where the first stage \(named 'builder'\) compiled a Go binary, and the second stage copied it: \`COPY --from=builder /go/bin/app /usr/local/bin/app\`. The build succeeded but the final image did not contain the binary. The developer was confused because no error was shown. The root cause: the 'builder' stage had a typo in the build command \(\`go build -o /go/bin/ap\` instead of \`app\`\), so the file \`/go/bin/app\` never existed. However, because the \`go build\` command succeeded \(it built a different binary\), the stage exited with code 0, and the COPY instruction silently copied nothing \(or failed with a non-obvious error in some Docker versions\). The fix: add a sanity check in the builder stage: \`RUN ls -la /go/bin/\` and ensure the exact filename. They corrected the typo and the binary was properly copied.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-26T20:05:47.781440+00:00— report_created — created