Parallels / docker-machine-parallels

Parallels driver for Docker Machine https://github.com/docker/machine
MIT License
471 stars 35 forks source link

Allow prl_fs to follow symlinks when mounting /Users #77

Closed shehzaman closed 5 years ago

shehzaman commented 5 years ago

Is there a way to mount all folders that are symlinked in /Users?

/Users is mounted as expected when using the driver

docker@default:/$ ls -la
total 8
drwxr-xr-x   17 root     root           440 Nov 29 06:33 .
drwxr-xr-x   17 root     root           440 Nov 29 06:33 ..
-rw-------    1 root     root          1024 Nov 29 06:33 .rnd
drwxr-xr-x    1 nobody   root           204 Oct 30  2015 Users
drwxr-xr-x    2 root     root          1420 Nov 29 06:32 bin
drwxrwxr-x   15 root     staff         4360 Nov 29 06:32 dev
drwxr-xr-x    9 root     root          1000 Dec  2 10:59 etc
drwxrwxr-x    4 root     staff           80 Nov 29 06:32 home
-rwxr-xr-x    1 root     root           496 Nov  8 01:53 init
drwxr-xr-x    4 root     root           840 Nov 29 06:32 lib
lrwxrwxrwx    1 root     root             3 Nov 29 06:32 lib64 -> lib
lrwxrwxrwx    1 root     root            11 Nov 29 06:32 linuxrc -> bin/busybox
drwxr-xr-x    4 root     root            80 Nov 29 06:33 mnt
drwxrwsr-x    2 root     staff          160 Nov 29 06:32 opt
dr-xr-xr-x   98 root     root             0 Nov 29 06:32 proc
drwxrwxr-x    2 root     staff           80 Nov 29 06:32 root
drwxrwxr-x    6 root     staff          120 Nov 29 06:33 run
drwxr-xr-x    2 root     root          1300 Nov 29 06:32 sbin
dr-xr-xr-x   13 root     root             0 Nov 29 06:32 sys
lrwxrwxrwx    1 root     root            13 Nov 29 06:33 tmp -> /mnt/sda1/tmp
drwxr-xr-x    7 root     root           140 Nov 29 06:32 usr
drwxrwxr-x    8 root     staff          180 Nov 29 06:32 var

If any folder inside /Users is symlinked outside /Users - the folder does not show up

docker@default:/Users/apple$ ls -la
drwx------    1 root     root           170 Jan 16  2018 Downloads
lrwxr-xr-x    1 root     root            36 Aug 20  2017 DownloadsLocal -> /Volumes/Macintosh HD/DownloadsLocal
drwx------    1 root     root          2686 Nov 27 12:06 Library
lrwxr-xr-x    1 root     root            29 Dec 14  2014 Movies -> /Volumes/Macintosh HD/Movies/
lrwxr-xr-x    1 root     root            28 Dec 14  2014 Music -> /Volumes/Macintosh HD/Music/
lrwxr-xr-x    1 root     root            32 Feb 18  2016 Parallels -> /Volumes/Macintosh HD/Parallels/
lrwxr-xr-x    1 root     root            31 Dec 14  2014 Pictures -> /Volumes/Macintosh HD/Pictures/
drwxr-xr-x    1 root     root           170 Sep 17  2014 Public
drwxr-xr-x    1 root     root           136 Oct 27 20:18 Sites

The folders symlinked to /Volumes/Machintosh HD/... are not accessible inside boot2docker VM.

Is there a way to mount these folders automatically?

legal90 commented 5 years ago

Hi @shehzaman, Unfortunately, that is not possible at this moment. Currently symlinks work only if they refer to folders inside /Users directory.

I'm also not sure that the possible auto-detection is the good thing to go. However, I think we can implement the new CLI flag which will allow do define additional shared folder path or override the default one (currently it is hard-coded to /Users: https://github.com/Parallels/docker-machine-parallels/blob/master/parallels_darwin.go#L29).

I will get back with a solution soon.

romankulikov commented 5 years ago

Is Machine's mount command a possible workaround for this type of problems? Moreover is it possible to "overwrite" mount from SSHFS to Parallels Shared Folders in case of our driver?

legal90 commented 5 years ago

I don't think so. docker-machine mount command works in other way around: it allows to mount the guest's path on the host

Files are actually being stored on the machine, not on the host. So make sure to make a copy of any files you want to keep, before removing it!

https://docs.docker.com/machine/reference/mount/

I was thinking about implementing some option similar to --virtualbox-share-folder from virtualbox driver, but maybe using a list instead https://github.com/docker/machine/blob/821e8c76f048ca9323ecc9440c0e3d3d5ec4906d/drivers/virtualbox/virtualbox.go#L248

For example:

shehzaman commented 5 years ago

@legal90 having a new CLI option will make it much easier! Thank you very much for looking into this.

romankulikov commented 5 years ago

I was thinking about implementing some option similar to --virtualbox-share-folder from virtualbox driver, but maybe using a list instead

Personally it'd rather follow VB "style"with specifying only one directory for consistency. But if multiple directories sharing is implemented I suggest to use colon as divider of the path list.

legal90 commented 5 years ago

Personally it'd rather follow VB "style"with specifying only one directory for consistency.

OK. I just thought that this kind of consistency is not very important since drivers don't interact with each other and use unique CLI arguments anyway. So we have a chance to make our driver a bit more convenient for the end user. For example, in VB (--virtualbox-share-folder) in addition to the shared folder path, the user also has to specify the share name, which is just an internal identifier and not what user should worry about.

But if multiple directories sharing is implemented I suggest to use colon as divider of the path list.

Sorry, I'm not sure this is not the best choice. Looking at different CLI tools, I can say that in most cases the colon : is used for mappings, while comma , is the right choice for lists.

I'll prepare the PR, so we will see how it looks.

romankulikov commented 5 years ago

Sorry, I'm not sure this is not the best choice. Looking at different CLI tools, I can say that in most cases the colon : is used for mappings, while comma , is the right choice for lists.

Comma is a valid symbol for a path component. And, for example, LD_LIBRARY_PATH uses colon as a divider.

Alternative variant: can we support passing multiple --parallels-shared-folder options? So each other adds new Shared Folder?

legal90 commented 5 years ago

Alternative variant: can we support passing multiple --parallels-shared-folder options? So each other adds new Shared Folder?

Oh yes! We actually can. I will do it in that way 👍

legal90 commented 5 years ago

@shehzaman in v1.4.0 we've added the --parallels-share-folder option which allows you to mount custom paths, for example:

docker-machine create -d parallels \
    --parallels-share-folder "/Volumes/Macintosh HD" \
    --parallels-share-folder "/Users" \
    test-vm

In this case your symlinks from /Users to /Volumes/Macintosh HD should work.

NB: Sharing the system paths with your VM is on your risk!

shehzaman commented 5 years ago

@legal90 Thank's a tonne! Tested and working very well!

NB: Yes, all risk is mine 👍