Set EnableIPv4 for predefined networks

Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
Rob Murray
2024-07-30 20:17:54 +01:00
parent 903daa4dc4
commit 1f542d5d6c
4 changed files with 6 additions and 0 deletions

View File

@@ -626,6 +626,7 @@ func (c *containerConfig) networkCreateRequest(name string) (clustertypes.Networ
return clustertypes.NetworkCreateRequest{}, errors.New("container: unknown network referenced")
}
ipv4Enabled := true
ipv6Enabled := na.Network.Spec.Ipv6Enabled
options := network.CreateOptions{
// ID: na.Network.ID,
@@ -633,6 +634,7 @@ func (c *containerConfig) networkCreateRequest(name string) (clustertypes.Networ
Internal: na.Network.Spec.Internal,
Attachable: na.Network.Spec.Attachable,
Ingress: convert.IsIngressNetwork(na.Network),
EnableIPv4: &ipv4Enabled,
EnableIPv6: &ipv6Enabled,
Scope: scope.Swarm,
}

View File

@@ -1051,6 +1051,7 @@ func initBridgeDriver(controller *libnetwork.Controller, cfg config.BridgeConfig
}
// Initialize default network on "bridge" with the same name
_, err = controller.NewNetwork("bridge", network.NetworkBridge, "",
libnetwork.NetworkOptionEnableIPv4(true),
libnetwork.NetworkOptionEnableIPv6(cfg.EnableIPv6),
libnetwork.NetworkOptionDriverOpts(netOption),
libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil),

View File

@@ -386,6 +386,7 @@ func (daemon *Daemon) initNetworkController(daemonCfg *config.Config, activeSand
_, err := daemon.netController.NewNetwork(strings.ToLower(v.Type), name, nid,
libnetwork.NetworkOptionGeneric(options.Generic{
netlabel.GenericData: netOption,
netlabel.EnableIPv4: true,
}),
libnetwork.NetworkOptionIpam("default", "", v4Conf, v6Conf, nil),
)
@@ -430,6 +431,7 @@ func initBridgeDriver(controller *libnetwork.Controller, config config.BridgeCon
_, err := controller.NewNetwork(network.DefaultNetwork, network.DefaultNetwork, "",
libnetwork.NetworkOptionGeneric(options.Generic{
netlabel.GenericData: netOption,
netlabel.EnableIPv4: true,
}),
ipamOption,
)

View File

@@ -20,6 +20,7 @@ func (c *Controller) createGWNetwork() (*Network, error) {
bridge.EnableICC: strconv.FormatBool(false),
bridge.EnableIPMasquerade: strconv.FormatBool(true),
}),
NetworkOptionEnableIPv4(true),
NetworkOptionEnableIPv6(false),
)
if err != nil {