From this reading on https://docs.openshift.org/latest/creating_images/guidelines.html#openshift-specific-guidelines in the section Support Arbitrary User IDs. It's recommended for:
- an image to support running an arbitrary user
- an image to make directories and files own by root group
- an image to declare
USER
with the user id, not the username
Example:
RUN chgrp -R 0 /some/directory && \
chmod -R g=u /some/directory
RUN chmod g=u /etc/passwd
ENTRYPOINT [ "uid_entrypoint" ]
USER 1001
I'm not clear with what all these mean.
- Where is user 1001 defined?
- What does
g=u
mean? - What does group
0
mean? I've specified in my image the below to create a new user and group, and run processes as that user (non-root). Is this wrong? Can someone please help explain and provide examples - what is the correct way of doing it?
RUN useradd -M nonroot \ && groupadd nonrootgr \ && chown -R nonroot:nonrootgr /var/lib/myapp USER nonroot