@@ -182,16 +182,14 @@ func (in ContainerInstance) GetContainer() *types.Container {
182182}
183183
184184func getContainer (name string ) types.Container {
185- cli , err := client .NewClientWithOpts (client .FromEnv , client .WithAPIVersionNegotiation ())
186- x .Check (err )
185+ containers := AllContainers (DockerPrefix )
187186
188- containers , err := cli .ContainerList (context .Background (), container.ListOptions {All : true })
189- if err != nil {
190- log .Fatalf ("While listing container: %v\n " , err )
191- }
187+ fmt .Println ("-------------containers-------------------" , len (containers ))
192188
193189 q := fmt .Sprintf ("/%s_%s_" , DockerPrefix , name )
190+ fmt .Println ("-------------qprefix-------------------" , q )
194191 for _ , c := range containers {
192+ fmt .Println ("-------------c.names-------------------" , c .Names )
195193 for _ , n := range c .Names {
196194 if ! strings .HasPrefix (n , q ) {
197195 continue
@@ -213,9 +211,9 @@ func AllContainers(prefix string) []types.Container {
213211
214212 var out []types.Container
215213 for _ , c := range containers {
216- fmt .Println ("--------------------------------" )
217- fmt .Println ("overall containers" , c .Names )
218- fmt .Println ("-------------prefix-------------------" , prefix )
214+ // fmt.Println("--------------------------------")
215+ // fmt.Println("overall containers", c.Names)
216+ // fmt.Println("-------------prefix-------------------", prefix)
219217 for _ , name := range c .Names {
220218 if strings .HasPrefix (name , "/" + prefix ) {
221219 out = append (out , c )
@@ -244,7 +242,11 @@ func ContainerAddrWithHostRetry(name string, privatePort uint16, host string) st
244242 for attempt := range maxAttempts {
245243 fmt .Printf ("Attempt %d to get container address for %s:%d with host %s\n " , attempt , name , privatePort , host )
246244 c := getContainer (name )
245+ fmt .Println ("-------------c-------------------" , c )
246+
247247 for _ , p := range c .Ports {
248+ fmt .Println ("-------------p.Private port-------------------" , p .PrivatePort )
249+ fmt .Println ("-------------private port-------------------" , privatePort )
248250 if p .PrivatePort == privatePort {
249251 // Found the mapping - return immediately without waiting
250252 return host + ":" + strconv .Itoa (int (p .PublicPort ))
0 commit comments