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

I am trying to create docker volumes using the docker-volume-netshare driver from here: https://github.com/ContainX/docker-volume-netshare

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.


Solution 1:

A little bit late ... But here is the solution:

docker volume create \
     --driver local \
     --opt type=cifs \
     --opt device=//server.domain/path/to/share \
     --opt o=addr=server.domain,username=myuser,password=mypw,file_mode=0777,dir_mode=0777 \
     --name myvolume

In some situations the DNS-name did not work, this has been fixed in this PR and now domain names can be used by adding addr in the CIFS options. Using the option "credentials" instead of "username" an "password" did not work for me. I'm getting always the error "No username specified". From the shell (mount -t cifs //server/path -o credentials=/etc/cifs.cred /tmp/mnt) it works fine.