Docker + Ubuntu + Virtualbox:“卷"dockerfile 中的指令不起作用 [英] Docker + Ubuntu + Virtualbox: "volumes" directive in dockerfile not working

查看:19
本文介绍了Docker + Ubuntu + Virtualbox:“卷"dockerfile 中的指令不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Docker + Ubuntu + Virtualbox:dockerfile 中的volumes"指令不起作用?请参阅下面的解决方案.

解决方案

只是在这里测试 Docker 并且已经在前面一个问题:

之后,您使用 docker-machine ssh [name] 进入您的机器,并且您必须从您的共享创建一个到来宾的 /home 的符号链接docker 中的主文件夹(主机已映射):

ln -s "/Users/[用户名]/${d}" "/home/${d}"

从这里开始,映射一定没问题,您可以开始了!o/

对前端的 PS:如果您打算使用 LiveReload 在您的项目中,您需要在终端中运行 vboxmanage controlvm default natpf1 "35729,tcp,127.0.0.1,35729,,35729" (不在 docker 机器内,在主机中)-所有项目只需一次.

Docker + Ubuntu + Virtualbox: "volumes" directive in dockerfile not working? See the solution below.

解决方案

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 and 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".

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.

这篇关于Docker + Ubuntu + Virtualbox:“卷"dockerfile 中的指令不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆