title: Can't access mounted host directory in Docker container
body: <p>I'm trying to get my Docker container to read and write to a host directory.</p>
  
  <p>I run the container with:</p>
  
  <pre><code>docker run -it -v $(pwd):/file logstash-5.1.2
  </code></pre>
  
  <p>Inside the container, I can see that /file has the uid of my (non-root) user on the host, and the same permissions as that on the host:</p>
  
  <pre><code>drwxrwxrwx.   2 1156 1156 4096 Jul 21 05:00 file
  </code></pre>
  
  <p>and that root can't access /file.</p>
  
  <pre><code>root@c642b0c37e09:~# ls /file
  ls: cannot open directory /file: Permission denied
  </code></pre>
  
  <p>I've read posts about creating a user in the container with the same uid as the host, but that seems to be frowned upon.</p>
  
  <ol>
  <li>Why can't root access the directory? I thought it could do everything.</li>
  <li>What's the best way to have the container read and write to the mounted directory, which is not owned by root, in Docker?</li>
  <li>We're also using Rancher. Does that make it easier? I haven't yet come across something different there, mainly as I'm trying to see if I can do it purely within Docker.</li>
  </ol>