(cherry picked from commit 14ff5e213cd084480d628ec0562200b174b6fa79)
Co-authored-by: Matt Clay <matt@mystile.com>
... | ... |
@@ -106,7 +106,13 @@ def get_docker_container_ip(args, container_id): |
106 | 106 |
networks = network_settings.get('Networks') |
107 | 107 |
|
108 | 108 |
if networks: |
109 |
- network_name = get_docker_preferred_network_name(args) or 'bridge' |
|
109 |
+ network_name = get_docker_preferred_network_name(args) |
|
110 |
+ |
|
111 |
+ if not network_name: |
|
112 |
+ # Sort networks and use the first available. |
|
113 |
+ # This assumes all containers will have access to the same networks. |
|
114 |
+ network_name = sorted(networks.keys()).pop(0) |
|
115 |
+ |
|
110 | 116 |
ipaddress = networks[network_name]['IPAddress'] |
111 | 117 |
else: |
112 | 118 |
# podman doesn't provide Networks, fall back to using IPAddress |