Search code examples
dockerboot2docker

Docker External File Access Not in /Users/ on OSX


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?


Solution

  • 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.