diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2024-06-05 09:31:20 +0100 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2024-06-05 09:31:20 +0100 |
commit | a8e7d91e8cdc3c48568fee9c8ca69bdc3ae28ef9 (patch) | |
tree | 10a4b000d7cddf7be439dc3f9990ac2fd19c62cd /docker_net.py | |
parent | d399ef3df2ac08cfc6b58fa50abc3e4ad1cf4af6 (diff) | |
download | TasmotaCLI-a8e7d91e8cdc3c48568fee9c8ca69bdc3ae28ef9.tar.gz TasmotaCLI-a8e7d91e8cdc3c48568fee9c8ca69bdc3ae28ef9.zip |
Added script to automatically fetch the mqtt IP
Diffstat (limited to 'docker_net.py')
-rw-r--r-- | docker_net.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/docker_net.py b/docker_net.py new file mode 100644 index 0000000..dd6f705 --- /dev/null +++ b/docker_net.py @@ -0,0 +1,12 @@ +import docker +import os + +def get_mqtt_addr(): + if os.getuid() != 0: + raise Exception("You must be root to access the docker API and fetch the container's network") + + client = docker.from_env() + containers = client.networks.get("poweredagay_default").attrs["Containers"] + for k, v in containers.items(): + if "mqtt_1" in v["Name"]: + return v["IPv4Address"].split("/") |