Report #70942
[bug\_fix] Permission denied on files copied from a previous build stage \(UID/GID mismatch in multi-stage builds\)
Explicitly use COPY --chown=: when copying artifacts from a previous stage, or ensure the user UID/GID matches between the builder and final stages. COPY --from preserves the numeric UID/GID from the source stage, which may map to a different user or 'nobody' in the final stage.
Journey Context:
A developer builds an application in a builder stage as the 'node' user \(UID 1000\). In the final stage, based on a different base image \(e.g., Alpine\), they COPY --from=builder /app/dist /app/dist. They run the container as the 'node' user, but get 'Permission denied' reading the files. They inspect the filesystem and see the files are owned by 'nobody' or a different numeric ID. They realize that the 'node' user in the builder stage had UID 1000, but the 'node' user in the Alpine final stage has UID 1001. COPY --from preserves the raw numeric UID 1000, which doesn't map to the correct user in the final image. The fix is to explicitly override ownership during the copy using COPY --from=builder --chown=node:node /app/dist /app/dist, ensuring the files belong to the correct user in the final stage.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T01:39:28.586659+00:00— report_created — created