从Windows到Boot2docker VM共享文件的最佳方式是什么? [英] What's the best way to share files from Windows to Boot2docker VM
问题描述
我还发现boot2docker无法持续我的更改。例如,我创建一个文件夹/ temp,在我重新启动boot2docker后,这个文件夹消失了,这是非常不方便的。
当你在Windows上有一些代码时,但是你需要对他们进行邮寄吗?
---更新---
更新虚拟框中的设置并重新启动boot2docker,但它不能在我的机器上工作。
docker @ boot2docker:/ $ ls -al / c
总计4
drwxr-xr-x 3根根60六月17 05:42 ./
drwxrwxr-x 17根根400六月17 05:42 ../
dr-xr- xr-x 1码头工作人员4096 Jun 16 09:47用户/
Boot2Docker是一个小Linux VM在VirtualBox上运行。因此,在可以使用Docker(在此虚拟机中运行)的文件(Windows中)之前,您必须先使用Boot2Docker VM本身共享您的代码。
要执行此操作,您将Windows文件夹挂载到VM时关闭(此处的VM名称为默认为
)
C:/ Program Files / Oracle / VirtualBox / VBoxManage sharedfolder \
添加默认名称win_share -hostpath c:/ work
也可以打开VirtualBox UI,并将文件夹安装到虚拟机上,就像您在屏幕截图中一样!)
现在 ssh
进入Docker Quickstart终端的Boot2Docker VM:
docker-machine ssh default
/ p>
然后执行mount:
- 在VM内创建一个文件夹:
sudo mkdir / VM_share
- 将Windows文件夹挂载到它:
sudo mount -t vboxsf win_share / VM_share
之后,您可以访问 C:/ work
在Boot2Docker VM内:
cd / VM_share
现在您的代码存在于您的虚拟机中,您可以将其与Docker一起使用,或者将其作为卷加载到容器: docker-machine ssh default
docker run --volume / VM_share:/ folder / in / container一些/ image
或者在构建Docker镜像时使用它:
...
添加/ my_windows_folder /文件夹
...
I have make my code ready on Windows, but I find it's not easy to share to boot2docker.
I also find that boot2docker can't persistent my changes. For example, I create a folder /temp, after I restart boot2docker, this folder disappears, it's very inconvenient.
What is your way when you have some code on windows, but you need to dockerized them?
---update---
I try to update the setting in Virtual Box and restart boot2docker, but it's not working on my machine.
docker@boot2docker:/$ ls -al /c
total 4
drwxr-xr-x 3 root root 60 Jun 17 05:42 ./
drwxrwxr-x 17 root root 400 Jun 17 05:42 ../
dr-xr-xr-x 1 docker staff 4096 Jun 16 09:47 Users/
解决方案 Boot2Docker is a small Linux VM running on VirtualBox. So before you can use your files (from Windows) in Docker (which is running in this VM), you must first share your code with the Boot2Docker VM itself.
To do so, you mount your Windows folder to the VM when it is shutdown (here a VM name of default
is assumed):
C:/Program Files/Oracle/VirtualBox/VBoxManage sharedfolder \
add default -name win_share -hostpath c:/work
(Alternatively you can also open the VirtualBox UI and mount the folder to your VM just as you did in your screenshot!)
Now ssh
into the Boot2Docker VM for the Docker Quickstart Terminal:
docker-machine ssh default
Then perform the mount:
- Make a folder inside the VM:
sudo mkdir /VM_share
- Mount the Windows folder to it:
sudo mount -t vboxsf win_share /VM_share
After that, you can access C:/work
inside your Boot2Docker VM:
cd /VM_share
Now that your code is present inside your VM, you can use it with Docker, either by mounting it as a volume to the container:
docker-machine ssh default
docker run --volume /VM_share:/folder/in/container some/image
Or by using it while building your Docker image:
...
ADD /my_windows_folder /folder
...
这篇关于从Windows到Boot2docker VM共享文件的最佳方式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!