summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-02-24 09:24:20 -0500
committerGitHub <noreply@github.com>2021-02-24 09:24:20 -0500
commit4846f877b83ea55b1d70155fd668c79a4a0f88f4 (patch)
treefb52b6435e12e46f2d7a087dd3273d1f62b1084d /libpod
parent49fa19dff6717e419ebbaba029e84cbc5bd97904 (diff)
parent90050671b71cd4629b27809055bd562ab76c4460 (diff)
downloadpodman-4846f877b83ea55b1d70155fd668c79a4a0f88f4.tar.gz
podman-4846f877b83ea55b1d70155fd668c79a4a0f88f4.tar.bz2
podman-4846f877b83ea55b1d70155fd668c79a4a0f88f4.zip
Merge pull request #9501 from Luap99/dns-search-cni
Add dns search domains from cni response to resolv.conf
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal_linux.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 9c3e91a97..dc0418148 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -1713,8 +1713,9 @@ rootless=%d
// generateResolvConf generates a containers resolv.conf
func (c *Container) generateResolvConf() (string, error) {
var (
- nameservers []string
- cniNameServers []string
+ nameservers []string
+ cniNameServers []string
+ cniSearchDomains []string
)
resolvConf := "/etc/resolv.conf"
@@ -1766,6 +1767,10 @@ func (c *Container) generateResolvConf() (string, error) {
cniNameServers = append(cniNameServers, i.DNS.Nameservers...)
logrus.Debugf("adding nameserver(s) from cni response of '%q'", i.DNS.Nameservers)
}
+ if i.DNS.Search != nil {
+ cniSearchDomains = append(cniSearchDomains, i.DNS.Search...)
+ logrus.Debugf("adding search domain(s) from cni response of '%q'", i.DNS.Search)
+ }
}
dns := make([]net.IP, 0, len(c.runtime.config.Containers.DNSServers))
@@ -1797,10 +1802,11 @@ func (c *Container) generateResolvConf() (string, error) {
}
var search []string
- if len(c.config.DNSSearch) > 0 || len(c.runtime.config.Containers.DNSSearches) > 0 {
+ if len(c.config.DNSSearch) > 0 || len(c.runtime.config.Containers.DNSSearches) > 0 || len(cniSearchDomains) > 0 {
if !util.StringInSlice(".", c.config.DNSSearch) {
search = c.runtime.config.Containers.DNSSearches
search = append(search, c.config.DNSSearch...)
+ search = append(search, cniSearchDomains...)
}
} else {
search = resolvconf.GetSearchDomains(resolv.Content)