Report #14420
[bug\_fix] COPY --from=builder --chown=appuser:appgroup fails with 'no such user or group' even though the user was created in the builder stage.
Create the user and group in the target \(runtime\) stage before executing the COPY --chown instruction, or use the explicit numeric UID/GID instead of the username.
Journey Context:
A developer optimizes their multi-stage build by creating a dedicated 'appuser' in the builder stage. They then use COPY --from=builder --chown=appuser:appgroup /app /app in their minimal runtime stage \(based on Alpine or Scratch\). The build fails with 'no such user or group: appuser'. The developer is confused because they just created that user in the previous stage. They fall down a rabbit hole checking if the user creation command failed silently. Eventually, they realize that --chown resolves usernames using the /etc/passwd of the \*current\* stage \(the target\), not the source stage. Since the minimal runtime stage doesn't have 'appuser' in its /etc/passwd, the resolution fails. The fix is to add RUN adduser appuser to the runtime stage before the COPY, or simply use the numeric UID/GID \(e.g., --chown=1001:1001\) which bypasses name resolution entirely.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T21:25:54.849735+00:00— report_created — created