Uh oh!
There was an error while loading. Please reload this page.
Fix: USER (runAsNonRoot) - #442
Conversation
Supply the numeric uid/gid of the user/group created early in the Dockerfile. This is to ensure that (on k8s) runAsNonRoot works as expected because the username could indeed map to root (uid 0).
tianon
commented
Dec 11, 2023
See docker-library/memcached#79 (comment):
|
till
commented
Dec 11, 2023
Can you reconsider this? There is a functional difference when using this image on Kubernetes. A non-numeric user cannot be verified with Adjusting this, would indeed require less work downstream. You also already create a user/group with a specific UID (a few lines up), so it seems there's nothing "extra" to maintain? |
till
commented
Apr 16, 2024
@tianon sorry to bug, but any thoughts? |
candrews
commented
Jul 17, 2025
I apparently just made a duplicate of this request at #547 This issue is a real concern. User do not want to "maintain a short Dockerfile" just to set the user to a numeric value. That's a lot of maintenance headache. Other projects have made this change, ex nodejs/docker-node#2185 Can docker please make this change as well? |
tianon
commented
Jul 17, 2025
Why not set the user explicitly in your Kubernetes YAML instead? Then you control the numeric ID explicitly, which is also really important if you want to be able to control the persistent storage / permissions. |
tianon
commented
Jul 17, 2025
Specific to this repository, and the only tags of this repository that use a non-root
|
candrews
commented
Jul 17, 2025
Why should one have to do so? Besides kubernetes, security tools flag USER with a username. Using USER with a username is just more difficult to use, especially for security conscience use cases. Plenty of other projects are using numeric uids. Why resist following that widespread practice here? |
till
commented
Jul 18, 2025
@tianon I think I linked you to the code that produces an error with non numeric user/group from the image. Not sure what other mapping you are suggesting that people do downstream. |
tianon
commented
Jul 18, 2025
I'm suggesting using https://kubernetes.io/docs/tasks/configure-pod-container/security-context/ spec:
securityContext:
runAsUser: 1000runAsGroup: 3000fsGroup: 2000supplementalGroups: [4000](Setting the user you want to run as explicitly will be much more secure in practice than relying on the image to do so.) |
till
commented
Jul 18, 2025
I set both of these usually. |
candrews
commented
Jul 19, 2025
How is that more secure? The situation right now is that users need to do more work to achieve the same result. That's not good practice, security related or otherwise. Simplicity is key feature of security. |
Supply the numeric uid/gid of the user/group created early in the Dockerfile. This is to ensure that (on k8s) runAsNonRoot works as expected because the username could indeed map to root (uid 0).
For context, I am using dind(-rootless) on a k8s cluster.