浏览代码

Merge pull request #180 from thaJeztah/18.09_backport_fix_net_host_systemd_resolved

[18.09 backport] Fix: network=host using wrong resolv.conf with systemd-resolved
Andrew Hsu 6 年之前
父节点
当前提交
80e10316cd
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      daemon/container_operations_unix.go

+ 3 - 3
daemon/container_operations_unix.go

@@ -375,11 +375,11 @@ func (daemon *Daemon) setupPathsAndSandboxOptions(container *container.Container
 	if container.HostConfig.NetworkMode.IsHost() {
 		// Point to the host files, so that will be copied into the container running in host mode
 		*sboxOptions = append(*sboxOptions, libnetwork.OptionOriginHostsPath("/etc/hosts"))
-		*sboxOptions = append(*sboxOptions, libnetwork.OptionOriginResolvConfPath("/etc/resolv.conf"))
-	} else {
-		*sboxOptions = append(*sboxOptions, libnetwork.OptionOriginResolvConfPath(daemon.configStore.GetResolvConf()))
 	}
 
+	// Copy the host's resolv.conf for the container (/etc/resolv.conf or /run/systemd/resolve/resolv.conf)
+	*sboxOptions = append(*sboxOptions, libnetwork.OptionOriginResolvConfPath(daemon.configStore.GetResolvConf()))
+
 	container.HostsPath, err = container.GetRootResourcePath("hosts")
 	if err != nil {
 		return err