Skip to content

Commit

Permalink
Enable DNS Lookups for CIFS Volumes
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
shuatseattlechildrens committed May 21, 2019
1 parent 12b837e commit 75a59c6
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions volume/local/local_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ func (v *localVolume) mount() error {
return fmt.Errorf("missing device in volume options")
}
mountOpts := v.opts.MountOpts
if v.opts.MountType == "nfs" {
switch v.opts.MountType {
case "nfs", "cifs":
if addrValue := getAddress(v.opts.MountOpts); addrValue != "" && net.ParseIP(addrValue).To4() == nil {
ipAddr, err := net.ResolveIPAddr("ip", addrValue)
if err != nil {
return errors.Wrapf(err, "error resolving passed in nfs address")
return errors.Wrapf(err, "error resolving passed in network volume address")
}
mountOpts = strings.Replace(mountOpts, "addr="+addrValue, "addr="+ipAddr.String(), 1)
}
Expand Down

0 comments on commit 75a59c6

Please sign in to comment.