Skip to content

Commit

Permalink
add support for gw_priority, enable_ipv4 (requires docker v28.0)
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ndeloof committed Feb 21, 2025
1 parent 20f780e commit da2eff4
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/compose/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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),
Expand All @@ -463,6 +465,7 @@ func createEndpointSettings(p *types.Project, service types.ServiceConfig, servi
IPAMConfig: ipam,
MacAddress: macAddress,
DriverOpts: driverOpts,
GwPriority: gwPriority,
}
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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))
Expand Down

0 comments on commit da2eff4

Please sign in to comment.