DEV Community

Discussion on: How to securely build Docker images for Node.js

 
lirantal profile image
Liran Tal • Edited

Would you like to reference an example Dockerfile for that?
AFAIK a directive such as USER lirantal does not create a user if one doesn't exist already.

Thread Thread
 
asto profile image
astodev

docs.docker.com/engine/reference/b...

USER directive does not create a user. The username specified must already exist or can be created earlier in the Dockerfile directives.

From docs.docker.com/develop/develop-im...
If a service can run without privileges, use USER to change to a non-root user. Start by creating the user and group in the Dockerfile with something like:


RUN groupadd -r postgres && useradd --no-log-init -r -g postgres postgres

Thread Thread
 
lirantal profile image
Liran Tal

Thanks for reassuring.

Thread Thread
 
rubberduck profile image
Christopher McClellan

Yup. I stand corrected.