title: Why docker in docker (dind) containers mount volumes with host path?
body: <p>I have a setup with docker in docker and try to mount folders.</p>
  
  <p>Let's say I have those folders that I wish to share with his parent. On the host, I created a file in /tmp/dind called <code>foo</code>. Host starts container 1, which starts container 2. This is the result I want to have.</p>
  
  <pre><code>Host      | Container 1 | Container 2
  
  /tmp/dind |  /tmp/dind2 | /tmp/dind3
        &lt;-------&gt;     &lt;-------&gt;
  </code></pre>
  
  <p>Instead, I get</p>
  
  <pre><code>Host      | Container 1 | Container 2
  
  /tmp/dind |  /tmp/dind2 | /tmp/dind3
        &lt;-------&gt;
        &lt;-----------------------&gt;
  </code></pre>
  
  <p>Code here:</p>
  
  <pre><code>docker run --rm -it \
    -v /tmp/dind:/tmp/dind2 \
    -v /var/run/docker.sock:/var/run/docker.sock docker sh -c \
      "docker run --rm -it \
        -v /tmp/dind2:/tmp/dind3 \
        -v /var/run/docker.sock:/var/run/docker.sock \
        docker ls /tmp/dind3"
  </code></pre>
  
  <p>This outputs nothing, while the next command gives foo as result. I changed the mounted volume:</p>
  
  <pre><code>docker run --rm -it \
    -v /tmp/dind:/tmp/dind2 \
    -v /var/run/docker.sock:/var/run/docker.sock docker sh -c \
      "docker run --rm -it \
        -v /tmp/dind:/tmp/dind3 \
        -v /var/run/docker.sock:/var/run/docker.sock \
        docker ls /tmp/dind3"
  </code></pre>
  
  <p>The question is, what do I need to do in order to use Container 1 path and not host? Or do I misunderstand something about docker here?</p>