ContainX / docker-volume-netshare

Docker NFS, AWS EFS, Ceph & Samba/CIFS Volume Plugin
http://netshare.containx.io
Apache License 2.0
1.11k stars 164 forks source link

cifsopts not recovered on daemon restart #188

Open fgodfrey opened 4 years ago

fgodfrey commented 4 years ago

I am attempting to create a CIFS volume on a Linux host and I want the user ID mapped to a specific UID number (in this example, 999). This works fine until I restart the docker-volume-netshare daemon. At that point, the options are lost.

The following test shows the issue:

Create/test:

docker volume create -d cifs --opt 'cifsopts=uid=999' --name server.example.com/test-vol
docker run -it --rm -v server.example.com/test-vol:/test busybox:latest sh

We see this from the docker-volume-netshare verbose log, which is correct:

mount -t cifs -o uid=999,username='my-user',password='****',rw //server.example.com/test-vol /var/lib/docker-volumes/netshare/cifs/server.example.com/test-vol 

Now, exit the container, restart docker-volume-netshare, and rerun the "docker run" command. Now from the docker-volume-netshare verbose log, we see this, which omits the "uid=999" option:

mount -t cifs -o username='my-user',password='****',rw //server.example.com/test-vol /var/lib/docker-volumes/netshare/cifs/server.example.com/test-vol 

I am not sure if the Docker daemon stores the options or if we would need to introduce a cache in docker-volume-netshare. I am not very proficient with Go so I'm not sure I'll be able to put together a PR to do the latter, but I'll try (or if someone else gets there first, I won't complain :) )

fgodfrey commented 4 years ago

The docker volume inspect command returns the options. So, I believe the fix is to "inspect" each volume as we discover it in the recovery function and add the options there. I am working on a PR that will do this.

fgodfrey commented 4 years ago

I put together a PR (https://github.com/ContainX/docker-volume-netshare/pull/189) that appears to pass CI.