dduportal / boot2docker-vagrant-box

Packer scripts to build a Vagrant-compatible boot2docker box.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Containers not mounting shared sources correctly

phpguru opened this issue · comments

I am able to view the contents of NFS shared files inside vagrant ssh at the path /vagrant however my folders from Mac are not showing up in the /src directory where the run command mounts them. With docker run command:

      docker run -d \
      -P --name db \
      -e APP=db \
      -e MYSQL_ROOT_PASSWORD=ROOTPASSWORD \
      -e MYSQL_USER=DBUSERNAME \
      -e MYSQL_PASSWORD=DBPASSWORD \
      -v /Users/username/Sites/mysqldata:/src \
      mysql

The config above worked with boot2docker, but now that I've migrated to boot2docker-vagrant-box, the mount works into the vagrant box, but my /src directory in the mysql container is empty. The src dir is created though and looks like this:

docker@boot2docker:~$ docker-enter db
root@89649480e099:/# df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1.4G   97M  1.3G   8% /src
/dev/sda2        39G   20G   18G  53% /var/lib/mysql
/dev/sda2        39G   20G   18G  53% /etc/resolv.conf
/dev/sda2        39G   20G   18G  53% /etc/hostname
/dev/sda2        39G   20G   18G  53% /etc/hosts

What am I missing?

Answering my own question, the paths change from the Mac full system path, to the full system path of the NFS share inside the vagrant box, by default, /vagrant, so:

with

config.vm.synced_folder ".", "/vagrant", type: "nfs", mount_options: ["nolock", "vers=3", "udp"], id: "nfs-sync"

in Vagrantfile, use

      docker run -d \
      -P --name db \
      -e APP=db \
      -e MYSQL_ROOT_PASSWORD=ROOTPASSWORD \
      -e MYSQL_USER=DBUSERNAME \
      -e MYSQL_PASSWORD=DBPASSWORD \
      -v /vagrant/mysqldata:/src \
      mysql

to mount the appropriate folder inside the container. See the -v switch setting specifically.