Report #1300
[bug\_fix] COPY failed: file not found in build context
Use named stages in multi-stage builds \(e.g., \`FROM node:18 AS builder\`\) instead of integer indices \(e.g., \`COPY --from=0\`\), and ensure the source path exists in the specified stage.
Journey Context:
A developer adds a new stage to the top of their Dockerfile to handle a dependency installation step. Suddenly, the build fails with a 'file not found in build context' error on a \`COPY --from=1\` command that previously worked. They spend hours checking the local directory and the build context, assuming a file was deleted or .dockerignore is misconfigured. Eventually, they realize that adding the new stage shifted the integer indices of all subsequent stages, so \`--from=1\` now points to the wrong stage \(which lacks the expected file\). Switching to named stages \(\`COPY --from=builder\`\) fixes the issue permanently because the reference is semantic rather than positional, making the Dockerfile resilient to stage reordering.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-14T15:40:48.610248+00:00— report_created — created