Skip to content

Commit da2eff4

Browse files
committed
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]>
1 parent 20f780e commit da2eff4

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

pkg/compose/create.go

+5
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ func createEndpointSettings(p *types.Project, service types.ServiceConfig, servi
443443
ipv6Address string
444444
macAddress string
445445
driverOpts types.Options
446+
gwPriority int
446447
)
447448
if config != nil {
448449
ipv4Address = config.Ipv4Address
@@ -454,6 +455,7 @@ func createEndpointSettings(p *types.Project, service types.ServiceConfig, servi
454455
}
455456
macAddress = config.MacAddress
456457
driverOpts = config.DriverOpts
458+
gwPriority = config.GatewayPriority
457459
}
458460
return &network.EndpointSettings{
459461
Aliases: getAliases(p, service, serviceIndex, config, useNetworkAliases),
@@ -463,6 +465,7 @@ func createEndpointSettings(p *types.Project, service types.ServiceConfig, servi
463465
IPAMConfig: ipam,
464466
MacAddress: macAddress,
465467
DriverOpts: driverOpts,
468+
GwPriority: gwPriority,
466469
}
467470
}
468471

@@ -1325,6 +1328,7 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, project *ty
13251328
Attachable: n.Attachable,
13261329
IPAM: ipam,
13271330
EnableIPv6: n.EnableIPv6,
1331+
EnableIPv4: n.EnableIPv4,
13281332
}
13291333

13301334
if n.Ipam.Driver != "" || len(n.Ipam.Config) > 0 {
@@ -1344,6 +1348,7 @@ func (s *composeService) resolveOrCreateNetwork(ctx context.Context, project *ty
13441348
}
13451349
createOpts.IPAM.Config = append(createOpts.IPAM.Config, config)
13461350
}
1351+
13471352
networkEventName := fmt.Sprintf("Network %s", n.Name)
13481353
w := progress.ContextWriter(ctx)
13491354
w.Event(progress.CreatingEvent(networkEventName))

0 commit comments

Comments
 (0)