From 0544246f7c733874c4411590c7ad5dc7e7ce3b72 Mon Sep 17 00:00:00 2001 From: LeoVerto Date: Thu, 4 Jun 2020 23:24:50 +0200 Subject: [PATCH] Fix KeyError when containers are attached to no or host network Fixes #7, fixes #10. --- docker-net-graph.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docker-net-graph.py b/docker-net-graph.py index d439a9a..77a04e9 100755 --- a/docker-net-graph.py +++ b/docker-net-graph.py @@ -87,6 +87,8 @@ def get_networks(client: docker.DockerClient, verbose: bool) -> typing.Dict[str, color = get_unique_color() networks[net.name] = Network(net.name, gateway, internal, isolated, color) + networks["host"] = Network("host", "0.0.0.0", False, False, "#808080") + return networks @@ -167,7 +169,8 @@ def generate_graph(verbose: bool, file: str): draw_container(g, container) for link in links: - draw_link(g, networks, link) + if link.network_name != "none": + draw_link(g, networks, link) if file: g.render(base)