Docker Community Forums

Share and learn in the Docker community.

Docker mount cifs / samba volume

I am experimenting with mounting a network storage volume . I have a remote Samba share that works when I mount it on my computer. I am trying to use it in docker and potentially in Swarm.

Right now I am unable to use Cifs to mount the volume correctly. I first define the volume

$ docker volume create \

 --driver local \
 --opt type=cifs \
 --opt device=//uxxxxx.your-server.de/backup \
 --opt o=username=uxxxxxxx,password=***********,file_mode=0777,dir_mode=0777 \
 --name testRemoteVolume

testRemoteVolume

As you can see this returns the name of the volume and when inspecting it looks fine (to me)

$ docker volume inspect testRemoteVolume
[
{
“CreatedAt”: “2021-02-09T16:51:01Z”,
“Driver”: “local”,
“Labels”: {},
“Mountpoint”: “/var/lib/docker/volumes/testRemoteVolume/_data”,
“Name”: “testRemoteVolume”,
“Options”: {
“device”: “//uxxxxxxx.your-server.de/backup”,
“o”: “username=uxxxxxx,password=**********,file_mode=0777,dir_mode=0777”,
“type”: “cifs”
},
“Scope”: “local”
}
]

But when i try to use it in a container i get this error

docker run -d \

–name cifVolTest
–mount source=testRemoteVolume,target=/remoteVolume
nginx:latest bash
72bd336d11fa21d6395317d583a6dbbf53f4764805f372bd6889161608aa9a56
docker: Error response from daemon: error while mounting volume ‘/var/lib/docker/volumes/testRemoteVolume/_data’: failed to mount local volume: mount //uxxxxxxxxx.your-server.de/backup:/var/lib/docker/volumes/testRemoteVolume/_data, data: username=uxxxxxxxxxxx,password=**********,file_mode=0777,dir_mode=0777: invalid argument.

I find it interesting that I get this error now once the volume is created. I would assume docker had some failsafe/checks when the volumes are created so that then volumes can be then mounted safely later.

Do you have any suggestions on how I can mount such a volume correcly?

The volume works if I use the server ip instead of the domain but this is not a great and stable solution. Any suggestion?

If anyone wonders how a cifs volume is mounted by using hostnames check my documentation PR, hopefully this has been merged into official docs