Report #69125
[bug\_fix] COPY failed: file not found in build context: stat : file does not exist
Use the \`--from=\` flag in the COPY instruction to copy artifacts from a previous build stage instead of the build context \(e.g., \`COPY --from=builder /app/build /usr/share/nginx/html\`\).
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 final stage, they attempt to copy the compiled files using \`COPY /app/build /usr/share/nginx/html\`. The build fails immediately. They drop into an intermediate container using \`docker run --rm -it sh\` and confirm the files exist in the builder stage. They spend hours checking \`.dockerignore\` and local directory structures, assuming Docker is looking on their host machine. The realization hits: by default, \`COPY\` only pulls from the build context \(the host filesystem relative to the Dockerfile\). To pull from a previous stage, the \`--from\` flag is strictly required. Adding \`--from=builder\` resolves the context lookup, pointing Docker to the intermediate image filesystem instead of the host.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T22:30:28.729841+00:00— report_created — created