title: Should I run things inside a docker container as non root for safety?
body: <p>I already run my <code>docker build</code> and <code>docker run</code> without sudo. However, when I launch a process inside a docker container, it appears as a root process on <code>top</code> on the host (not inside the container).</p>
  <p>While it cannot access the host filesystem because of namespacing and cgroups from docker, is it still more dangerous than running as a simple user?</p>
  <p>If so, how is the right way of running things inside docker as non root?</p>
  <p>Should I just do <code>USER nonroot</code> at the end of the Dockerfile?</p>
  <p><strong>UPDATE:</strong></p>
  <p>root it also needed for building some things. Should I put <code>USER</code> on the very top of the Dockerfile and then install <code>sudo</code> together with other dependencies, and then use <code>sudo</code> only when needed in the build?</p>
  <p>Can someone give a simple Dockerfile example with USER in the beggining and installing and using <code>sudo</code>?</p>