I have a Windows 10 share for a particular user. Then I have Debian:stretch in a docker container. I try to mount a shared folder like this:

root@b9cda19f784c:~# mount -t cifs -v -o username=dockerfile,password=docker,sec=ntlm // /root/somedir
mount: permission denied

I tried to remove sec=ntlm option, set uid and gid in options but didn't succeed. Also I don't see any verbose messages that I'm expecting of -v flag.

From my Windows 10 host I can mount this folder using a command:

net use p: \\\hlds /user:dockeruser

How can I make mount command output more information to debug? Or what am I missing in my mount command?


Running a container with --privileged flag doesn't help:

root@62d77b4c1058:/# mount -v -t cifs -o username=dockerfile,password=docker // /root/mnt 
mount.cifs kernel mount options: ip=,unc=\\\hlds,user=dockerfile,pass=******** 
mount error(13): Permission denied 
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

And creating a volume using Docker and mounting it didn't succeed:

PS F:\repos\hlds-docker> docker volume create --opt type=cifs --opt device=// --opt o=username=dockerfile,password=docker,file_mode=0777,dir_mode=0777,uid=0,gid=0 myvolume
PS F:\repos\hlds-docker> docker run --rm -v myvolume:/root -it --privileged debian:stretch bash
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: error while mounting volume with options: type='cifs' device='//' o='username=dockerfile,password=docker,file_mode=0777,dir_mode=0777,uid=0,gid=0': permission denied.
See 'C:\Program Files\Docker\Docker\Resources\bin\docker.exe run --help'.

My Docker Version:

PS F:\repos\hlds-docker> docker version
Client: Docker Engine - Community
 Version:           18.09.1
 API version:       1.39
 Go version:        go1.10.6
 Git commit:        4c52b90
 Built:             Wed Jan  9 19:34:26 2019
 OS/Arch:           windows/amd64
 Experimental:      false

Server: Docker Engine - Community
  Version:          18.09.1
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.6
  Git commit:       4c52b90
  Built:            Wed Jan  9 19:41:49 2019
  OS/Arch:          linux/amd64
  Experimental:     false

So after some trials and tributations I found a solution (but I think it's weird). You need to do 2 steps:

  1. Put some dummy file in your dir so it's not empty (either way you get permission denied error)
  2. Create docker volume with noserverino option (found accidentally)

So in my case it's:

docker volume create --opt type=cifs --opt device=// --opt o=username=dockeruser,password=docker,noserverino,file_mode=0777,dir_mode=0777,uid=1000,gid=1000 somevol

And then:

docker run --rm -v somevol:/home/steam/opts -it krow7/hlds:1.0 bash

So you have your dirs owned by an exact user you need and can do all operations with files on a mounted share.

I hope someone will find it useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.