Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion tox_docker/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,20 @@ def get_gateway_ip(container: Container) -> str:
# made available on localhost (but 0.0.0.0 works just as well)
ip = "0.0.0.0"
else:
ip = container.attrs["NetworkSettings"]["Gateway"] or "0.0.0.0"
# Try the legacy format first
legacy_gateway = container.attrs["NetworkSettings"].get("Gateway")
if legacy_gateway:
ip = legacy_gateway
else:
# For newer Docker versions, check Networks section
networks = container.attrs["NetworkSettings"].get("Networks", {})
# Try to find gateway in any network (typically 'bridge')
gateway_ip = None
for network_name, network_info in networks.items():
gateway_ip = network_info.get("Gateway")
if gateway_ip:
break
ip = gateway_ip or "0.0.0.0"
return ip


Expand Down