Skip to content

Commit c0c75d6

Browse files
authored
Merge pull request #407 from nodejs/fix-user-docs
Update "Non-root User" docs
2 parents 955f24f + bc7cd93 commit c0c75d6

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

docs/BestPractices.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@ You can also include tini [directly in your Dockerfile](https://github.com/krall
2929

3030
## Non-root User
3131

32-
By default, Docker runs container as root which inside of the container can pose as a security issue. You would want to run the container as an unprivileged user wherever possible. The node images (with the exception of the `onbuild` variant) provide the `node` user for such purpose. The Docker Image can than be run with the `node` user in the following way:
32+
By default, Docker runs container as root which inside of the container can pose as a security issue. You would want to run the container as an unprivileged user wherever possible. The node images provide the `node` user for such purpose. The Docker Image can than be run with the `node` user in the following way:
3333

3434
```
3535
-u "node"
3636
```
37-
When using the `onbuild` variant, add the user like so:
37+
Alternatively, the user can be activated in the `Dockerfile`:
3838

3939
```Dockerfile
40-
FROM node:4.1.2-onbuild
41-
# Add our user and group first to make sure their IDs get assigned consistently
42-
RUN groupadd -r node && useradd -r -g node node
43-
# Set the user to use when running this image
40+
FROM node:6.10.3
41+
...
42+
# At the end, set the user to use when running this image
4443
USER node
4544
```
4645

0 commit comments

Comments
 (0)