Browse Source

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 <[email protected]>
Signed-off-by: Nicolas De Loof <[email protected]>
Signed-off-by: Sebastiaan van Stijn <[email protected]>
Nicolas De Loof 9 months ago
parent
commit
da2eff4ba7
1 changed files with 5 additions and 0 deletions
  1. 5 0
      pkg/compose/create.go

+ 5 - 0
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))