Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker + Ubuntu + Virtualbox: "volumes" directive in dockerfile not working

Just testing Docker here and already in front an issue: the "volumes" directive in dockerfile seems like not working in Ubuntu -- OK in Mac and Windows. All the proccess with docker-machine and docker-compose alright and the environment ups, but the filesystem without the sharing folders.

After trying MANY things and a lot of researching with my pals, we found this issue in GitHub: "Add support to mount Linux host homedir".

Basically, the problem is the fail of Docker in mount host home dir in container. They plan to include the fix in future releases, but, meanwhile, if you need to use right now, here is what you have to do.

Open Virtualbox interface, right click in your machine, Settings > Shared Folders. You can delete whatever is filled and add a new one. In path, choose your /home and name Users (could be whatever name, but this one is for name consistency with Mac and Windows). Check automatic mounting and persistence and press "OK".

Virtualbox config sample

After that, you enter in your machine with docker-machine ssh [name] and you have to create a symlink to the /home of the guest from your shared home folder in docker (host already mapped):

ln -s "/Users/[your username]/${d}" "/home/${d}"

From here, the mapping must be alright and you good to go! \o/

PS to frontenders: if you intend to use LiveReload in your projects, you need to run vboxmanage controlvm default natpf1 "35729,tcp,127.0.0.1,35729,,35729" in your terminal (not inside docker machine, in host) -- just once for all projects.

like image 588
Tárcio Zemel Avatar asked Dec 24 '22 09:12

Tárcio Zemel


1 Answers

Just testing Docker here and already in front an issue: the "volumes" directive in dockerfile seems like not working in Ubuntu -- OK in Mac and Windows. All the proccess with docker-machine and docker-compose alright and the environment ups, but the filesystem without the sharing folders.

After trying MANY things and a lot of researching with my pals, we found this issue in GitHub: "Add support to mount Linux host homedir".

Basically, the problem is the fail of Docker in mount host home dir in container. They plan to include the fix in future releases, but, meanwhile, if you need to use right now, here is what you have to do.

Open Virtualbox interface, right click in your machine, Settings > Shared Folders. You can delete whatever is filled and add a new one. In path, choose your /home and name Users (could be whatever name, but this one is for name consistency with Mac and Windows). Check automatic mounting and persistence and press "OK".

Virtualbox config sample

After that, you enter in your machine with docker-machine ssh [name] and you have to create a symlink to the /home of the guest from your shared home folder in docker (host already mapped):

ln -s "/Users/[username]/${d}" "/home/${d}"

From here, the mapping must be alright and you good to go! \o/

PS to frontenders: if you intend to use LiveReload in your projects, you need to run vboxmanage controlvm default natpf1 "35729,tcp,127.0.0.1,35729,,35729" in your terminal (not inside docker machine, in host) -- just once for all projects.

like image 156
Tárcio Zemel Avatar answered Dec 26 '22 22:12

Tárcio Zemel