forked from docker/docker-hoster
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a5eeb03e8 | |||
| eb55a805b4 | |||
| 581f5c1e66 | |||
| 74fa987b9e | |||
| 05231ffae0 | |||
| c0436fd225 |
@@ -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`:
|
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 \
|
--name myname \
|
||||||
--hostname myhostname \
|
--hostname myhostname \
|
||||||
--network somenetwork --network-alias "myserver.com" \
|
--network somenetwork --network-alias "myserver.com" \
|
||||||
mycontainer
|
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. :)
|
Any contribution is, of course, welcome. :)
|
||||||
|
|||||||
@@ -55,6 +55,13 @@ def main():
|
|||||||
hosts.pop(container_id)
|
hosts.pop(container_id)
|
||||||
update_hosts_file()
|
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):
|
def get_container_data(dockerClient, container_id):
|
||||||
#extract all the info with the docker api
|
#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_hostname = info["Config"]["Hostname"]
|
||||||
container_name = info["Name"].strip("/")
|
container_name = info["Name"].strip("/")
|
||||||
container_ip = info["NetworkSettings"]["IPAddress"]
|
container_ip = info["NetworkSettings"]["IPAddress"]
|
||||||
|
if info["Config"]["Domainname"]:
|
||||||
|
container_hostname = container_hostname + "." + info["Config"]["Domainname"]
|
||||||
|
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
@@ -104,7 +113,8 @@ def update_hosts_file():
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
#remove all the trailing newlines on the line list
|
#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
|
#append all the domain lines
|
||||||
if len(hosts)>0:
|
if len(hosts)>0:
|
||||||
|
|||||||
Reference in New Issue
Block a user