Docker外部文件访问不在OSX中的/ Users /中 [英] Docker External File Access Not in /Users/ on OSX
问题描述
所以,尽管 Docker 1.3现在允许通过boot2docker轻松访问OSX上的外部存储,用于/ Users / 中的文件,我仍然需要访问不在/ Users /中的文件。我有一个设置文件在/ etc / settings /我想让我的容器访问。另外,我的容器中的CMD将日志写入容器中的/ var / log,我宁愿把它写入主机上的/ var / log。我一直在玩 VOLUME
,并在运行时传递东西与 -v
,但我没有得到任何地方。谷歌没有太多的帮助。有人可以帮助吗?
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?
推荐答案
如boot2docker现在包括VirtualBox Guest添加,现在可以使用客户机操作系统(boot2docker-vm)在主机(OSX)上共享文件夹。 / Users /自动挂载,但您可以挂载/共享自定义文件夹。在您的主机控制台(OSX)中:
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
启动boot2docker和ssh( $ boot2docker up
/ $ boot2docker ssh
)。
选择要在boot2docker VM中安装settings-share(/ etc / settings)的位置:
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
根据 / settings
是在docker容器中声明的卷add -v / settings-share -on-guest:/ settings
到docker运行命令到挂载主机目录设置 - 作为数据卷共享。
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.
适用于Windows ,没有在OSX上测试但应该工作。
Works on Windows, not tested on OSX but should work.
这篇关于Docker外部文件访问不在OSX中的/ Users /中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!