title: Overlapping bind-mounts and permissions in docker on linux
body: <p>Overlapping bind mounts on a linux host seems to create ghost files on the host machine owned by <code>root</code>. Is this intended? Here's an example:</p>
  
  <pre><code># Create a file to mount in the container
  touch hostfile
  # Create a temporary directory to mount in the container
  mkdir tempdir
  # Run bash in the container and mount the file and directory
  docker run --rm --volume=`pwd`/tempdir:/home --volume=`pwd`/hostfile:/home/hostfile ubuntu bash
  </code></pre>
  
  <p>After running the command, the <code>hostfile</code> can be found in the <code>tempdir</code> but is owned by <code>root</code>. </p>
  
  <p>Note that</p>
  
  <ul>
  <li>running the same bash script on an OS X host results in the <code>hostfile</code> being owned by the user who started the container,</li>
  <li>specifying the user and group id of the user on the host machine as part of the <code>docker run</code> call does not change anything.</li>
  </ul>