6 Commits

Author SHA1 Message Date
David Darias 7a5eeb03e8 Merge pull request #17 from aureleoules/develop
Handle container rename
2023-10-23 18:23:22 -04:00
Aurele Oules eb55a805b4 Handle container rename 2023-10-23 23:27:47 +02:00
David Darias 581f5c1e66 Merge pull request #7 from pemcconnell-anyvision/develop
Only attempt lines trim if the list isn't empty
2020-04-28 18:26:49 -04:00
Peter McConnell 74fa987b9e Only attempt lines trim if the list isn't empty 2020-04-27 20:26:00 +01:00
David Darias 05231ffae0 Merge pull request #6 from ederuiter/ederuiter-domainname
Append domain name to host name
2020-03-10 10:41:16 -04:00
Eric de Ruiter c0436fd225 Append domain name to host name 2020-03-09 16:48:05 +01:00
+11 -1
View File
@@ -55,6 +55,13 @@ def main():
hosts.pop(container_id)
update_hosts_file()
if status=="rename":
container_id = e["id"]
if container_id in hosts:
container = get_container_data(dockerClient, container_id)
hosts[container_id] = container
update_hosts_file()
def get_container_data(dockerClient, container_id):
#extract all the info with the docker api
@@ -62,6 +69,8 @@ def get_container_data(dockerClient, container_id):
container_hostname = info["Config"]["Hostname"]
container_name = info["Name"].strip("/")
container_ip = info["NetworkSettings"]["IPAddress"]
if info["Config"]["Domainname"]:
container_hostname = container_hostname + "." + info["Config"]["Domainname"]
result = []
@@ -104,7 +113,8 @@ def update_hosts_file():
break;
#remove all the trailing newlines on the line list
while lines[-1].strip()=="": lines.pop()
if lines:
while lines[-1].strip()=="": lines.pop()
#append all the domain lines
if len(hosts)>0: