@@ -351,25 +351,7 @@ defmodule Testcontainers.Docker.Api do
351351 # The default bridge IPAddress will be empty for custom networks
352352 resolved_ip = resolve_ip_address ( ip_address , networks )
353353
354- % Container {
355- container_id: container_id ,
356- image: image ,
357- labels: labels ,
358- ip_address: resolved_ip ,
359- exposed_ports:
360- Enum . reduce ( ports || [ ] , [ ] , fn { key , ports } , acc ->
361- acc ++
362- Enum . map ( ports || [ ] , fn % { "HostPort" => host_port } ->
363- { key |> String . replace ( "/tcp" , "" ) |> String . to_integer ( ) ,
364- host_port |> String . to_integer ( ) }
365- end )
366- end ) ,
367- environment:
368- Enum . reduce ( env || [ ] , % { } , fn env , acc ->
369- tokens = String . split ( env , "=" )
370- Map . merge ( acc , % { "#{ List . first ( tokens ) } ": List . last ( tokens ) } )
371- end )
372- }
354+ make_container ( container_id , image , labels , resolved_ip , ports , env )
373355 end
374356
375357 # Also handle when Networks key is missing
@@ -379,6 +361,10 @@ defmodule Testcontainers.Docker.Api do
379361 NetworkSettings: % { IPAddress: ip_address , Ports: ports } ,
380362 Config: % { Env: env , Labels: labels }
381363 } ) do
364+ make_container ( container_id , image , labels , ip_address , ports , env )
365+ end
366+
367+ defp make_container ( container_id , image , labels , ip_address , ports , env ) do
382368 % Container {
383369 container_id: container_id ,
384370 image: image ,
@@ -412,7 +398,6 @@ defmodule Testcontainers.Docker.Api do
412398 networks
413399 |> Enum . find_value ( fn
414400 { _name , % { IPAddress: ip } } when is_binary ( ip ) and ip != "" -> ip
415- { _name , % { "IPAddress" => ip } } when is_binary ( ip ) and ip != "" -> ip
416401 _ -> nil
417402 end )
418403 end
0 commit comments