Report #38358
[bug\_fix] COPY failed: file not found in build context
Add the --from= flag to the COPY instruction to copy from a previous build stage instead of the build context.
Journey Context:
A developer sets up a multi-stage build to compile a React application. In the first stage, 'builder', they run npm run build, which outputs static files to /app/build. In the second stage, they attempt to COPY /app/build /usr/share/nginx/html. The build fails, claiming the file is not found in the build context. The developer checks their local directory, confirming /app/build doesn't exist there—it only exists inside the builder container. They realize that by default, COPY looks in the host build context, not other stages. Adding --from=builder to the COPY instruction tells Docker to look inside the 'builder' stage filesystem, resolving the error.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:51:47.487422+00:00— report_created — created