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

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

问题描述

我在 Win7 上运行 boot2docker 1.3.

I'm running boot2docker 1.3 on Win7.

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

I want to connect a shared folder.

在图像属性->共享文件夹下的 VirtualBox 管理器中,我添加了我想要的文件夹并将其命名为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.

谢谢

它对我大喊大叫这是 Mac 上的 Boot2Docker - Accessing本地文件 这是一个不同的问题.我想挂载一个不是默认值之一的文件夹,例如 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 

我的一个用例是

我通常把shared目录设为/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

所以每次我都可以在 boot2docker 中访问 ~/shared 就像在主机中一样

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

FAQ.md(@KCD 提供)

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

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