title: How to re-mount a docker volume without overriding existing files?
body: <p>When running Docker, you can mount files and directories using the <code>--volume</code> option. E.g.:</p>
  
  <pre><code>docker run --volume /remote ./local myimage
  </code></pre>
  
  <p>I'm running a docker image that defines <a href="https://docs.docker.com/engine/reference/builder/#/volume" rel="nofollow noreferrer">VOLUMES</a>s in the Dockerfile. I need to access a config file that happens to be inside one of the defined volumes. I'd like to have that file "synced" on the host so that I can edit it. I know I could run <code>docker exec ...</code>, but I hope to circumvent that overhead for only editing one file. I found out that the volumes created by the VOLUMES line are stored in <code>/var/lib/docker/volumes/&lt;HASH&gt;/_data</code>.</p>
  
  <p>Using <code>docker inspect</code> I was able to find the directory that is mounted:</p>
  
  <pre><code>docker inspect gitlab-runner | grep -B 1 '"Destination": "/etc/gitlab-runner"' | head -n 1 | cut -d '"' -f 4
  </code></pre>
  
  <p>Output:</p>
  
  <blockquote>
    <p>/var/lib/docker/volumes/9c233c085c36380c6c33035222c16e5d061368c5060cc81dda2a9a713a2b2b3b/_data</p>
  </blockquote>
  
  <hr>
  
  <p>So the question is:</p>
  
  <p>Is there a way to re-mount volumes defined in an image? OR to somehow get the directory easier than my oneliner above?</p>
  
  <hr>
  
  <p><strong>EDIT</strong> after comments by zeppelin I've tried rebinding the volume with no success:</p>
  
  <pre><code>$ mkdir etc
  
  $ docker run -d --name test1 gitlab/gitlab-runner
  $ docker run -d --name test2 -v ~/etc:/etc/gitlab-runner gitlab/gitlab-runner
  
  $ docker exec test1 ls /etc/gitlab-runner/
  certs
  config.toml
  
  $ docker exec test2 ls /etc/gitlab-runner/
  # empty. no files
  $ ls etc
  # also empty
  </code></pre>
  
  <p><code>docker inspect</code> shows correctly that the volume is bound to <code>~/etc</code>, but the files inside the container at <code>/etc/gitlab-runner/</code> seem lost.</p>