This comes from an old suggestion https://github.com/moby/moby/pull/39250 on an issue. I am trying to mount a CIFS volume, config it via IP worked for me but when I try to config it using a hostname it doesn't work.
CIFS=XX.XX.XX.XX
api:
image: name-api:$TAG
environment:
- NODE_ENV=docker
ports:
- "3000:3000"
container_name: cc-api
volumes:
- cifs:/usr/node/cifs
volumes:
cifs:
driver: local
driver_opts:
type: cifs
o: username=$WSDLUSER,password=$WSDLPASS,rw,domain=domain.com,uid=1000,forceuid,gid=1000,forcegid,file_mode=0400,dir_mode=0500
device: "\\\\${CIFS}\\documentation\\_shared\\pdfs”
When I try to change it to CIFSDOMAIN=cifs.domain.com
I get an error during creation of volume invalid argument
. So this should work:
volumes:
cifs:
driver: local
driver_opts:
type: cifs
o: addr=cifs.domain.com,username=$WSDLUSER,password=$WSDLPASS,rw,uid=1000,forceuid,gid=1000,forcegid,file_mode=0400,dir_mode=0500
device: "\\\\${CIFSDOMAIN}\\documentation\\_shared\\pdfs”
It has been tried with with "//${CIFSDOMAIN}/documentation/_shared/pdfs”
too.
Is it likely that the kernel driver does not resolve hostnames? This article says that you need to use the IP address when doing CIFS mounts because docker does not use the same userland tools to do the mount, and will fail if a hostname is provided.
Inspecting the volume shows the mountpoint, looks correct to me
{
"Driver": "local",
"Labels": {
"com.docker.compose.project": "cc",
"com.docker.compose.version": "1.27.4",
"com.docker.compose.volume": "cifs"
},
"Mountpoint": "/var/lib/docker/volumes/cc_cifs/_data",
"Name": "cc_cifs",
"Options": {
"device": "\\\\cifs.domain.com\\documentation\\_shared\\pdfs",
"o": "addr=cifs.domain.com,username=XXXXX,password=YYYYY,rw,uid=1000,forceuid,gid=1000,forcegid,file_mode=0400,dir_mode=0500",
"type": "cifs"
},
"Scope": "local"
}
Also, contents of /etc/hosts is:
XX.XX.XX.XX cifs cifs.domain.com