Tuesday, April 28, 2015

Setting up boot2docker and working with live-reload directory the easy way



Checkout https://github.com/boot2docker/boot2docker/pull/534

Download latest boot2docker from:
https://github.com/boot2docker/windows-installer/releases

If you access the boot2docker VM via the following:
$boot2docker ssh

You will not be able to have access to your host developement files. To make your
developement files accessible do the following in Windows:

$boot2docker stop
$VBoxManage.exe sharedfolder add boot2docker-vm --name Users --hostpath C:/Users --automount.



Note 1: if you are using cygwin you have to use the syntax C:/Users, not C:\Users
Note 2:
hostpath Users` share at `/Users` in the boot2docker VM
hostpath /Users` share at `/Users`  in the boot2docker VM
hostpath c/Users` share at `/c/Users`  in the boot2docker VM
hostpath /c/Users` share at `/c/Users`  in the boot2docker VM
hostpath c:/Users` share at `/c/Users`  in the boot2docker VM


$boot2docker up
$boot2docker ssh "ls /Users"

Voila!  You will see your files inside boot2docker !

But how about using another path than Users above ?
Do as follows:


$VBoxManage.exe sharedfolder add boot2docker-vm --name Afrepo --hostpath F:/gitrepositories2 --automount

$ boot2docker ssh "ls /"
You will not find your Afrepo in the list, right? Try the following:
$ boot2docker ssh "mkdir /home/docker/Afrepo && sudo mount -t vboxsf -o uid=1000,gid=50 Afrepo /home/docker/Afrepo"


You files at F:/gitrepositories2 - in your host will be accessible inside boot2docker VM and finally to your docker !

Try the following:
$ boot2docker ssh
$docker run -v /Users/...:...   if you have used Users as sharename or
$docker run -v /Afrepo/...: ...  if you have used Afrepo as sharename