0

So, despite Docker 1.3 now allowing easy access to external storage on OSX through boot2docker for files in /Users/, I still need to access files not in /Users/. I have a settings file in /etc/settings/ that I'd like my container to have access to. Also, the CMD in my container writes logs to /var/log in the container, which I'd rather have it write to /var/log on the host. I've been playing around with VOLUME and passing stuff in with -v at run, but I'm not getting anywhere. Googling hasn't been much help. Can someone who has this working provide help?

Eli
  • 36,793
  • 40
  • 144
  • 207

1 Answers1

3

As boot2docker now includes VirtualBox Guest Additions, you can now share folders on the host computer (OSX) with guest operating systems (boot2docker-vm). /Users/ is automatically mounted but you can mount/share custom folders. In your host console (OSX) :

 $ vboxmanage sharedfolder add "boot2docker-vm" --name settings-share --hostpath  /etc/settings --automount

Start boot2docker and ssh into it ($boot2docker up / $boot2docker ssh). Choose where you want to mount the "settings-share" (/etc/settings) in the boot2docker VM :

$ sudo mkdir /settings-share-on-guest
$ sudo mount -t vboxsf settings-share /settings-share-on-guest

According that /settings is the volume declared in the docker container add -v /settings-share-on-guest:/settings to the docker run command to mount the host directory settings-share-on-guest as a data volume.

Works on Windows, not tested on OSX but should work.

jclagache
  • 46
  • 2
  • Why do you have to supply the uid and gid? – Eli Nov 19 '14 at 23:49
  • I needed to mount two things, and one would overwrite the other when I specified gid and uid. When I switched to just `sudo mount -t vboxsf settings-share /settings-share-on-guest` everything worked. Awesome answer anyway though! – Eli Nov 19 '14 at 23:56
  • Answer edited as gid and uid are not mandatory. I don't know why it overwrites your first mount. – jclagache Nov 20 '14 at 10:16
  • On `OSX` the share can be created using Virtualbox Manager tool aswell - here you can set it to automount – singh1469 Mar 06 '15 at 16:05