docker
build_error
ai_generated
true
COPY --from=builder failed: stat /app/build: file not found in build stage
ID: docker/multi-stage-copy-from
90%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 27 | active | — | — | — |
Root Cause
Multi-stage build COPY source path doesn't exist in the builder stage.
genericWorkarounds
-
95% success Check the builder stage: the build output path may differ from what you're copying
# Verify: RUN ls -la /app/build # add this to builder stage to debug
Sources: https://docs.docker.com/build/building/multi-stage/
-
90% success Ensure the build step in the builder stage actually runs and outputs to the expected path
# Verify the builder stage output: FROM node:20 AS builder WORKDIR /app COPY . . RUN npm ci && npm run build # Check: ls -la /app/dist (this is what COPY --from=builder copies) FROM node:20-slim COPY --from=builder /app/dist ./dist # Path must match builder output
Sources: https://docs.docker.com/build/building/multi-stage/
Dead Ends
Common approaches that don't work:
-
Add the file to the build context
80% fail
Build context is for COPY without --from; --from copies from another stage
-
Use a single-stage build
65% fail
Loses multi-stage benefits (smaller final image, no build tools in prod)
Error Chain
Frequently confused with: