简体   繁体   English

如何在opensuse中的同一台机器上的VM和docker之间共享目录?

[英]How to share directory between VM and docker on same machine in opensuse?

I know how to have a shared directory between docker and host and even VM and host, is there a way to directly share a directory between VM and the Docker in OpenSUSE, I am using virtual machine manager for the VM. 我知道如何在docker和host之间以及甚至VM和host之间建立共享目录,是否有一种方法可以在OpenSUSE中直接在VM和Docker之间共享目录,我正在为VM使用虚拟机管理器。 please help. 请帮忙。

Finally found the answer assign a tag to the VM filesystem(add file system from the "add hardware" option provided in the VM assign a string to it ie TAGNAME) 最后找到答案,为VM文件系统分配标签(通过VM中提供的“添加硬件”选项添加文件系统,为其分配字符串,即TAGNAME)

use the command inside the VM: 在VM内使用命令:

sudo mount -t 9p -o trans=virtio,version=9p2000.L,rw TAGNAME /MOUNT_POINT

And to make this directory permanently appear after every boot, edit the /etc/fstab , add this line at the end. 为了使该目录在每次引导后永久显示,请编辑/ etc / fstab,并在末尾添加此行。

TAG   /MOUNT_POINT    9p  trans=virtio,version=9p2000.L,rw    0   0

To make the folder available from docker just use the -v option during docker creation and specify the same folder as source. 要使该文件夹可从docker使用,只需在docker创建期间使用-v选项并指定与source相同的文件夹即可。 This solves the problem. 这样就解决了问题。 :) :)

The bind mount (-v or --mount) should apply within a VM as it does from a Host, in order to share a folder to your Docker container. 绑定挂载(-v或--mount)应该像从主机那样应用于VM,以便将文件夹共享到Docker容器。

I do that all the time between a KVM and Docker container on SLES 12SP3 (not OpenSuse, but close) 我一直在SLES 12SP3上的KVM和Docker容器之间执行此操作(不是OpenSuse,而是关闭)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM