From da2eff4ba7d95ddae71d6b70323dbe739bbd130b Mon Sep 17 00:00:00 2001 From: Nicolas De Loof Date: Thu, 20 Feb 2025 11:16:12 +0100 Subject: [PATCH] add support for gw_priority, enable_ipv4 (requires docker v28.0) This adds support for the GwPriority API field in API v1.48 (docker v28.0). It can be set on both docker container run and docker network connect. This option is used by the Engine to determine which network provides the default gateway for a container. It also adds support for enable_ipv4, which allows enabling (default) or disabling IPv4 address assignment for a network. Co-authored-by: Nicolas De Loof Signed-off-by: Nicolas De Loof Signed-off-by: Sebastiaan van Stijn --- pkg/compose/create.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/compose/create.go b/pkg/compose/create.go index 357791c3dd..ddd4898cbd 100644 --- a/pkg/compose/create.go +++ b/pkg/compose/create.go @@ -443,6 +443,7 @@ func createEndpointSettings(p *types.Project, service types.ServiceConfig, servi ipv6Address string macAddress string driverOpts types.Options + gwPriority int ) if config != nil { ipv4Address = config.Ipv4Address @@ -454,6 +455,7 @@ func createEndpointSettings(p *types.Project, service types.ServiceConfig, servi } macAddress = config.MacAddress driverOpts = config.DriverOpts + gwPriority = config.GatewayPriority } return &network.EndpointSettings{ Aliases: getAliases(p, service, serviceIndex, config, useNetworkAliases), @@ -463,6 +465,7 @@ func createEndpointSettings(p *types.Project, service types.ServiceConfig, servi IPAMConfig: ipam, MacAddress: macAddress, DriverOpts: driverOpts, + GwPriority: gwPriority, } } @@ -1325,6 +1328,7 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, project *ty Attachable: n.Attachable, IPAM: ipam, EnableIPv6: n.EnableIPv6, + EnableIPv4: n.EnableIPv4, } if n.Ipam.Driver != "" || len(n.Ipam.Config) > 0 { @@ -1344,6 +1348,7 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, project *ty } createOpts.IPAM.Config = append(createOpts.IPAM.Config, config) } + networkEventName := fmt.Sprintf("Network %s", n.Name) w := progress.ContextWriter(ctx) w.Event(progress.CreatingEvent(networkEventName))