@@ -2338,6 +2338,8 @@ func (task *Task) dockerPortMap(container *apicontainer.Container) (nat.PortMap,
23382338 dockerPortMap := nat.PortMap {}
23392339 scContainer := task .GetServiceConnectContainer ()
23402340 containerToCheck := container
2341+ containerPortSet := make (map [int ]struct {})
2342+ containerPortRangeMap := make (map [string ]string )
23412343 if task .IsServiceConnectEnabled () && task .IsNetworkModeBridge () {
23422344 if container .Type == apicontainer .ContainerCNIPause {
23432345 // 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,
23522354 // create bindings for all ingress listener ports
23532355 // no need to create binding for egress listener port as it won't be access from host level or from outside
23542356 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"
23562359 hostPort := 0 // default bridge-mode SC experience - host port will be an ephemeral port assigned by docker
23572360 if ic .HostPort != nil { // non-default bridge-mode SC experience - host port specified by customer
23582361 hostPort = int (* ic .HostPort )
23592362 }
23602363 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 taskContainer.ContainerPortSet to be used during network binding creation
2367+ taskContainer .SetContainerPortSet (containerPortSet )
23612368 }
23622369 return dockerPortMap , nil
23632370 }
@@ -2370,8 +2377,6 @@ func (task *Task) dockerPortMap(container *apicontainer.Container) (nat.PortMap,
23702377 }
23712378 }
23722379
2373- containerPortSet := make (map [int ]struct {})
2374- containerPortRangeMap := make (map [string ]string )
23752380 for _ , portBinding := range containerToCheck .Ports {
23762381 // for each port binding config, either one of containerPort or containerPortRange is set
23772382 if portBinding .ContainerPort != 0 {
0 commit comments