title: What is the concept of user in Docker and how does permission work in volume?
body: <p>I can't understand the concept of user in Docker.</p>
  <p>These are my questions:</p>
  <ol>
  <li><p>Does each Docker container have its own users and groups or Docker containers use the host user management?</p>
  </li>
  <li><p>What is the <code>--user</code> parameter that we pass to the <code>docker run</code> command?</p>
  </li>
  <li><p>Is it possible for Docker container or Docker daemon to create user on host OS?</p>
  </li>
  <li><p>How does the ownership and file permission work in Docker volume?</p>
  </li>
  </ol>
  <p>For the 4th question imagine I have the following volume:</p>
  <pre><code>--volume /var/run/docker.sock:/var/run/docker.sock
  </code></pre>
  <p>And the result of the <code>ls</code> and <code>id</code> commands in host OS are as follow:</p>
  <pre><code>root@tashkhisi:/var/run# ls -l docker.sock
  srw------- 1 root docker 0 Jul 30 18:44 docker.sock
  
  root@novinhost:/var/run# id -u  root
  0
  </code></pre>
  <p>Does it mean I can only access that file from within Docker container with user whose id is 0 inside Docker container?<br />
  I mean container see that file with original file permissions but with its own users?</p>
  <p>Please, don't notice the <code>/var/run/docker.sock</code> file I just want to know how permission works.<br />
  I just used it because it is a common use case.</p>