title: OpenShift support arbitrary user ids
body: <p>From this reading on <a href="https://docs.openshift.org/latest/creating_images/guidelines.html#openshift-specific-guidelines" rel="nofollow noreferrer">https://docs.openshift.org/latest/creating_images/guidelines.html#openshift-specific-guidelines</a> in the section <strong>Support Arbitrary User IDs</strong>.  It's recommended for:</p>
  
  <ul>
  <li>an image to support running an arbitrary user</li>
  <li>an image to make directories and files own by root group</li>
  <li>an image to declare <code>USER</code> with the user id, not the username</li>
  </ul>
  
  <p>Example:</p>
  
  <pre><code>RUN chgrp -R 0 /some/directory &amp;&amp; \
      chmod -R g=u /some/directory
  RUN chmod g=u /etc/passwd
  ENTRYPOINT [ "uid_entrypoint" ]
  USER 1001
  </code></pre>
  
  <p>I'm not clear with what all these mean.</p>
  
  <ul>
  <li>Where is user 1001 defined?</li>
  <li>What does <code>g=u</code> mean?</li>
  <li>What does group <code>0</code> mean?</li>
  <li><p>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?</p>
  
  <pre><code>RUN useradd -M nonroot \
      &amp;&amp; groupadd nonrootgr \
      &amp;&amp; chown -R nonroot:nonrootgr /var/lib/myapp
  
  USER nonroot
  </code></pre></li>
  </ul>