docker-volume-netshare icon indicating copy to clipboard operation
docker-volume-netshare copied to clipboard

Is the directory on the remote NFS created?

Open ChristianKniep opened this issue 8 years ago • 9 comments

Hey there,

I might just be a bit confused, but it seems to me that the plugin assumes that the remote directory on the NFS server has to be created before hand, am I right?

$ /usr/local/bin/docker-1.11.2 volume create --name 127.0.0.1:/srv/nfs/test/ --driver=nfs
127.0.0.1:/srv/nfs/test/

Daemon output:

time="2016-07-15T10:44:32Z" level=debug msg="Entering Get: {127.0.0.1:/srv/nfs/test/ map[]}"
time="2016-07-15T10:44:32Z" level=debug msg="Entering Create: name: 127.0.0.1:/srv/nfs/test/, options map[]"
time="2016-07-15T10:44:32Z" level=debug msg="Create volume -> name: 127.0.0.1:/srv/nfs/test/, map[]"
time="2016-07-15T10:44:32Z" level=debug msg="Host path for 127.0.0.1:/srv/nfs/test/ is at /mnt/nfs/127.0.0.1:/srv/nfs/test"

When I mount it:

$ docker-1.11.2 run -ti --rm --volume-driver=nfs -v 127.0.0.1/srv/nfs/test/:/test/ ubuntu bash
docker-1.11.2: Error response from daemon: VolumeDriver.Mount: exit status 32.

Output:

time="2016-07-15T10:46:19Z" level=debug msg="Entering Get: {127.0.0.1/srv/nfs/test/ map[]}"
time="2016-07-15T10:46:19Z" level=debug msg="Entering Create: name: 127.0.0.1/srv/nfs/test/, options map[]"
time="2016-07-15T10:46:19Z" level=debug msg="Create volume -> name: 127.0.0.1/srv/nfs/test/, map[]"
time="2016-07-15T10:46:19Z" level=debug msg="Host path for 127.0.0.1/srv/nfs/test/ is at /mnt/nfs/127.0.0.1/srv/nfs/test"
time="2016-07-15T10:46:19Z" level=debug msg="Entering Mount: {127.0.0.1/srv/nfs/test/ map[]}"
time="2016-07-15T10:46:19Z" level=info msg="Mounting NFS volume 127.0.0.1:/srv/nfs/test/ on /mnt/nfs/127.0.0.1/srv/nfs/test"
time="2016-07-15T10:46:19Z" level=debug msg="Mounting with NFSv4 - src: 127.0.0.1:/srv/nfs/test/, dest: /mnt/nfs/127.0.0.1/srv/nfs/test"
time="2016-07-15T10:46:19Z" level=debug msg="exec: mount -v -t nfs4 127.0.0.1:/srv/nfs/test/ /mnt/nfs/127.0.0.1/srv/nfs/test\n"
2016/07/15 10:46:20 mount.nfs4: mount(2): No such file or directory
mount.nfs4: trying 127.0.0.1 prog 100003 vers 3 prot TCP port 2049
mount.nfs4: trying 127.0.0.1 prog 100005 vers 3 prot UDP port 42499
mount.nfs4: mount(2): No such file or directory
mount.nfs4: mounting 127.0.0.1:/srv/nfs/test/ failed, reason given by server: No such file or directory
mount.nfs4: timeout set for Fri Jul 15 10:48:19 2016
mount.nfs4: trying text-based options 'vers=4.2,addr=127.0.0.1,clientaddr=127.0.0.1'
mount.nfs4: trying text-based options 'addr=127.0.0.1'
mount.nfs4: prog 100003, trying vers=3, prot=6
mount.nfs4: prog 100005, trying vers=3, prot=17

time="2016-07-15T10:46:20Z" level=debug msg="Entering Unmount: {127.0.0.1/srv/nfs/test/ map[]}"
time="2016-07-15T10:46:20Z" level=info msg="Unmounting volume name 127.0.0.1/srv/nfs/test/ from /mnt/nfs/127.0.0.1/srv/nfs/test"
2016/07/15 10:46:20 umount: /mnt/nfs/127.0.0.1/srv/nfs/test: not mounted

But when I create it myself mkdir /srv/nfs/test, it works:

time="2016-07-15T10:47:13Z" level=debug msg="Host path for 127.0.0.1/srv/nfs/test/ is at /mnt/nfs/127.0.0.1/srv/nfs/test"
time="2016-07-15T10:47:14Z" level=debug msg="Entering Mount: {127.0.0.1/srv/nfs/test/ map[]}"
time="2016-07-15T10:47:14Z" level=info msg="Mounting NFS volume 127.0.0.1:/srv/nfs/test/ on /mnt/nfs/127.0.0.1/srv/nfs/test"
time="2016-07-15T10:47:14Z" level=debug msg="Mounting with NFSv4 - src: 127.0.0.1:/srv/nfs/test/, dest: /mnt/nfs/127.0.0.1/srv/nfs/test"
time="2016-07-15T10:47:14Z" level=debug msg="exec: mount -v -t nfs4 127.0.0.1:/srv/nfs/test/ /mnt/nfs/127.0.0.1/srv/nfs/test\n"

ChristianKniep avatar Jul 15 '16 10:07 ChristianKniep

This is true but has nothing todo with the plugin. Since docker-volume-netshare uses a mount command internally it is bound by the capabilities of mount.

Convince yourself with mount -t nfs host:/some/non/existing/dir /somewhere ;-)

holgerreif avatar Jul 15 '16 13:07 holgerreif

I was just about to open a ticket for this. Given this command

docker volume create -d nfs --name myvol -o share=nfshost:/share

I expected the plugin to mount nfshost:/share, and then create the directory 'myvol' on the mount if it doesn't already exist

given the way it works now, I'll have to manually create directories for every volume I want to put on the share. That works, but in the long run makes it less friendly..

bkcsfi avatar Jul 15 '16 13:07 bkcsfi

Hmmm.... Actually the --name myvol is just a logical entity (a name) that should not have any relationship to a physical directory...

What I could imagine is the following

docker volume create -d nfs --name myvol -o share=nfshost:/share/myvol -o create=yes

With option create=yes docker-volume-netshare would do the following:

  1. check the exports of the host
  2. mount the export that is closest to the desired volume (e.g. nfshost:/share)
  3. create if the dir if it does not exist
  4. umount the share
  5. proceed as before and mount nfshost:/share/myvol

@bkcsfi Would this help to you?

holgerreif avatar Jul 15 '16 14:07 holgerreif

Yes, this would be helpful. Can the create=yes option also be specified in the volume section of a swarm file? That's ultimately how I would be using it.

Thanks

bkcsfi avatar Jul 15 '16 14:07 bkcsfi

Hi,

I think that it would be even more helpful if the share was considered as a volumes set, and the named volume would be created in it, something like :

docker volume create -d nfs --name myvol -o share=nfshost:/share -o create=yes

And considering the path is a myvol (based on the volume name) folder in nfshost:/share.

Because without it, I find it confusing, in fact I don't really see what's the advantage of using the netshare volume plugin against having the NFS shares mounted on all docker hosts and using bind volumes (if you have to explicitly create the folders, and explicitly ask for the specific share, that's not much work).

But I might be missing some point.

Regards,

eesprit avatar Aug 31 '16 10:08 eesprit

I think that it would be even more helpful if the share was considered as a volumes set, and the named volume would be created in it, something like :

docker volume create -d nfs --name myvol -o share=nfshost:/share -o create=yes

I agree on that. My expectation was also, that the driver would create a Directory for each volume (by Name) within my NFS share. The current situation, that i would need to define one nfs export per named volume, is quite cumbersome.

ender74 avatar Sep 07 '16 14:09 ender74

I like this idea a lot. Lets see if we get a few more votes and this can be the change of direction. I will start prototyping this in the meantime and making sure it works with clusters like Mesos as well.

Could someone create a new issue stating what this enhancement should do and I will flag it for voting

gondor avatar Sep 07 '16 15:09 gondor

I did create a new issue https://github.com/ContainX/docker-volume-netshare/issues/72 to desribe the proposed change.

ender74 avatar Sep 07 '16 18:09 ender74

Error

Error response from daemon: create myvol: Error looking up volume plugin nfs: legacy plugin: Post http://%2Frun%2Fdocker%2Fplugins%2Fnfs.sock/Plugin.Activate: dial unix /run/docker/plugins/nfs.sock: connect: connection refused

RakeshNagarajan avatar Jul 18 '18 09:07 RakeshNagarajan