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

How to create CIFS docker volume with username, password, uid, and gid? #77

Open MikkelBC opened 8 years ago

MikkelBC commented 8 years ago

I am trying to create CIFS docker volumes using docker-volume-netshare. I am having trouble finding the right syntax to pass options to mount and I suspect that there might be a bug in the option passing.

The sequence should be like this:

docker volume create -d cifs <some_options>
docker run -v <the_volume> <other_docker_options>

and I can get it to work part of the way but for the life of me I can't get it to pass all the options I need.

Instead of trying to recount my countless different failure modes, I would prefer to state my goal. Underneath, docker-volume-netshare will execute a mount -t cifs ... command. This can be seen in the log when verbose is set to true.

This is the mount command that I am trying to get. I can get username and password in there, but only when using a .netrc file, and I have found no way to get the uid and gid into the command.

mount -t cifs -o username=myusername,password=mypasswd,uid=500,gid=499,rw //myserver.example.net/mysharename /the_mount_point/

So what I am looking for is the authoritative syntax for passing these options through docker-volume-netshare.

BarnumD commented 7 years ago

I had to run this: docker-volume-netshare cifs --username myusername --password "mypasswd" --domain DOMAIN --security ntlm Then I used this to test: (phusion baseimage is just an example of an image you could run.) docker run -it --volume-driver=cifs -v servername/sharename:/mount phusion/baseimage /bin/bash

I had to use security ntlm for it to work with my server.

MikkelBC commented 7 years ago

Hi BarnumD, Thank you for your reply! Have you also successfully used uid and gid options? This is the part I am having the most difficulty with.

BarnumD commented 7 years ago

I have not tried that, sorry.

MikkelBC commented 7 years ago

Thanks anyway for quick feedback!

BarnumD commented 7 years ago

Looking at the code in cifs.go it seems like you should be able to pass cifsopts

MikkelBC commented 7 years ago

That's what I thought too at one point, but I think cifsopts are treated differently than the other options. I am not that seasoned in go, so I admit having some difficulty following the flow. When I find some time, I will set up an environment that lets me step through it in the debugger.

mfowlewebs commented 7 years ago

There's a Serverfault question asking the same. I too would like to know. And details in general about how to use cifsopts would be great, as we have some other extra stuff in there.

MikkelBC commented 7 years ago

@mfowlewebs , that is my question on Serverfault. I asked it there first but got reprimanded by one of the moderators (Michael Hampton) for asking the question there before asking the developers here.

andree-bjorkgard commented 7 years ago

According to docker-volume-netshare cifs --help you can just pass options using -o just as you would with mount.
ex: -o uid=1000,gid=1000