aboutsummaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorColin Walters <walters@verbum.org>2018-11-21 09:30:03 -0500
committerColin Walters <walters@verbum.org>2018-11-27 15:28:09 -0500
commit870eed9378c025f3684aa8baf3db6de969da3c5d (patch)
tree26bb1dcc44a8519973ab119e34985a91efc52542 /libpod
parent6df7409cb5a41c710164c42ed35e33b28f3f7214 (diff)
downloadpodman-870eed9378c025f3684aa8baf3db6de969da3c5d.tar.gz
podman-870eed9378c025f3684aa8baf3db6de969da3c5d.tar.bz2
podman-870eed9378c025f3684aa8baf3db6de969da3c5d.zip
Use host's resolv.conf if no network namespace enabled
My host system runs Fedora Silverblue 29 and I have NetworkManager's `dns=dnsmasq` setting enabled, so my `/etc/resolv.conf` only has `127.0.0.1`. I also run my development podman containers with `--net=host` for various reasons. If we have a host network namespace, there's no reason not to just use the host's nameserver configuration either. This fixes e.g. accessing content on a VPN, and is also faster since the container is using cached DNS. I know this doesn't solve the bigger picture issue of localhost-DNS conflicting with bridged networking, but that's far more involved, probably requiring a DNS proxy in the container. This patch makes my workflow a lot nicer and was easy to write. Signed-off-by: Colin Walters <walters@verbum.org>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal_linux.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index ffb82cc94..677645e7d 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -729,9 +729,10 @@ func (c *Container) generateResolvConf() (string, error) {
return "", errors.Wrapf(err, "unable to read %s", resolvPath)
}
- // Process the file to remove localhost nameservers
+ // Ensure that the container's /etc/resolv.conf is compatible with its
+ // network configuration.
// TODO: set ipv6 enable bool more sanely
- resolv, err := resolvconf.FilterResolvDNS(contents, true)
+ resolv, err := resolvconf.FilterResolvDNS(contents, true, c.config.CreateNetNS)
if err != nil {
return "", errors.Wrapf(err, "error parsing host resolv.conf")
}