The option --add-host and --net=host should not be mutually exclusive.
This fix tries to address the issue raised in #21976 and allows the options of `--add-host` and `--net=host` to work at the same time. The documentation has been updated and additional tests have been added to cover this change. This fix fixes #21976. Signed-off-by: Yong Tang <yong.tang.github@outlook.com> Upstream-commit: 90bd41a74d57080711678bffa2bc4371020ee3a5 Component: engine
This commit is contained in:
@ -47,7 +47,9 @@ func (daemon *Daemon) buildSandboxOptions(container *container.Container, n libn
|
||||
|
||||
if container.HostConfig.NetworkMode.IsHost() {
|
||||
sboxOptions = append(sboxOptions, libnetwork.OptionUseDefaultSandbox())
|
||||
sboxOptions = append(sboxOptions, libnetwork.OptionOriginHostsPath("/etc/hosts"))
|
||||
if len(container.HostConfig.ExtraHosts) == 0 {
|
||||
sboxOptions = append(sboxOptions, libnetwork.OptionOriginHostsPath("/etc/hosts"))
|
||||
}
|
||||
if len(container.HostConfig.DNS) == 0 && len(daemon.configStore.DNS) == 0 &&
|
||||
len(container.HostConfig.DNSSearch) == 0 && len(daemon.configStore.DNSSearch) == 0 &&
|
||||
len(container.HostConfig.DNSOptions) == 0 && len(daemon.configStore.DNSOptions) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user