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

nfs mount command doesn't include `--opt` flags from `docker volume create`

Open grisaitis opened this issue 7 years ago • 1 comments

In the "Advanced Options" part of the NFS docs, it says you can pass custom mount options (mount -o <key>=<value>) like so: docker volume create -d nfs --name <name> -o <key>=<value>.

I'm observing that none of these options get passed to mount.

Here's how I start the plugin:

# docker-volume-netshare nfs -v 3 --verbose
INFO[0000] == docker-volume-netshare :: Version: 0.34 - Built: 2017-05-29T13:06:34-07:00 == 
INFO[0000] Starting NFS Version 3 :: options: ''        

(The issue still occurs without -v 3, but my nfs server is nfs v3)

And then:

$ docker volume create -d nfs --name test_docker_nfs_volume -o share=my_nfs_server:/my/path -o o=ro
DEBU[0014] Entering Get: {test_docker_nfs_volume map[]} 
DEBU[0014] Entering Get: {test_docker_nfs_volume map[]} 
DEBU[0014] Entering Create: name: test_docker_nfs_volume, options map[o:ro share:my_nfs_server:/my/path] 
DEBU[0014] Create volume -> name: test_docker_nfs_volume, map[o:ro share:my_nfs_server:/my/path] 
DEBU[0014] Host path for test_docker_nfs_volume (test_docker_nfs_volume) is at /var/lib/docker-volumes/netshare/nfs/test_docker_nfs_volume 
$ docker run --rm -v test_docker_nfs_volume:/mnt/test ubuntu bash -c 'mount | grep "/mnt/test"'
my_nfs_server:/my/path on /mnt/test type nfs (rw,relatime,vers=3,rsize=1048576,wsize=1048576,namlen=255,hard,nolock,proto=tcp,port=2049,timeo=600,retrans=2,sec=sys,mountaddr=x.x.x.x,mountvers=3,mountport=2049,mountproto=tcp,local_lock=all,addr=x.x.x.x)

And here you can see that it's a rw mount. But, I passed -o o=ro to docker volume create. I can see that when mount was called, indeed there was no -o o=ro passed:

DEBU[0036] Entering Get: {test_docker_nfs_volume map[]} 
DEBU[0036] Get: mount found for test_docker_nfs_volume, host directory: /var/lib/docker-volumes/netshare/nfs/test_docker_nfs_volume 
DEBU[0036] Entering Mount: {test_docker_nfs_volume 996376611bcb2c7a2dd6a30ba9e0c146891485d43b64f73042df43be2fc6771c} 
INFO[0036] Mounting NFS volume my_nfs_server:/my/path on /var/lib/docker-volumes/netshare/nfs/test_docker_nfs_volume 
DEBU[0036] Mounting with NFSv3 - src: my_nfs_server:/my/path, dest: /var/lib/docker-volumes/netshare/nfs/test_docker_nfs_volume 
DEBU[0036] exec: mount -v -t nfs -o port=2049,nolock,proto=tcp my_nfs_server:/my/path /var/lib/docker-volumes/netshare/nfs/test_docker_nfs_volume

Am I doing something wrong?

The only way I can get this plugin to include mount flags is if I provide them globally at launch (like in the docs). But, I need more volume-level granularity to control NFS versions, readability, etc.

Indeed, providing a random option like -o foo=baz doesn't show up either:

DEBU[0047] Create volume -> name: test_docker_nfs_volume, map[o:foo=baz share:my_nfs_server:/my/path] 
...
DEBU[0050] exec: mount -v -t nfs -o port=2049,nolock,proto=tcp my_nfs_server:/my/path /var/lib/docker-volumes/netshare/nfs/test_docker_nfs_volume

grisaitis avatar Jun 07 '17 20:06 grisaitis

Had the same problem with cifs, and have to dig into the code. Look in https://github.com/ContainX/docker-volume-netshare/blob/master/netshare/drivers/nfs.go and you may find something. may need to set nfsopts=, instead of classical "-o"

RemyCH avatar Jun 15 '17 12:06 RemyCH