1
0
mirror of https://github.com/dvddarias/docker-hoster synced 2026-08-05 16:12:43 +02:00

Compare commits

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
2 changed files with 13 additions and 3 deletions
+2 -2
View File
@@ -19,12 +19,12 @@ Hoster provides by default the entries `<container name>, <hostname>, <container
For example, the following container would be available via DNS as `myname`, `myhostname`, `et54rfgt567` and `myserver.com`:
docker run --restart=unless-stopped -d \
docker run -d \
--name myname \
--hostname myhostname \
--network somenetwork --network-alias "myserver.com" \
mycontainer
If you need more features like **systemd integration** and **dns forwarding** please check [resolvable](https://hub.docker.com/r/mgood/resolvable/)
If you need more features like **systemd interation** and **dns forwarding** please check [resolvable](https://hub.docker.com/r/mgood/resolvable/)
Any contribution is, of course, welcome. :)
+10
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,6 +113,7 @@ def update_hosts_file():
break;
#remove all the trailing newlines on the line list
if lines:
while lines[-1].strip()=="": lines.pop()
#append all the domain lines