Report #52359
[bug\_fix] failed to compute cache key: failed to create user: user: unknown user myuser when using COPY --chown=myuser:mygroup
Ensure the user and group specified in the --chown flag are created in a preceding RUN instruction \(e.g., RUN adduser -D myuser\) before the COPY instruction that attempts to assign ownership to them.
Journey Context:
A developer wants to follow security best practices by avoiding running containers as root. They add USER myuser at the end of the Dockerfile and update an earlier COPY . /app instruction to COPY --chown=myuser:mygroup . /app. The build fails with an unknown user error. They are confused because the user is defined in the Dockerfile. They debug by realizing Docker evaluates each instruction sequentially. At the time the COPY instruction is executed, the myuser user hasn't been created yet \(it was going to be created in a later RUN step\). They move the user creation RUN command above the COPY instruction. The fix works because the OS layer now has the user in /etc/passwd at the moment the --chown chown operation is applied.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T18:22:35.560866+00:00— report_created — created