Create CIFS volume using local driver and credentials file?

Is it possible to create a CIFS volume (using the local driver) by passing it a credentials file instead of specifying the username/password inline?

I am aware that other solutions exist like docker-volume-netshare but I don’t want to rely on 3rd party for this project and the Docker documentation states it supports similar commands as the Linux mount command so I’ve been trying to go down that path.

I have a /root/.cifs file.

username=myusername
password=mypassword 

Then I test it by mounting the share manually.

mount -t cifs \
-o credentials=/root/.cifs,vers=3.0 \
//192.168.76.20/docker_01 /mnt

This works perfectly fine and I can read/write against the share. I then try to create the volume.

docker volume create \
--driver local \
--name persistent \
--opt type=cifs \
--opt device=//192.168.76.20/docker_01 \
--opt o=vers=3.0,credentials=/root/.cifs

I don’t get any errors when I create the volume but if I try to mount it in a container I get: CIFS VFS: No username specified in the Docker log file.

I tried to be clever and modify the options to --opt o=vers=3.0,credentials=/root/.cifs,username=docker01 but that just results in a STATUS_LOGON_FAILURE.

Does Docker support an external credentials file? I can’t find any documentation on it and no practical examples so I’m hoping someone out there has run into this before.

Thanks!!

Docker Version: 18.09.0-CE
API Version: 1.39
O/S: Ubuntu 16.04

I’m having similar issues except I keep getting invalid options. Except the options I’m using work perfectly for mounting the cif share locally.

1 Like

For posterity, a recent Stack Overflow post explains it’s not supported:

It seems the issue here is that the credentials-file is a feature of the wrapper binary “mount.cifs” while docker uses the systemcall SYS_MOUNT itself for mounting the volume

More details at:

What other options are there?
Could a docker secret be used with the docker volume create command?