title: Shared Volume in Docker through Vagrant
body: <p>I have a Vagrant virtualbox which hosts a Docker container. The host machine has a folder which needs to be accessible in the vm and the container:</p>
  
  <pre><code>Host: /host/path =&gt; VM: /vagrant/path =&gt; Container: /docker/path
  </code></pre>
  
  <p>Background: <code>/host/path/</code> holds the development files for a project which are available at container level to ensure automatic reloads when a change was made.</p>
  
  <h2>Configuration</h2>
  
  <p>Vagrant:</p>
  
  <pre><code>Vagrant.configure("2") do |config|
    config.vm.synced_folder "/host/path", "/vagrant/path"
  end
  </code></pre>
  
  <p>Docker:</p>
  
  <pre><code>docker run -name mycontainer -d -v /vagrant/path:/docker/path my/image
  </code></pre>
  
  <h2>Problem</h2>
  
  <p>This configuration works until i reload the vm. For example, when i restart my computer and start the vm with <code>vagrant up</code>, the docker container only recognizes an empty folder in <code>/docker/path</code>. I guess that could be some timing or sequencing issue. <code>/vagrant/path</code> is not empty and has the correct content.</p>
  
  <p>My workaround at the moment is to reload the container after each restart of the vm:</p>
  
  <pre><code>docker rm mycontainer 
  docker kill mycontainer 
  docker run -name mycontainer -d -v /vagrant/path:/docker/path my/image
  </code></pre>
  
  <p>That feels wrong. Any ideas?</p>