Enable DNS Lookups for CIFS Volumes#39250
Conversation
This comes from an old suggestion (docker/cli#706 (comment)) on an issue we were having and has since popped up again. For NFS volumes, Docker will do an IP lookup on the volume name. This is not done for CIFS volumes, which forces you to add the volume via IP address instead. This change will enable the IP lookup also for CIFS volumes. Signed-off-by: Shu-Wai Chow <shu-wai.chow@seattlechildrens.org>
Codecov Report
@@ Coverage Diff @@
## master #39250 +/- ##
=========================================
Coverage ? 37.06%
=========================================
Files ? 612
Lines ? 45488
Branches ? 0
=========================================
Hits ? 16861
Misses ? 26340
Partials ? 2287 |
|
Did this get tested? Does the cifs module really use the same weird |
|
Re: For Testing: The Docker documentation will have to be updated since there is no current section on CIFS. We're able to create and mount CIFS volumes using the same syntax as NFS. docker volume create From the Docker documentation on NFS (https://docs.docker.com/engine/reference/commandline/volume_create/): docker volume create --driver local The "addr:" syntax is part of compose. |
|
Hm, not sure that would work with the current code though; if ipAddr, err := net.ResolveIPAddr("ip", addrValue) |
|
Sorry, copied/pasted an older command (which also works). The same exact syntax as nfs also works for cifs with the path broken out: docker volume create The getAddress function in local.go is just looking for "addr=" for the volume_name, so that should be fine. I'm trying to dive into how CIFS is parsing out the device option for the path and resolving the ":", but it's definitely working on my end. |
|
Hi guys-- What's the status on this? I'm running into this problem and hoping these changes get merged in. |
Hey Drew. I was going to ask the main contributors what more I can do for testing this. I don't have access to another CIFS environment to verify that the same mounting syntax for NFS works, nor have I had the chance to deep dive into the volume creation to see how it handles CIFS. I'd be happy to add more to the PR if necessary. |
|
ping @cpuguy83 ptal |
kolyshkin
left a comment
There was a problem hiding this comment.
LGTM
it would be nice to update the docs to show the newly available syntax.
thaJeztah
left a comment
There was a problem hiding this comment.
still LGTM
let's merge 👍 thanks for being so patient!!
|
@shuchow for the documentation; perhaps a block similar to the NFS example on this page; https://docs.docker.com/storage/volumes/#create-a-service-which-creates-an-nfs-volume (source file for that is in this repository: https://github.com/docker/docker.github.io/blob/master/storage/volumes.md) And the reference section for (source file for that is in the docker/cli repository: https://github.com/docker/cli/blob/master/docs/reference/commandline/volume_create.md#driver-specific-options) |
|
@thaJeztah Great, thanks for the links. I'll send a PR for the documentation in a bit. |
|
Note that these options are passed directly to the kernel module for this fs type. Are we sure this actually works? for this command: mount.cifs -o user=foo,password=bar \\\\1.2.3.4\\foo /tmpSo, based purely on what I'm seeing in the ubuntu mount.cifs we need to be looking at a totally different option for cifs (as compared to nfs). |
|
There's also a eg. $ sudo ./mount.cifs //fileserver/backup/rolling /backup -o 'user=foo,pass=bar'
mount(//fileserver/backup/rolling, ".", cifs, (null), ip=192.168.86.50,unc=\\fileserver\backup,user=foo,prefixpath=rolling,pass=bar) |
|
when I tried this on Docker 20.10.2, for this syntax I get an error during creation of volume: For the other syntax: Creation was okay but when I actually mount it I got a different error: From the code changes I can see it is simply replacing addr=hostname to addr=ip, however the errors seemed to suggest addr was never a valid argument to mount.cifs. Could you clarify @shuchow? |
|
@spinosae This still works for me in docker docker volume create
--driver local
--opt type=cifs
--opt device=//core/backup
--opt "o=uid=1000,gid=1000,ip=172.16.20.110,unc=\\core\backup,file_mode=0664,dir_mode=0775,iocharset=utf8,cache=none,mapchars,mfsymlinks,user=bkupusr,pass=${CIFS_PASSWD}"
sync-backupMost of the extra options can be dropped, but thats a copy of a live volume create from a daily script. |
|
@spinosae I misread your comment, all this PR does is rewrite the so this will work: docker volume create \
--driver local \
--opt type=cifs \
--opt device=//myserver/backup \
--opt "o=addr=myserver.localdomain.com,user=bkupusr,pass=${CIFS_PASSWD}" \
sync-backupit will find the So your second example should have worked if the device was a valid path to a CIFS mount eg. |
wow, just like that, MAGIC! so the difference is device option, instead of |
|
@spinosae Did you finally manage to connect via domain name? |
|
Hi, Was this resolved? I'm hitting the CIFS + DNS problem with a couple of containers. I tried adding the 'addr=' option as above, but I get 'invalid argument' when the container tries to start. Have the options changed, or does a FQDN for a CIFS share not work? |
|
@jefft4 could you open a ticket with details? Note that these options are not handled by the docker daemon itself, but passed as options when doing a mount syscall, so options (including the |
Sure, will do. |
|
Does not fix the problem: #46180 (comment) |
fixes docker/cli#706
This comes from an old suggestion (docker/cli#706 (comment)) on an issue we were having and has since popped up again. For NFS volumes, Docker will do an IP lookup on the volume name. This is not done for CIFS volumes, which forces you to add the volume via IP address instead. This change will enable the IP lookup also for CIFS volumes.
Signed-off-by: Shu-Wai Chow shu-wai.chow@seattlechildrens.org
- What I did
Add an IP address lookup for CIFS network volumes.
- How I did it
Change the special case triggered by an if statement to a switch cause triggered by both nfs and cifs volumes. This should enable future cases if necessary.
- How to verify it
Add a CIFS volume using a name instead of an IP Address.
- Description for the changelog
Enable DNS Lookups for CIFS Volumes
- A picture of a cute animal (not mandatory but encouraged)