Signed-off-by: msabansal <sabansal@microsoft.com>
| ... | ... |
@@ -32,12 +32,22 @@ var ( |
| 32 | 32 |
getPortMapInfo = container.GetSandboxPortMapInfo |
| 33 | 33 |
) |
| 34 | 34 |
|
| 35 |
+func (daemon *Daemon) getDNSSearchSettings(container *container.Container) []string {
|
|
| 36 |
+ if len(container.HostConfig.DNSSearch) > 0 {
|
|
| 37 |
+ return container.HostConfig.DNSSearch |
|
| 38 |
+ } |
|
| 39 |
+ |
|
| 40 |
+ if len(daemon.configStore.DNSSearch) > 0 {
|
|
| 41 |
+ return daemon.configStore.DNSSearch |
|
| 42 |
+ } |
|
| 43 |
+ |
|
| 44 |
+ return nil |
|
| 45 |
+} |
|
| 35 | 46 |
func (daemon *Daemon) buildSandboxOptions(container *container.Container) ([]libnetwork.SandboxOption, error) {
|
| 36 | 47 |
var ( |
| 37 | 48 |
sboxOptions []libnetwork.SandboxOption |
| 38 | 49 |
err error |
| 39 | 50 |
dns []string |
| 40 |
- dnsSearch []string |
|
| 41 | 51 |
dnsOptions []string |
| 42 | 52 |
bindings = make(nat.PortMap) |
| 43 | 53 |
pbList []types.PortBinding |
| ... | ... |
@@ -78,11 +88,7 @@ func (daemon *Daemon) buildSandboxOptions(container *container.Container) ([]lib |
| 78 | 78 |
sboxOptions = append(sboxOptions, libnetwork.OptionDNS(d)) |
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 |
- if len(container.HostConfig.DNSSearch) > 0 {
|
|
| 82 |
- dnsSearch = container.HostConfig.DNSSearch |
|
| 83 |
- } else if len(daemon.configStore.DNSSearch) > 0 {
|
|
| 84 |
- dnsSearch = daemon.configStore.DNSSearch |
|
| 85 |
- } |
|
| 81 |
+ dnsSearch := daemon.getDNSSearchSettings(container) |
|
| 86 | 82 |
|
| 87 | 83 |
for _, ds := range dnsSearch {
|
| 88 | 84 |
sboxOptions = append(sboxOptions, libnetwork.OptionDNSSearch(ds)) |
| ... | ... |
@@ -339,8 +339,10 @@ func (daemon *Daemon) initNetworkController(config *Config, activeSandboxes map[ |
| 339 | 339 |
name := v.Name |
| 340 | 340 |
|
| 341 | 341 |
// If there is no nat network create one from the first NAT network |
| 342 |
- // encountered |
|
| 343 |
- if !defaultNetworkExists && runconfig.DefaultDaemonNetworkMode() == containertypes.NetworkMode(strings.ToLower(v.Type)) {
|
|
| 342 |
+ // encountered if it doesn't already exist |
|
| 343 |
+ if !defaultNetworkExists && |
|
| 344 |
+ runconfig.DefaultDaemonNetworkMode() == containertypes.NetworkMode(strings.ToLower(v.Type)) && |
|
| 345 |
+ n == nil {
|
|
| 344 | 346 |
name = runconfig.DefaultDaemonNetworkMode().NetworkName() |
| 345 | 347 |
defaultNetworkExists = true |
| 346 | 348 |
} |
| ... | ... |
@@ -9,6 +9,7 @@ import ( |
| 9 | 9 |
"github.com/docker/docker/container" |
| 10 | 10 |
"github.com/docker/docker/layer" |
| 11 | 11 |
"github.com/docker/docker/libcontainerd" |
| 12 |
+ "github.com/docker/docker/pkg/system" |
|
| 12 | 13 |
"golang.org/x/sys/windows/registry" |
| 13 | 14 |
) |
| 14 | 15 |
|
| ... | ... |
@@ -30,6 +31,14 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain |
| 30 | 30 |
hvOpts.IsHyperV = container.HostConfig.Isolation.IsHyperV() |
| 31 | 31 |
} |
| 32 | 32 |
|
| 33 |
+ dnsSearch := daemon.getDNSSearchSettings(container) |
|
| 34 |
+ if dnsSearch != nil {
|
|
| 35 |
+ osv := system.GetOSVersion() |
|
| 36 |
+ if osv.Build < 14997 {
|
|
| 37 |
+ return nil, fmt.Errorf("dns-search option is not supported on the current platform")
|
|
| 38 |
+ } |
|
| 39 |
+ } |
|
| 40 |
+ |
|
| 33 | 41 |
// Generate the layer folder of the layer options |
| 34 | 42 |
layerOpts := &libcontainerd.LayerOption{}
|
| 35 | 43 |
m, err := container.RWLayer.Metadata() |
| ... | ... |
@@ -149,7 +158,11 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain |
| 149 | 149 |
createOptions = append(createOptions, hvOpts) |
| 150 | 150 |
createOptions = append(createOptions, layerOpts) |
| 151 | 151 |
if epList != nil {
|
| 152 |
- createOptions = append(createOptions, &libcontainerd.NetworkEndpointsOption{Endpoints: epList, AllowUnqualifiedDNSQuery: AllowUnqualifiedDNSQuery})
|
|
| 152 |
+ createOptions = append(createOptions, &libcontainerd.NetworkEndpointsOption{
|
|
| 153 |
+ Endpoints: epList, |
|
| 154 |
+ AllowUnqualifiedDNSQuery: AllowUnqualifiedDNSQuery, |
|
| 155 |
+ DNSSearchList: dnsSearch, |
|
| 156 |
+ }) |
|
| 153 | 157 |
} |
| 154 | 158 |
|
| 155 | 159 |
return createOptions, nil |
| ... | ... |
@@ -90,6 +90,7 @@ const defaultOwner = "docker" |
| 90 | 90 |
// "SandboxPath": "C:\\\\control\\\\windowsfilter", |
| 91 | 91 |
// "HvPartition": true, |
| 92 | 92 |
// "EndpointList": ["e1bb1e61-d56f-405e-b75d-fd520cefa0cb"], |
| 93 |
+// "DNSSearchList": "a.com,b.com,c.com", |
|
| 93 | 94 |
// "HvRuntime": {
|
| 94 | 95 |
// "ImagePath": "C:\\\\control\\\\windowsfilter\\\\65bf96e5760a09edf1790cb229e2dfb2dbd0fcdc0bf7451bae099106bfbfea0c\\\\UtilityVM" |
| 95 | 96 |
// }, |
| ... | ... |
@@ -166,6 +167,9 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir |
| 166 | 166 |
if n, ok := option.(*NetworkEndpointsOption); ok {
|
| 167 | 167 |
configuration.EndpointList = n.Endpoints |
| 168 | 168 |
configuration.AllowUnqualifiedDNSQuery = n.AllowUnqualifiedDNSQuery |
| 169 |
+ if n.DNSSearchList != nil {
|
|
| 170 |
+ configuration.DNSSearchList = strings.Join(n.DNSSearchList, ",") |
|
| 171 |
+ } |
|
| 169 | 172 |
continue |
| 170 | 173 |
} |
| 171 | 174 |
if c, ok := option.(*CredentialsOption); ok {
|