Skip to content

Commit 655ca34

Browse files
authored
docs: Use numeric uid instead of username in Dockerfile
Systems configured to disallow running images as root aren't able to run images that use user name string values for the `USER` because they can't validate that a named user isn't root. To allow images to run on such systems, use the uid of the user as the value for `USER` instead of the username. See: kubernetes/kubernetes#56503
1 parent 6502c3e commit 655ca34

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/BestPractices.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ You can also include Tini [directly in your Dockerfile](https://github.com/krall
9898

9999
## Non-root User
100100

101-
By default, Docker runs commands inside the container as root which violates the [Principle of Least Privilege (PoLP)](https://en.wikipedia.org/wiki/Principle_of_least_privilege) when superuser permissions are not strictly required. You want to run the container as an unprivileged user whenever possible. The node images provide the `node` user for such purpose. The Docker Image can then be run with the `node` user in the following way:
101+
By default, Docker runs commands inside the container as root which violates the [Principle of Least Privilege (PoLP)](https://en.wikipedia.org/wiki/Principle_of_least_privilege) when superuser permissions are not strictly required. You want to run the container as an unprivileged user whenever possible. The node images provide the `node` user with uid 1000 for such purpose. The Docker Image can then be run with the `node` user in the following way:
102102

103103
```
104104
-u "node"
@@ -110,7 +110,7 @@ Alternatively, the user can be activated in the `Dockerfile`:
110110
FROM node:6.10.3
111111
...
112112
# At the end, set the user to use when running this image
113-
USER node
113+
USER 1000 # node
114114
```
115115

116116
Note that the `node` user is neither a build-time nor a run-time dependency and it can be removed or altered, as long as the functionality of the application you want to add to the container does not depend on it.

0 commit comments

Comments
 (0)