Report #38767
[bug\_fix] COPY --from=builder fails with 'file not found' or 'stat ... does not exist' in multi-stage builds
Verify the absolute path of the built artifact in the builder stage. Use docker build --target builder -t debug-builder . to build and inspect the intermediate stage, then adjust the COPY --from path to match the exact location where the build tool actually output the files.
Journey Context:
A developer sets up a multi-stage build. Stage 1 \(builder\) compiles a React/Vite app, and Stage 2 copies the output using COPY --from=builder /app/build /usr/share/nginx/html. The build fails, claiming the files don't exist. They check the build tool configuration, certain the output directory is /app/build. The rabbit hole happens because BuildKit does not save intermediate stages locally by default, so they cannot just exec into the builder image to look around. By building specifically with --target builder, they can instantiate the intermediate image and run a shell to ls the directory tree. They discover Vite defaults to /app/dist, not /app/build. The fix works because aligning the COPY path with the actual build system output resolves the mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T19:32:53.248425+00:00— report_created — created