mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
volume/local: Make host resolution backwards compatible
Commit 8ae94cafa5 added a DNS resolution
of the `device` part of the volume option.
The previous way to resolve the passed hostname was to use `addr`
option, which was handled by the same code path as the `nfs` mount type.
The issue is that `addr` is also an SMB module option handled by kernel
and passing a hostname as `addr` produces an invalid argument error.
To fix that, restore the old behavior to handle `addr` the same way as
before, and only perform the new DNS resolution of `device` if there is
no `addr` passed.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -127,16 +127,20 @@ func (v *localVolume) mount() error {
|
||||
mountDevice := v.opts.MountDevice
|
||||
|
||||
switch v.opts.MountType {
|
||||
case "nfs":
|
||||
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 network volume address")
|
||||
return errors.Wrap(err, "error resolving passed in network volume address")
|
||||
}
|
||||
mountOpts = strings.Replace(mountOpts, "addr="+addrValue, "addr="+ipAddr.String(), 1)
|
||||
}
|
||||
case "cifs":
|
||||
deviceURL, err := url.Parse(v.opts.MountDevice)
|
||||
|
||||
if v.opts.MountType != "cifs" {
|
||||
break
|
||||
}
|
||||
|
||||
deviceURL, err := url.Parse(mountDevice)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "error parsing mount device url")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user