@@ -2338,6 +2338,8 @@ func (task *Task) dockerPortMap(container *apicontainer.Container) (nat.PortMap,
2338
2338
dockerPortMap := nat.PortMap {}
2339
2339
scContainer := task .GetServiceConnectContainer ()
2340
2340
containerToCheck := container
2341
+ containerPortSet := make (map [int ]struct {})
2342
+ containerPortRangeMap := make (map [string ]string )
2341
2343
if task .IsServiceConnectEnabled () && task .IsNetworkModeBridge () {
2342
2344
if container .Type == apicontainer .ContainerCNIPause {
2343
2345
// we will create bindings for task containers (including both customer containers and SC Appnet container)
@@ -2352,12 +2354,17 @@ func (task *Task) dockerPortMap(container *apicontainer.Container) (nat.PortMap,
2352
2354
// create bindings for all ingress listener ports
2353
2355
// no need to create binding for egress listener port as it won't be access from host level or from outside
2354
2356
for _ , ic := range task .ServiceConnectConfig .IngressConfig {
2355
- dockerPort := nat .Port (strconv .Itoa (int (ic .ListenerPort ))) + "/tcp"
2357
+ listenerPortInt := int (ic .ListenerPort )
2358
+ dockerPort := nat .Port (strconv .Itoa (listenerPortInt )) + "/tcp"
2356
2359
hostPort := 0 // default bridge-mode SC experience - host port will be an ephemeral port assigned by docker
2357
2360
if ic .HostPort != nil { // non-default bridge-mode SC experience - host port specified by customer
2358
2361
hostPort = int (* ic .HostPort )
2359
2362
}
2360
2363
dockerPortMap [dockerPort ] = append (dockerPortMap [dockerPort ], nat.PortBinding {HostPort : strconv .Itoa (hostPort )})
2364
+ // append non-range, singular container port to the containerPortSet
2365
+ containerPortSet [listenerPortInt ] = struct {}{}
2366
+ // set Container.ContainerPortSet to be used during network binding creation
2367
+ taskContainer .SetContainerPortSet (containerPortSet )
2361
2368
}
2362
2369
return dockerPortMap , nil
2363
2370
}
@@ -2370,8 +2377,6 @@ func (task *Task) dockerPortMap(container *apicontainer.Container) (nat.PortMap,
2370
2377
}
2371
2378
}
2372
2379
2373
- containerPortSet := make (map [int ]struct {})
2374
- containerPortRangeMap := make (map [string ]string )
2375
2380
for _ , portBinding := range containerToCheck .Ports {
2376
2381
// for each port binding config, either one of containerPort or containerPortRange is set
2377
2382
if portBinding .ContainerPort != 0 {
0 commit comments