mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-03 23:38:24 +00:00
configurable dns search domains
Add a --dns-search parameter and a DnsSearch configuration field for specifying dns search domains. Docker-DCO-1.1-Signed-off-by: Daniel Norberg <daniel.norberg@gmail.com> (github: danielnorberg)
This commit is contained in:
committed by
Daniel Norberg
parent
d3c5891486
commit
fbfac21ed4
+14
-3
@@ -493,13 +493,19 @@ func (runtime *Runtime) Create(config *runconfig.Config, name string) (*Containe
|
||||
}
|
||||
|
||||
// If custom dns exists, then create a resolv.conf for the container
|
||||
if len(config.Dns) > 0 || len(runtime.config.Dns) > 0 {
|
||||
var dns []string
|
||||
if len(config.Dns) > 0 || len(runtime.config.Dns) > 0 || len(config.DnsSearch) > 0 || len(runtime.config.DnsSearch) > 0 {
|
||||
dns := utils.GetNameservers(resolvConf)
|
||||
dnsSearch := utils.GetSearchDomains(resolvConf)
|
||||
if len(config.Dns) > 0 {
|
||||
dns = config.Dns
|
||||
} else {
|
||||
} else if len(runtime.config.Dns) > 0 {
|
||||
dns = runtime.config.Dns
|
||||
}
|
||||
if len(config.DnsSearch) > 0 {
|
||||
dnsSearch = config.DnsSearch
|
||||
} else if len(runtime.config.DnsSearch) > 0 {
|
||||
dnsSearch = runtime.config.DnsSearch
|
||||
}
|
||||
container.ResolvConfPath = path.Join(container.root, "resolv.conf")
|
||||
f, err := os.Create(container.ResolvConfPath)
|
||||
if err != nil {
|
||||
@@ -511,6 +517,11 @@ func (runtime *Runtime) Create(config *runconfig.Config, name string) (*Containe
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
if len(dnsSearch) > 0 {
|
||||
if _, err := f.Write([]byte("search " + strings.Join(dnsSearch, " ") + "\n")); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
container.ResolvConfPath = "/etc/resolv.conf"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user