Search code examples
linuxdockervirtual-machineopensuseshared-directory

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. please help.


Solution

  • 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 i.e. TAGNAME)

    use the command inside the 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.

    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. This solves the problem. :)