title: What is the (best) way to manage permissions for Docker shared volumes?
body: <p>I've been playing around with Docker for a while and keep on finding the same issue when dealing with persistent data.</p>
  
  <p>I create my <code>Dockerfile</code> and <a href="http://docs.docker.io/reference/builder/#volume" rel="noreferrer">expose a volume</a> or use <code>--volumes-from</code> to <a href="https://stackoverflow.com/questions/18496940/how-to-deal-with-persistent-storage-e-g-databases-in-docker">mount a host folder inside my container</a>.</p>
  
  <p>What permissions should I apply to the shared volume on the host?</p>
  
  <p>I can think of two options:</p>
  
  <ul>
  <li><p>So far I've given everyone read/write access, so I can write to the folder from the Docker container.</p></li>
  <li><p>Map the users from host into the container, so I can assign more granular permissions. Not sure this is possible though and haven't found much about it. So far, all I can do is run the container as some user: <code>docker run -i -t -user="myuser" postgres</code>, but this user has a different UID than my host <code>myuser</code>, so permissions do not work. Also, I'm unsure if mapping the users will pose some security risks.</p></li>
  </ul>
  
  <p>Are there other alternatives?</p>
  
  <p>How are you guys/gals dealing with this issue?</p>