1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2025-07-02 06:45:45 +00:00

Merge pull request #2222 from rot169/support-hostnet-containers

Support containers running --net=host (#1537)
This commit is contained in:
Nicolas Duchon
2023-06-07 07:55:28 +02:00
committed by GitHub
7 changed files with 115 additions and 0 deletions

View File

@ -160,6 +160,10 @@ def container_ip(container: Container):
net_info = container.attrs["NetworkSettings"]["Networks"]
if "bridge" in net_info:
return net_info["bridge"]["IPAddress"]
# container is running in host network mode
if "host" in net_info:
return "127.0.0.1"
# not default bridge network, fallback on first network defined
network_name = list(net_info.keys())[0]
@ -173,6 +177,10 @@ def container_ipv6(container):
net_info = container.attrs["NetworkSettings"]["Networks"]
if "bridge" in net_info:
return net_info["bridge"]["GlobalIPv6Address"]
# container is running in host network mode
if "host" in net_info:
return "::1"
# not default bridge network, fallback on first network defined
network_name = list(net_info.keys())[0]