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