adlogix / docker-machine-nfs

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

bootlocal.sh is not written #31

Closed jeromegn closed 8 years ago

jeromegn commented 8 years ago

After a few hours of troubleshooting and trying every method I could think of to mount a nfs volume in my docker-machine, I figured out that the bootlocal.sh was just left empty.

I wrote the bootlocal.sh file manually to make it work.

Not entirely sure where that goes wrong though. I'm using OS X 10.11.1 and running docker-machine 0.5.5.

daigotanaka commented 8 years ago

@jeromegn: I was helping my co-worker to set up docker-machine-nfs and we experienced the same issue. Manually generating bootlocal.sh seems to work. docker-machine-nfs has been working fine on my machine (Yosemite 10.10.5) with docker-machine-nfs.sh pulled on Dec 3, 2015. My co-worker's machine is El Capitan. Since configureBoot2Docker() in docker-machine-nfs.sh that auto-generates bootlocal.sh has not changed since I pulled the code, I suspect this is docker-machine issue on El Capitan with virtualbox? I am just guessing.

jeromegn commented 8 years ago

Yes that's also my configuration. On Mon, Jan 4, 2016 at 8:17 PM Daigo Tanaka notifications@github.com wrote:

@jeromegn https://github.com/jeromegn: I was helping my co-worker to set up docker-machine-nfs and we experienced the same issue and manually generating bootlocal.sh seems to work. docker-machine-nfs has been working fine on my machine (Yosemite 10.10.5) with docker-machine-nfs.sh pulled on Dec 3. My co-worker's machine is El Capitan. Since configureBoot2Docker() in docker-machine-nfs.sh that auto-generates bootlocal.sh has not changed since I pulled the code (except for a commit to remove trailing spaces), I suspect this is docker-machine issue on El Capitan with virtualbox? I am just guessing.

— Reply to this email directly or view it on GitHub https://github.com/adlogix/docker-machine-nfs/issues/31#issuecomment-168862002 .

jbarbuto commented 8 years ago

This is happening to me as well since upgrading to docker-machine 0.5.5, downgrading back to 0.5.4 fixes it. I'm on OS X 10.11.2 (El Capitan) and VirtualBox 5.0.12.

tonivdv commented 8 years ago

I can't check right now, but if any of you can quickly check what's happening when removing '> /dev/null' at https://github.com/adlogix/docker-machine-nfs/blob/master/docker-machine-nfs.sh#L339 maybe it will shed some light on the issue.

daigotanaka commented 8 years ago

@tonivdv: I updated my Mac to 10.11.2 (El Capitan) and re-installed docker-machine 0.5.5. My VirtualBox is 5.0.12. I could reproduce other people's problem on my machine.

So, I commented out "> /dev/null" as you asked and ran the docker-machine-nfs.sh again and here is the output:

$ docker-machine-nfs test --shared-folder=/Users/daigo/server
[INFO] Configuration:

    - Machine Name: test
    - Shared Folder: /Users/daigo/server 
    - Force: false 

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

    - Machine IP: 192.168.99.100 
    - 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 ...         #!/bin/sh
  sudo umount /Users
    sudo mkdir -p /Users/daigo/server
  sudo /usr/local/etc/init.d/nfs-client start
    sudo mount -t nfs -o noacl,async 192.168.99.1:/Users/daigo/server /Users/daigo/server
OK 
[INFO] Restart Docker Machine ...       OK 
[INFO] Verify NFS mount ...             FAIL

Cannot detect the NFS mount :( 

I also inserted docker-machine ssh test "ls /var/lib/boot2docker/bootlocal.sh" after configureBoot2Docker (Ln #434) and restartDockerMachine (Ln #435). It seems configureBoot2Docker writes out bootlocal.sh fine but the file disappears after the docker-machine restarts:

[INFO] Configure NFS ... 

 !!! Sudo will be necessary for editing /etc/exports !!! 
                        OK 
[INFO] Configure Docker Machine ...         OK 
/var/lib/boot2docker/bootlocal.sh
[INFO] Restart Docker Machine ...       OK 
ls: /var/lib/boot2docker/bootlocal.sh: No such file or directory
exit status 1

(See the 2nd & 4th lines from the bottom)

I hope this helps.

daigotanaka commented 8 years ago

So, just triggering bootlocal.sh without restarting worked for me:

Here is the tweak I made to #435

# restartDockerMachine
docker-machine ssh $prop_machine_name "sudo /var/lib/boot2docker/bootlocal.sh"  
brandontamm commented 8 years ago

@daigotanaka and @tonivdv - i was absolutely ready to pull my hair out because of this issue but the tweak made at line #435 solved my problems. Now this works flawlessly on three different dev machines and I have to say - THANK YOU @daigotanaka!!!

tonivdv commented 8 years ago

@daigotanaka if this solves the issue can you make a PR?

josephwinston commented 8 years ago

Thank you @daigotanaka. Just to be explicit with your comment for others, here is the diff:

diff -c /usr/local/bin/docker-machine-nfs~ /usr/local/bin/docker-machine-nfs
*** /usr/local/bin/docker-machine-nfs~  2016-01-08 19:30:28.000000000 -0600
--- /usr/local/bin/docker-machine-nfs   2016-01-08 19:45:14.000000000 -0600
***************
*** 432,438 ****
  configureNFS

  configureBoot2Docker
! restartDockerMachine

  verifyNFSMount

--- 432,439 ----
  configureNFS

  configureBoot2Docker
! # restartDockerMachine
! docker-machine ssh $prop_machine_name "sudo /var/lib/boot2docker/bootlocal.sh"

  verifyNFSMount
paolomainardi commented 8 years ago

I confirm the problem, the file is empty with docker-machine 0.5.5

@josephwinston the problem is that restarting the vm the bootlocal.sh file disappear.

paolomainardi commented 8 years ago

Guys, can you try this fix https://github.com/adlogix/docker-machine-nfs/pull/35 ?

josephwinston commented 8 years ago

35 fails

$ docker-machine --version
docker-machine version 0.5.5, build
$ docker --version
Docker version 1.9.1, build d12ea79c9de6d144ce6bc7ccfe41c507cca6fd35
docker-machine-nfs default
[INFO] Configuration:

    - Machine Name: default
    - Shared Folder: /Users
    - Force: false

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

    - Machine IP: 192.168.99.100
    - 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 :(```
tonivdv commented 8 years ago

Hello Guys,

Today I got some time to try to figure this all out ...

Imho the fix of @daigotanaka and the PR #35 are no real fixes :(

However I did came to the conclusion that after it wrote the file bootlocal.sh and doing the restart machine immediately it seems the system was not able or not the time enough to persist it really. But if you add a long enough sleep command it will work! I honestly don't get it, and could be related to a docker-machine bug (will raise an issue to see what they say about that)

In the meantime , in order to double (or more) confirm this, could some of you test this too. Here the simple diff:

diff --git a/docker-machine-nfs.sh b/docker-machine-nfs.sh
index 220f68e..bb2b4f3 100755
--- a/docker-machine-nfs.sh
+++ b/docker-machine-nfs.sh
@@ -338,6 +338,8 @@ configureBoot2Docker()
   docker-machine ssh $prop_machine_name \
     "echo '$bootlocalsh' | sudo tee $file && sudo chmod +x $file" > /dev/null

+  sleep 20
+
   echoSuccess "OK"
 }

Cheers

daigotanaka commented 8 years ago

@tonivdv and all: Sorry, I was busy last few days before saw what people commented after my last. I understand my trick was not the permanent fix so I don't need to submit PR. (I don't need a credit for anything, so feel free to do whatever right to fix this issue without crediting me.) I hope my diagnosis helped somehow.

Cheers.

tonivdv commented 8 years ago

@daigotanaka Your help was and is highly appreciated! Thanks again ;)

paolomainardi commented 8 years ago

John can you try my patch ? Il 16/gen/2016 22:33, "John Barbuto" notifications@github.com ha scritto:

On docker-machine 0.5.6, I'm still experiencing the issue with bootlocal.sh not being written, even with the 20 second sleep.

— Reply to this email directly or view it on GitHub https://github.com/adlogix/docker-machine-nfs/issues/31#issuecomment-172259484 .

jbarbuto commented 8 years ago

@paolomainardi: With your patch I'm still experiencing the issue.

tonivdv commented 8 years ago

@jbarbuto Can you increase the sleep time to a ridiculous number to see if it passes?

jbarbuto commented 8 years ago

@tonivdv I increased the sleep to 60 seconds, which fixed the issue for me. This led me to suspect the VM wasn't fully writing the file to disk before restart. Adding the sync call in https://github.com/adlogix/docker-machine-nfs/issues/39 worked every time I tested.

terryzwt commented 5 years ago

I have the same problem.

docker-machine version 0.16.0, build 702c267f docker-machine-nfs: 0.5.1 MAC version: Mac Mojave 10.14.1 (18B75)

tonivdv commented 5 years ago

@terryzwt It's not the same initial issue ... I saw they recently updated boot2docker to v18.09.0 (https://github.com/boot2docker/boot2docker/releases/tag/v18.09.0) and it has now Tiny Core Linux .

Can you confirm?

terryzwt commented 5 years ago

@tonivdv yes. see below.

~/www docker-machine ls
NAME       ACTIVE   DRIVER       STATE     URL                       SWARM   DOCKER     ERRORS
database   -        virtualbox   Running   tcp://10.10.11.101:2376           v18.09.0
default    -        virtualbox   Running   tcp://10.10.11.100:2376           v18.09.0
~/www docker-machine ssh default cat /etc/release
TinyCoreLinux 8.2.1
tonivdv commented 5 years ago

@terryzwt I created a dedicated ticket for it #91 . I will try to install a test image with latest version but it crashes with my current setup (previous toolbox version). I hope it resolves itself when installing latest version, otherwise it will be hard to fix the issue :/

tonivdv commented 5 years ago

@terryzwt I forgot to mention that you can specific a previous boot2docker version (v18.06.1-ce) with the --virtualbox-boot2docker-url https://github.com/boot2docker/boot2docker/releases/download/v18.06.1-ce/boot2docker.iso command

Hope this gets you up and running until the bug is fixed.

terryzwt commented 5 years ago

@tonivdv Thanks for your hint. I try create a docker machine named m1 with v18.06.1-ce iso, then exec "docker-machine-nfs m1", it works this time!.

terryzwt commented 5 years ago

FYI:

~/www docker-machine ssh m1 lsb_release
Boot2Docker 18.06.1-ce (TCL 8.2.1); HEAD : c7e5c3e - Wed Aug 22 16:27:42 UTC 2018