adlogix / docker-machine-nfs

Activates NFS on docker-machine
MIT License
794 stars 104 forks source link

Cannot detect the NFS mount #103

Open zored opened 4 years ago

zored commented 4 years ago

Thanks for such a nice project! ❤️

I get this error on macOS Catalina 10.15.3:

+ docker-machine-nfs default --ip=192.168.99.200 --force --shared-folder=/Users
[INFO] Configuration:

    - Machine Name: default
    - Shared Folder: /Users
    - Mount Options: noacl,async,nfsvers=3
    - Force: true

[INFO] machine presence ...             OK
[INFO] machine running ...          OK
[INFO] Lookup mandatory properties ... OK

    - Machine IP: 192.168.99.200
    - Network ID: vboxnet0
    - NFSHost IP: 192.168.99.1

[INFO] Configure NFS ...

 !!! Sudo will be necessary for editing /etc/exports !!!
                        OK
[INFO] Configure Docker Machine ...         OK
[INFO] Restart Docker Machine ...       OK
[INFO] Verify NFS mount ...             FAIL

Cannot detect the NFS mount :(
zored commented 4 years ago

Currently commenting this line out helped.

tonivdv commented 4 years ago

Currently commenting this line out helped.

Mmh that line was added during #102 ... @mtibben does it still work great for you? I'm not using docker toolbox and thus docker machine any more :/ so hard to figure it out ...

mtibben commented 4 years ago

Yep, haven't heard any reports of breaking from our 30 devs.. just created a machine and tested, all seems to be working OK for me. Might need more info to debug further @zored

tonivdv commented 4 years ago

@zored you think there is still an issue or we can close this one?

akurov-lam commented 4 years ago

Currently commenting this line out helped.

It helped me too.

I created my first docker-machines in December of 2019 and docker-machine-nfs worked fine. After some macOS update at spring of this year docker-machine-nfs stopped to work properly: there wasn't any impact on performance of docker-machine.

For the first docker-machines there were the next entries in /etc/exports:

# docker-machine-nfs-begin vm1 #
"/Users" 192.168.99.101 -alldirs -mapall=513103068:195260738
# docker-machine-nfs-end vm1 #

# docker-machine-nfs-begin vm2 #
"/Users" 192.168.99.103 -alldirs -mapall=513103068:195260738
# docker-machine-nfs-end vm2 #

And so on. After that update of macOS for the new docker-machines next entries start to appear:

# docker-machine-nfs-begin vm3 #
"/System/Volumes/Data/Users" 192.168.99.106 -alldirs -mapall=513103068:195260738
# docker-machine-nfs-end vm3 #

The difference is obviously in paths.

When I have commented out the line as @zored suggested docker-machine-nfs starts to work for new machines. And new entry in /etc/exports have been created with old-style path:

# docker-machine-nfs-begin vm4 #
"/Users" 192.168.99.114 -alldirs -mapall=513103068:195260738
# docker-machine-nfs-end vm4 #

The output of mount:

/dev/disk1s5 on / (apfs, local, read-only, journaled)
devfs on /dev (devfs, local, nobrowse)
/dev/disk1s1 on /System/Volumes/Data (apfs, NFS exported, local, journaled, nobrowse)
/dev/disk1s4 on /private/var/vm (apfs, local, journaled, nobrowse)
map auto_home on /System/Volumes/Data/home (autofs, automounted, nobrowse)
map -fstab on /System/Volumes/Data/Network/Servers (autofs, automounted, nobrowse)
/dev/disk2s1 on /Volumes/Android Studio 4.0.1 (hfs, local, nodev, nosuid, read-only, noowners, quarantine, mounted by some.user)

the output of docker-machine ssh default "sudo mount" | grep nfs is empty for the machines that were processed by un-fixed docker-machine-nfs. For the machines that were processed by fixed docker-machine-nfs the output is 192.168.99.1:/Users on /Users type nfs (rw,relatime,vers=3,rsize=65536,wsize=65536,namlen=255,hard,noacl,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.99.1,mountvers=3,mountport=886,mountproto=udp,local_lock=none,addr=192.168.99.1)

mtibben commented 4 years ago

@akurov-lam /System/Volumes/Data/Users is the correct /etc/exports entry. Maybe the old /Users entries are causing problems.

I'd suggest

  1. Revert your changes to docker-machine-nfs - you really need that line
  2. completely clear out your /etc/exports
  3. sudo nfsd restart
  4. restart all your docker-machines
  5. then run docker-machine-nfs to set them up again.
akurov-lam commented 4 years ago

Thank you, it helped. But I made a little bit more to be sure that everything works from scratch.

  1. I removed all docker-machines
  2. I removed all entries in /etc/exports
  3. I rebooted mac

Now docker-machine-nfs works fine for me:

someuser@MAC-01194 path % docker-machine-nfs vm
[INFO] Configuration:

    - Machine Name: vm 
    - Shared Folder: /Users 
    - Mount Options: noacl,async,nfsvers=3 
    - Force: false 

[INFO] machine presence ...                     OK 
[INFO] machine running ...                      OK 
[INFO] Lookup mandatory properties ... OK 

    - Machine IP: 192.168.99.118 
    - Network ID: vboxnet0 
    - NFSHost IP: 192.168.99.1 

[INFO] Configure NFS ... 

 !!! Sudo will be necessary for editing /etc/exports !!! 
Password:
                                            OK 
[INFO] Configure Docker Machine ...             OK 
[INFO] Restart Docker Machine ...               OK 
[INFO] Verify NFS mount ...                     OK 

--------------------------------------------

 The docker-machine 'vm'
 is now mounted with NFS!

 ENJOY high speed mounts :D

--------------------------------------------
zendex commented 3 years ago

Actual behavior

docker-machine-nfs log

[INFO] Configuration:

    - Machine Name: default
    - Shared Folder: /Users
    - Mount Options: noacl,async,nfsvers=3
    - Force: false

[INFO] machine presence ...             OK
[INFO] machine running ...          OK
[INFO] Lookup mandatory properties ...      OK

    - Machine IP: 192.168.99.105
    - Network ID: vboxnet0
    - NFSHost IP: 192.168.99.1

[INFO] Configure NFS ...

 !!! Sudo will be necessary for editing /etc/exports !!!
Password:
                        OK
[INFO] Configure Docker Machine ...         OK
[INFO] Restart Docker Machine ...       OK
[INFO] Verify NFS mount ...             FAIL

Cannot detect the NFS mount :(

virtual machine log

sudo: <HOMEBREW_PREFIX>/etc/init.d/nfs-client: command not found
mount.nfs: rpc.statd is not running but is required for remote locking.
mount.nfs: Either use '-o nolock' to keep locks local, or start statd

Information

Workarounds to solve this issue

If you use alternative homebrew installs as https://docs.brew.sh/Installation#multiple-installations or https://docs.brew.sh/Installation#untar-anywhere and your HOMEBREW_PREFIX value is different from /usr/local the docker-machine-nfs script doesn't work fine.

To check your HOMEBREW_PREFIX run

$ brew config

To solve this issue replace the line with

<HOMEBREW_PREFIX>/etc/init.d/nfs-client start

on

/usr/local/etc/init.d/nfs-client start

in <HOMEBREW_PREFIX>/Cellar/docker-machine-nfs/0.5.4/bin/docker-machine-nfs file or install Homebrew to its preferred prefix /usr/local.

Surprisingly, the source code contains the correct path to nfs-client, but after installation <HOMEBREW_PREFIX>/Cellar/docker-machine-nfs/0.5.4/.brew/docker-machine-nfs.rb replaces it

inreplace "docker-machine-nfs.sh", "/usr/local", HOMEBREW_PREFIX

I hope this helps someone.