Report #30132
[bug\_fix] COPY --from=builder \[path\] fails: file not found in build context or previous stage
Ensure the source path in the COPY --from instruction exactly matches the absolute path where the artifact was created in the builder stage, accounting for WORKDIR changes, and verify the artifact was successfully generated in the builder stage logs.
Journey Context:
A developer sets up a multi-stage build. In the builder stage, they run a build command \(e.g., npm run build\) which outputs to a directory like /app/dist. In the final stage, they run COPY --from=builder /app/dist /usr/share/nginx/html. The build fails claiming the file is not found in the previous stage. They check the local host directory and see the dist folder, leading them to mistakenly think the build context is the issue. The debugging process involves adding a RUN ls -la /app step to the builder stage to inspect the filesystem. They discover that the build tool actually outputted to /app/build/dist, or they forgot they changed the WORKDIR earlier in the builder stage, meaning the absolute path they assumed was wrong. The fix requires aligning the COPY --from path with the actual absolute path inside the builder stage's filesystem.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:57:55.754671+00:00— report_created — created