@@ -301,35 +301,9 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
301
301
}
302
302
303
303
var networkConfig * network.NetworkingConfig
304
-
305
304
for _ , id := range service .NetworksByPriority () {
306
- net := p .Networks [id ]
307
- config := service .Networks [id ]
308
- var ipam * network.EndpointIPAMConfig
309
- var (
310
- ipv4Address string
311
- ipv6Address string
312
- )
313
- if config != nil {
314
- ipv4Address = config .Ipv4Address
315
- ipv6Address = config .Ipv6Address
316
- ipam = & network.EndpointIPAMConfig {
317
- IPv4Address : ipv4Address ,
318
- IPv6Address : ipv6Address ,
319
- LinkLocalIPs : config .LinkLocalIPs ,
320
- }
321
- }
322
- networkConfig = & network.NetworkingConfig {
323
- EndpointsConfig : map [string ]* network.EndpointSettings {
324
- net .Name : {
325
- Aliases : getAliases (service , config ),
326
- IPAddress : ipv4Address ,
327
- IPv6Gateway : ipv6Address ,
328
- IPAMConfig : ipam ,
329
- },
330
- },
331
- }
332
- break //nolint:staticcheck
305
+ networkConfig = s .createNetworkConfig (p , service , id )
306
+ break
333
307
}
334
308
335
309
tmpfs := map [string ]string {}
@@ -409,6 +383,35 @@ func (s *composeService) getCreateOptions(ctx context.Context, p *types.Project,
409
383
return & containerConfig , & hostConfig , networkConfig , nil
410
384
}
411
385
386
+ func (s * composeService ) createNetworkConfig (p * types.Project , service types.ServiceConfig , networkID string ) * network.NetworkingConfig {
387
+ net := p .Networks [networkID ]
388
+ config := service .Networks [networkID ]
389
+ var ipam * network.EndpointIPAMConfig
390
+ var (
391
+ ipv4Address string
392
+ ipv6Address string
393
+ )
394
+ if config != nil {
395
+ ipv4Address = config .Ipv4Address
396
+ ipv6Address = config .Ipv6Address
397
+ ipam = & network.EndpointIPAMConfig {
398
+ IPv4Address : ipv4Address ,
399
+ IPv6Address : ipv6Address ,
400
+ LinkLocalIPs : config .LinkLocalIPs ,
401
+ }
402
+ }
403
+ return & network.NetworkingConfig {
404
+ EndpointsConfig : map [string ]* network.EndpointSettings {
405
+ net .Name : {
406
+ Aliases : getAliases (service , config ),
407
+ IPAddress : ipv4Address ,
408
+ IPv6Gateway : ipv6Address ,
409
+ IPAMConfig : ipam ,
410
+ },
411
+ },
412
+ }
413
+ }
414
+
412
415
// copy/pasted from https://github.com/docker/cli/blob/9de1b162f/cli/command/container/opts.go#L673-L697 + RelativePath
413
416
// TODO find so way to share this code with docker/cli
414
417
func parseSecurityOpts (p * types.Project , securityOpts []string ) ([]string , bool , error ) {
0 commit comments