boot2docker启动脚本与主机挂载本地共享文件夹 [英] boot2docker startup script to mount local shared folder with host

查看:1010
本文介绍了boot2docker启动脚本与主机挂载本地共享文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Win7上运行boot2docker 1.3。

I'm running boot2docker 1.3 on Win7.

我想连接一个共享文件夹。

I want to connect a shared folder.

在VirtualBox Manager中的图像属性 - >共享文件夹下,我添加了我想要的文件夹,并将其命名为c / shared。检查自动挂载和永久框。

In the VirtualBox Manager under the image properties->shared folders I've added the folder I've want and named it "c/shared". The "auto-mount" and "make permanent" boxes are checked.

当boot2docker启动时,它不会挂载。我必须做一个额外的事情:

When boot2docker boots, it isn't mounted though. I have to do an additional:

sudo mount -t vboxsf c/shared /c/shared

以显示它。
由于我需要每次我会使用docker,所以我想要运行在启动,或只是已经在那里。所以我想如果有一些启动脚本我可以添加,但我似乎找不到哪里会。

for it to show up. Since I need that for every time I'll ever use docker, I'd like that to just run on boot, or just already be there. So I thought if there were some startup script I could add, but I can't seem to find where that would be.

谢谢

编辑:对我来说,这是 Boot2Docker的副本在Mac上 - 访问本地文件这是一个不同的问题。我想挂载一个不是默认值的文件夹,例如OSX上的/ User或Windows上的/ c / Users。我特别要求启动脚本。

It's yelling at me about this being a duplicate of Boot2Docker on Mac - Accessing Local Files which is a different question. I wanted to mount a folder that wasn't one of the defaults such as /User on OSX or /c/Users on windows. And I'm specifically asking for startup scripts.

推荐答案

/ var / lib / boot2docker / bootlocal。 sh 适合您的需要,它将由初始脚本运行 /opt/bootscripts.sh

/var/lib/boot2docker/bootlocal.sh fits your need probably, it will be run by initial script /opt/bootscripts.sh

bootscripts.sh 也将输出输入到 /var/log/bootlocal.log 请参阅下面的段落(boot2docker 1.3.1版本)

And bootscripts.sh will also put the output into the /var/log/bootlocal.log, see segment below (boot2docker 1.3.1 version)

# Allow local HD customisation
if [ -e /var/lib/boot2docker/bootlocal.sh ]; then
   /var/lib/boot2docker/bootlocal.sh > /var/log/bootlocal.log 2>&1 &
fi 

我的一个用例是

我通常将共享目录作为 / c / Users / larry / shared ,然后添加脚本

I usually put shared directory as /c/Users/larry/shared, then I add script

#/bin/bash
ln -s  /c/Users/larry/shared /home/docker/shared

所以每次我可以访问〜/ shared 在boot2docker中与主机相同

So each time, I can access ~/shared in boot2docker as the same as in host

请参阅 FAQ.md (由@KCD提供)

see FAQ.md (provided by @KCD)

这篇关于boot2docker启动脚本与主机挂载本地共享文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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