Report #15025
[bug\_fix] Multi-stage build COPY --from=0 fails after Dockerfile refactor
Use explicit stage names \(e.g., \`FROM node:18 AS builder\`\) instead of integer indices \(e.g., \`COPY --from=0\`\), and ensure the copy path matches the exact output location in the named stage.
Journey Context:
A developer creates a multi-stage Dockerfile. They add a new \`FROM\` statement at the top of the file to do some preliminary processing. Suddenly, the final \`COPY --from=0\` breaks, complaining about missing files. They are baffled because the build worked yesterday. The issue is that Docker assigns stage indices sequentially based on the order of \`FROM\` commands. By adding a new stage at the top, stage \`0\` shifted to the new preliminary stage, which didn't contain the expected build artifacts. The fix works because naming stages \(e.g., \`AS builder\`\) creates an absolute reference that is resilient to Dockerfile restructuring, ensuring \`COPY --from=builder\` always targets the correct stage regardless of its position.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T22:56:27.521057+00:00— report_created — created