Signed-off-by: msabansal <sabansal@microsoft.com>
| ... | ... |
@@ -782,7 +782,7 @@ func (container *Container) BuildJoinOptions(n libnetwork.Network) ([]libnetwork |
| 782 | 782 |
} |
| 783 | 783 |
|
| 784 | 784 |
// BuildCreateEndpointOptions builds endpoint options from a given network. |
| 785 |
-func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network, epConfig *networktypes.EndpointSettings, sb libnetwork.Sandbox) ([]libnetwork.EndpointOption, error) {
|
|
| 785 |
+func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network, epConfig *networktypes.EndpointSettings, sb libnetwork.Sandbox, daemonDNS []string) ([]libnetwork.EndpointOption, error) {
|
|
| 786 | 786 |
var ( |
| 787 | 787 |
bindings = make(nat.PortMap) |
| 788 | 788 |
pbList []types.PortBinding |
| ... | ... |
@@ -792,7 +792,8 @@ func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network, epC |
| 792 | 792 |
|
| 793 | 793 |
defaultNetName := runconfig.DefaultDaemonNetworkMode().NetworkName() |
| 794 | 794 |
|
| 795 |
- if n.Name() == defaultNetName || container.NetworkSettings.IsAnonymousEndpoint {
|
|
| 795 |
+ if (!container.EnableServiceDiscoveryOnDefaultNetwork() && n.Name() == defaultNetName) || |
|
| 796 |
+ container.NetworkSettings.IsAnonymousEndpoint {
|
|
| 796 | 797 |
createOptions = append(createOptions, libnetwork.CreateOptionAnonymous()) |
| 797 | 798 |
} |
| 798 | 799 |
|
| ... | ... |
@@ -914,6 +915,19 @@ func (container *Container) BuildCreateEndpointOptions(n libnetwork.Network, epC |
| 914 | 914 |
} |
| 915 | 915 |
} |
| 916 | 916 |
|
| 917 |
+ var dns []string |
|
| 918 |
+ |
|
| 919 |
+ if len(container.HostConfig.DNS) > 0 {
|
|
| 920 |
+ dns = container.HostConfig.DNS |
|
| 921 |
+ } else if len(daemonDNS) > 0 {
|
|
| 922 |
+ dns = daemonDNS |
|
| 923 |
+ } |
|
| 924 |
+ |
|
| 925 |
+ if len(dns) > 0 {
|
|
| 926 |
+ createOptions = append(createOptions, |
|
| 927 |
+ libnetwork.CreateOptionDNS(dns)) |
|
| 928 |
+ } |
|
| 929 |
+ |
|
| 917 | 930 |
createOptions = append(createOptions, |
| 918 | 931 |
libnetwork.CreateOptionPortMapping(pbList), |
| 919 | 932 |
libnetwork.CreateOptionExposedPorts(exposeList)) |
| ... | ... |
@@ -93,3 +93,8 @@ func (container *Container) BuildHostnameFile() error {
|
| 93 | 93 |
func (container *Container) canMountFS() bool {
|
| 94 | 94 |
return true |
| 95 | 95 |
} |
| 96 |
+ |
|
| 97 |
+// EnableServiceDiscoveryOnDefaultNetwork Enable service discovery on default network |
|
| 98 |
+func (container *Container) EnableServiceDiscoveryOnDefaultNetwork() bool {
|
|
| 99 |
+ return false |
|
| 100 |
+} |
| ... | ... |
@@ -428,3 +428,8 @@ func cleanResourcePath(path string) string {
|
| 428 | 428 |
func (container *Container) canMountFS() bool {
|
| 429 | 429 |
return true |
| 430 | 430 |
} |
| 431 |
+ |
|
| 432 |
+// EnableServiceDiscoveryOnDefaultNetwork Enable service discovery on default network |
|
| 433 |
+func (container *Container) EnableServiceDiscoveryOnDefaultNetwork() bool {
|
|
| 434 |
+ return false |
|
| 435 |
+} |
| ... | ... |
@@ -110,3 +110,8 @@ func (container *Container) BuildHostnameFile() error {
|
| 110 | 110 |
func (container *Container) canMountFS() bool {
|
| 111 | 111 |
return !containertypes.Isolation.IsHyperV(container.HostConfig.Isolation) |
| 112 | 112 |
} |
| 113 |
+ |
|
| 114 |
+// EnableServiceDiscoveryOnDefaultNetwork Enable service discovery on default network |
|
| 115 |
+func (container *Container) EnableServiceDiscoveryOnDefaultNetwork() bool {
|
|
| 116 |
+ return true |
|
| 117 |
+} |
| ... | ... |
@@ -597,11 +597,12 @@ func cleanOperationalData(es *network.EndpointSettings) {
|
| 597 | 597 |
} |
| 598 | 598 |
|
| 599 | 599 |
func (daemon *Daemon) updateNetworkConfig(container *container.Container, n libnetwork.Network, endpointConfig *networktypes.EndpointSettings, updateSettings bool) error {
|
| 600 |
+ |
|
| 600 | 601 |
if !containertypes.NetworkMode(n.Name()).IsUserDefined() {
|
| 601 | 602 |
if hasUserDefinedIPAddress(endpointConfig) && !enableIPOnPredefinedNetwork() {
|
| 602 | 603 |
return runconfig.ErrUnsupportedNetworkAndIP |
| 603 | 604 |
} |
| 604 |
- if endpointConfig != nil && len(endpointConfig.Aliases) > 0 {
|
|
| 605 |
+ if endpointConfig != nil && len(endpointConfig.Aliases) > 0 && !container.EnableServiceDiscoveryOnDefaultNetwork() {
|
|
| 605 | 606 |
return runconfig.ErrUnsupportedNetworkAndAlias |
| 606 | 607 |
} |
| 607 | 608 |
} else {
|
| ... | ... |
@@ -673,9 +674,8 @@ func (daemon *Daemon) connectToNetwork(container *container.Container, idOrName |
| 673 | 673 |
} |
| 674 | 674 |
|
| 675 | 675 |
controller := daemon.netController |
| 676 |
- |
|
| 677 | 676 |
sb := daemon.getNetworkSandbox(container) |
| 678 |
- createOptions, err := container.BuildCreateEndpointOptions(n, endpointConfig, sb) |
|
| 677 |
+ createOptions, err := container.BuildCreateEndpointOptions(n, endpointConfig, sb, daemon.configStore.DNS) |
|
| 679 | 678 |
if err != nil {
|
| 680 | 679 |
return err |
| 681 | 680 |
} |
| ... | ... |
@@ -53,6 +53,7 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain |
| 53 | 53 |
|
| 54 | 54 |
// Get endpoints for the libnetwork allocated networks to the container |
| 55 | 55 |
var epList []string |
| 56 |
+ AllowUnqualifiedDNSQuery := false |
|
| 56 | 57 |
if container.NetworkSettings != nil {
|
| 57 | 58 |
for n := range container.NetworkSettings.Networks {
|
| 58 | 59 |
sn, err := daemon.FindNetwork(n) |
| ... | ... |
@@ -72,6 +73,10 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain |
| 72 | 72 |
if data["hnsid"] != nil {
|
| 73 | 73 |
epList = append(epList, data["hnsid"].(string)) |
| 74 | 74 |
} |
| 75 |
+ |
|
| 76 |
+ if data["AllowUnqualifiedDNSQuery"] != nil {
|
|
| 77 |
+ AllowUnqualifiedDNSQuery = true |
|
| 78 |
+ } |
|
| 75 | 79 |
} |
| 76 | 80 |
} |
| 77 | 81 |
|
| ... | ... |
@@ -80,7 +85,7 @@ func (daemon *Daemon) getLibcontainerdCreateOptions(container *container.Contain |
| 80 | 80 |
createOptions = append(createOptions, hvOpts) |
| 81 | 81 |
createOptions = append(createOptions, layerOpts) |
| 82 | 82 |
if epList != nil {
|
| 83 |
- createOptions = append(createOptions, &libcontainerd.NetworkEndpointsOption{Endpoints: epList})
|
|
| 83 |
+ createOptions = append(createOptions, &libcontainerd.NetworkEndpointsOption{Endpoints: epList, AllowUnqualifiedDNSQuery: AllowUnqualifiedDNSQuery})
|
|
| 84 | 84 |
} |
| 85 | 85 |
|
| 86 | 86 |
return &createOptions, nil |
| ... | ... |
@@ -150,6 +150,7 @@ func (clnt *client) Create(containerID string, checkpoint string, checkpointDir |
| 150 | 150 |
} |
| 151 | 151 |
if n, ok := option.(*NetworkEndpointsOption); ok {
|
| 152 | 152 |
configuration.EndpointList = n.Endpoints |
| 153 |
+ configuration.AllowUnqualifiedDNSQuery = n.AllowUnqualifiedDNSQuery |
|
| 153 | 154 |
continue |
| 154 | 155 |
} |
| 155 | 156 |
} |
| ... | ... |
@@ -64,7 +64,8 @@ type LayerOption struct {
|
| 64 | 64 |
// NetworkEndpointsOption is a CreateOption that provides the runtime list |
| 65 | 65 |
// of network endpoints to which a container should be attached during its creation. |
| 66 | 66 |
type NetworkEndpointsOption struct {
|
| 67 |
- Endpoints []string |
|
| 67 |
+ Endpoints []string |
|
| 68 |
+ AllowUnqualifiedDNSQuery bool |
|
| 68 | 69 |
} |
| 69 | 70 |
|
| 70 | 71 |
// Checkpoint holds the details of a checkpoint (not supported in windows) |