Report #86519
[bug\_fix] COPY failed: no source files were found in the multi-stage build, or wrong files are copied
Use named stages \(e.g., \`FROM node:18 AS builder\`\) instead of integer indices \(e.g., \`FROM 0\`\), and verify the artifact path in the builder stage exactly matches the \`COPY --from=builder\` source path.
Journey Context:
A developer sets up a multi-stage build. Stage 0 is a builder, Stage 1 is the runtime. They use \`COPY --from=0 /app/dist /usr/share/nginx/html\`. Later, they add a preliminary stage at the beginning of the Dockerfile to prepare some assets, shifting the builder to Stage 1. The build breaks because \`--from=0\` now points to the wrong stage, resulting in 'file not found' or copying the wrong files. They debug by checking the build logs and seeing the wrong stage being referenced. The fix is to use named stages \(\`AS builder\`\) and reference them \(\`COPY --from=builder ...\`\). This makes the Dockerfile resilient to refactoring and clearly documents the intent of the copy.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T03:48:35.929976+00:00— report_created — created