Added support for dns-search and fixes #30102
Signed-off-by: msabansal <sabansal@microsoft.com>
This commit is contained in:
parent
27695cd751
commit
e6962481a0
5 changed files with 35 additions and 9 deletions
|
@ -32,12 +32,22 @@ var (
|
|||
getPortMapInfo = container.GetSandboxPortMapInfo
|
||||
)
|
||||
|
||||
func (daemon *Daemon) getDNSSearchSettings(container *container.Container) []string {
|
||||
if len(container.HostConfig.DNSSearch) > 0 {
|
||||
return container.HostConfig.DNSSearch
|
||||
}
|
||||
|
||||
if len(daemon.configStore.DNSSearch) > 0 {
|
||||
return daemon.configStore.DNSSearch
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
func (daemon *Daemon) buildSandboxOptions(container *container.Container) ([]libnetwork.SandboxOption, error) {
|
||||
var (
|
||||
sboxOptions []libnetwork.SandboxOption
|
||||
err error
|
||||
dns []string
|
||||
dnsSearch []string
|
||||
dnsOptions []string
|
||||
bindings = make(nat.PortMap)
|
||||
pbList []types.PortBinding
|
||||
|
@ -78,11 +88,7 @@ func (daemon *Daemon) buildSandboxOptions(container *container.Container) ([]lib
|
|||
sboxOptions = append(sboxOptions, libnetwork.OptionDNS(d))
|
||||
}
|
||||
|
||||
if len(container.HostConfig.DNSSearch) > 0 {
|
||||
dnsSearch = container.HostConfig.DNSSearch
|
||||
} else if len(daemon.configStore.DNSSearch) > 0 {
|
||||
dnsSearch = daemon.configStore.DNSSearch
|
||||
}
|
||||
dnsSearch := daemon.getDNSSearchSettings(container)
|
||||
|
||||
for _, ds := range dnsSearch {
|
||||
sboxOptions = append(sboxOptions, libnetwork.OptionDNSSearch(ds))
|
||||
|
|
|
@ -339,8 +339,10 @@ func (daemon *Daemon) initNetworkController(config *Config, activeSandboxes map[
|
|||
name := v.Name
|
||||
|
||||
// If there is no nat network create one from the first NAT network
|
||||
// encountered
|
||||
if !defaultNetworkExists && runconfig.DefaultDaemonNetworkMode() == containertypes.NetworkMode(strings.ToLower(v.Type)) {
|
||||
// encountered if it doesn't already exist
|
||||
if !defaultNetworkExists &&
|
||||
runconfig.DefaultDaemonNetworkMode() == containertypes.NetworkMode(strings.ToLower(v.Type)) &&
|
||||
n == nil {
|
||||
name = runconfig.DefaultDaemonNetworkMode().NetworkName()
|
||||
defaultNetworkExists = true
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ import (
|
|||
"github.com/docker/docker/container"
|
||||
"github.com/docker/docker/layer"
|
||||
"github.com/docker/docker/libcontainerd"
|
||||
"github.com/docker/docker/pkg/system"
|
||||
"golang.org/x/sys/windows/registry"
|
||||
)
|
||||
|
||||
|
@ -30,6 +31,14 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain
|
|||
hvOpts.IsHyperV = container.HostConfig.Isolation.IsHyperV()
|
||||
}
|
||||
|
||||
dnsSearch := daemon.getDNSSearchSettings(container)
|
||||
if dnsSearch != nil {
|
||||
osv := system.GetOSVersion()
|
||||
if osv.Build < 14997 {
|
||||
return nil, fmt.Errorf("dns-search option is not supported on the current platform")
|
||||
}
|
||||
}
|
||||
|
||||
// Generate the layer folder of the layer options
|
||||
layerOpts := &libcontainerd.LayerOption{}
|
||||
m, err := container.RWLayer.Metadata()
|
||||
|
@ -149,7 +158,11 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain
|
|||
createOptions = append(createOptions, hvOpts)
|
||||
createOptions = append(createOptions, layerOpts)
|
||||
if epList != nil {
|
||||
createOptions = append(createOptions, &libcontainerd.NetworkEndpointsOption{Endpoints: epList, AllowUnqualifiedDNSQuery: AllowUnqualifiedDNSQuery})
|
||||
createOptions = append(createOptions, &libcontainerd.NetworkEndpointsOption{
|
||||
Endpoints: epList,
|
||||
AllowUnqualifiedDNSQuery: AllowUnqualifiedDNSQuery,
|
||||
DNSSearchList: dnsSearch,
|
||||
})
|
||||
}
|
||||
|
||||
return createOptions, nil
|
||||
|
|
|
@ -90,6 +90,7 @@ const defaultOwner = "docker"
|
|||
// "SandboxPath": "C:\\\\control\\\\windowsfilter",
|
||||
// "HvPartition": true,
|
||||
// "EndpointList": ["e1bb1e61-d56f-405e-b75d-fd520cefa0cb"],
|
||||
// "DNSSearchList": "a.com,b.com,c.com",
|
||||
// "HvRuntime": {
|
||||
// "ImagePath": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c\\\\UtilityVM"
|
||||
// },
|
||||
|
@ -166,6 +167,9 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir
|
|||
if n, ok := option.(*NetworkEndpointsOption); ok {
|
||||
configuration.EndpointList = n.Endpoints
|
||||
configuration.AllowUnqualifiedDNSQuery = n.AllowUnqualifiedDNSQuery
|
||||
if n.DNSSearchList != nil {
|
||||
configuration.DNSSearchList = strings.Join(n.DNSSearchList, ",")
|
||||
}
|
||||
continue
|
||||
}
|
||||
if c, ok := option.(*CredentialsOption); ok {
|
||||
|
|
|
@ -59,6 +59,7 @@ type LayerOption struct {
|
|||
type NetworkEndpointsOption struct {
|
||||
Endpoints []string
|
||||
AllowUnqualifiedDNSQuery bool
|
||||
DNSSearchList []string
|
||||
}
|
||||
|
||||
// CredentialsOption is a CreateOption that indicates the credentials from
|
||||
|
|
Loading…
Reference in a new issue