if the networks is "host", use 127.0.0.1

This commit is contained in:
neilpang 2021-05-05 16:30:33 +08:00
parent 581f5c1e66
commit 6b5ca1643e
1 changed files with 3 additions and 0 deletions

View File

@ -62,6 +62,9 @@ def get_container_data(dockerClient, container_id):
container_hostname = info["Config"]["Hostname"]
container_name = info["Name"].strip("/")
container_ip = info["NetworkSettings"]["IPAddress"]
if not container_ip and info["NetworkSettings"]["Networks"]["host"]:
container_ip = "127.0.0.1"
if info["Config"]["Domainname"]:
container_hostname = container_hostname + "." + info["Config"]["Domainname"]