This error means the final image references the nonroot user, but the /etc/passwd entry that defines it was not carried into the final build stage. The -dev variants include the nonroot user; distroless runtime variants rely on the entry being present.
Fix A: reference the numeric UID
The nonroot user is UID and GID 65532:
USER 65532:65532
Fix B: carry the passwd entry across stages
COPY --from=builder /etc/passwd /etc/passwd COPY --from=builder /etc/group /etc/group USER nonroot
Files copied as root
Files added with COPY default to root ownership. Set ownership explicitly:
COPY --chown=65532:65532 ./app /app
Default user reference
| Variant | Default user | UID/GID | Home | Shell |
|---|---|---|---|---|
| Production (distroless) | nonroot | 65532 | /home/nonroot | none |
| -dev | root (for build) | 0 | /root | yes |
A small number of application-specific images set a different home; check the image's overview page.
Comments
0 comments
Article is closed for comments.