Adds instructions for modifying the `node` user (#328)
Also highlights the `Best Practices` section in the `README.md` file so the new instructions are easier to find. Special thanks to: * @blueimp for the uid/gid change command * @LaurentGoderre for the user rename command Refs #289
This commit is contained in:
parent
bc4e7eecfe
commit
c3694d8baa
|
@ -75,6 +75,8 @@ It also assumes that you have a file named [`.dockerignore`](https://docs.docker
|
|||
node_modules
|
||||
```
|
||||
|
||||
## Best Practices
|
||||
|
||||
We have assembled a [Best Practices Guide](./docs/BestPractices.md) for those using these images on a daily basis.
|
||||
|
||||
## Run a single Node.js script
|
||||
|
|
|
@ -43,6 +43,38 @@ FROM node:6.10.3
|
|||
USER node
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
If you do not want nor need the user created in this image you can remove it with the following:
|
||||
|
||||
```Dockerfile
|
||||
# For debian based images use:
|
||||
RUN userdel -r node
|
||||
|
||||
# For alpine based images use:
|
||||
RUN deluser --remove-home node
|
||||
```
|
||||
|
||||
If you need to change the uid/gid of the user you can use:
|
||||
|
||||
```Dockerfile
|
||||
RUN groupmod -g 999 node && usermod -u 999 -g 999 node
|
||||
```
|
||||
|
||||
If you need another name for the user (ex. `myapp`) execute:
|
||||
|
||||
```Dockerfile
|
||||
RUN usermod -d /home/myapp -l myapp node
|
||||
```
|
||||
|
||||
For alpine based images, you do not have `groupmod` nor `usermod`, so to change the uid/gid you have to delete the previous user:
|
||||
```Dockerfile
|
||||
RUN deluser --remove-home node \
|
||||
&& delgroup node \
|
||||
&& addgroup -S node -g 999 \
|
||||
&& adduser -S -g node -u 999 node
|
||||
```
|
||||
|
||||
## Memory
|
||||
|
||||
By default, any Docker Container may consume as much of the hardware such as CPU and RAM. If you are running multiple containers on the same host you should limit how much memory they can consume.
|
||||
|
|
Loading…
Reference in New Issue