|
@@ -788,6 +788,7 @@ func (daemon *Daemon) clearAttachableNetworks() {
|
|
// buildCreateEndpointOptions builds endpoint options from a given network.
|
|
// buildCreateEndpointOptions builds endpoint options from a given network.
|
|
func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, epConfig *network.EndpointSettings, sb *libnetwork.Sandbox, daemonDNS []string) ([]libnetwork.EndpointOption, error) {
|
|
func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, epConfig *network.EndpointSettings, sb *libnetwork.Sandbox, daemonDNS []string) ([]libnetwork.EndpointOption, error) {
|
|
var createOptions []libnetwork.EndpointOption
|
|
var createOptions []libnetwork.EndpointOption
|
|
|
|
+ var genericOptions = make(options.Generic)
|
|
|
|
|
|
nwName := n.Name()
|
|
nwName := n.Name()
|
|
defaultNetName := runconfig.DefaultDaemonNetworkMode().NetworkName()
|
|
defaultNetName := runconfig.DefaultDaemonNetworkMode().NetworkName()
|
|
@@ -825,6 +826,14 @@ func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, e
|
|
for k, v := range epConfig.DriverOpts {
|
|
for k, v := range epConfig.DriverOpts {
|
|
createOptions = append(createOptions, libnetwork.EndpointOptionGeneric(options.Generic{k: v}))
|
|
createOptions = append(createOptions, libnetwork.EndpointOptionGeneric(options.Generic{k: v}))
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if epConfig.MacAddress != "" {
|
|
|
|
+ mac, err := net.ParseMAC(epConfig.MacAddress)
|
|
|
|
+ if err != nil {
|
|
|
|
+ return nil, err
|
|
|
|
+ }
|
|
|
|
+ genericOptions[netlabel.MacAddress] = mac
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
if svcCfg := c.NetworkSettings.Service; svcCfg != nil {
|
|
if svcCfg := c.NetworkSettings.Service; svcCfg != nil {
|
|
@@ -852,23 +861,6 @@ func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, e
|
|
createOptions = append(createOptions, libnetwork.CreateOptionDisableResolution())
|
|
createOptions = append(createOptions, libnetwork.CreateOptionDisableResolution())
|
|
}
|
|
}
|
|
|
|
|
|
- // configs that are applicable only for the endpoint in the network
|
|
|
|
- // to which container was connected to on docker run.
|
|
|
|
- // Ideally all these network-specific endpoint configurations must be moved under
|
|
|
|
- // container.NetworkSettings.Networks[n.Name()]
|
|
|
|
- netMode := c.HostConfig.NetworkMode
|
|
|
|
- if nwName == netMode.NetworkName() || n.ID() == netMode.NetworkName() || (nwName == defaultNetName && netMode.IsDefault()) {
|
|
|
|
- if c.Config.MacAddress != "" {
|
|
|
|
- mac, err := net.ParseMAC(c.Config.MacAddress)
|
|
|
|
- if err != nil {
|
|
|
|
- return nil, err
|
|
|
|
- }
|
|
|
|
- createOptions = append(createOptions, libnetwork.EndpointOptionGeneric(options.Generic{
|
|
|
|
- netlabel.MacAddress: mac,
|
|
|
|
- }))
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
// Port-mapping rules belong to the container & applicable only to non-internal networks.
|
|
// Port-mapping rules belong to the container & applicable only to non-internal networks.
|
|
//
|
|
//
|
|
// TODO(thaJeztah): Look if we can provide a more minimal function for getPortMapInfo, as it does a lot, and we only need the "length".
|
|
// TODO(thaJeztah): Look if we can provide a more minimal function for getPortMapInfo, as it does a lot, and we only need the "length".
|
|
@@ -940,7 +932,10 @@ func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, e
|
|
createOptions = append(createOptions, libnetwork.CreateOptionDNS(daemonDNS))
|
|
createOptions = append(createOptions, libnetwork.CreateOptionDNS(daemonDNS))
|
|
}
|
|
}
|
|
|
|
|
|
- createOptions = append(createOptions, libnetwork.CreateOptionPortMapping(publishedPorts), libnetwork.CreateOptionExposedPorts(exposedPorts))
|
|
|
|
|
|
+ createOptions = append(createOptions,
|
|
|
|
+ libnetwork.CreateOptionPortMapping(publishedPorts),
|
|
|
|
+ libnetwork.CreateOptionExposedPorts(exposedPorts),
|
|
|
|
+ libnetwork.EndpointOptionGeneric(genericOptions))
|
|
|
|
|
|
return createOptions, nil
|
|
return createOptions, nil
|
|
}
|
|
}
|