Skip to content

Use numeric uid instead of username in Dockerfiles#249

Open
candrews wants to merge 1 commit intosonatype:mainfrom
candrews:uid-as-user-in-dockerfiles
Open

Use numeric uid instead of username in Dockerfiles#249
candrews wants to merge 1 commit intosonatype:mainfrom
candrews:uid-as-user-in-dockerfiles

Conversation

@candrews
Copy link
Copy Markdown

Systems configured to disallow running images as root aren't able to run images that use a username string value for the USER because they can't validate that a username isn't mapped to uid 0 (root). To allow images to run on such systems, use the uid of the user as the value for USER instead of the username.

This has no downside when running in environments that do not do non-root validation.

See MustRunAsNonRoot at https://kubernetes.io/docs/reference/access-authn-authz/psp-to-pod-security-standards/ and kubernetes/kubernetes#56503

Systems configured to disallow running images as root aren't able to run images that use a username string value for the `USER` because they can't validate that a username isn't mapped to uid 0 (root). To allow images to run on such systems, use the uid of the user as the value for `USER` instead of the username. 

This has no downside when running in environments that do not do non-root validation.

See `MustRunAsNonRoot` at https://kubernetes.io/docs/reference/access-authn-authz/psp-to-pod-security-standards/ and kubernetes/kubernetes#56503
@candrews candrews requested a review from madpah as a code owner September 11, 2025 19:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant