Fix KeyError when networks with no gateway exist
This commit is contained in:
parent
23112d8e39
commit
8c5cc44946
2 changed files with 10 additions and 1 deletions
|
@ -63,7 +63,7 @@ def get_networks(client: docker.DockerClient, verbose: bool) -> typing.Dict[str,
|
||||||
|
|
||||||
for net in sorted(client.networks.list(), key=lambda k: k.name):
|
for net in sorted(client.networks.list(), key=lambda k: k.name):
|
||||||
try:
|
try:
|
||||||
gateway = net.attrs["IPAM"]["Config"][0]["Gateway"]
|
gateway = net.attrs["IPAM"]["Config"][0]["Subnet"]
|
||||||
except (KeyError, IndexError):
|
except (KeyError, IndexError):
|
||||||
# This network doesn't seem to be used, skip it
|
# This network doesn't seem to be used, skip it
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -22,6 +22,7 @@ services:
|
||||||
- network_a
|
- network_a
|
||||||
- network_b
|
- network_b
|
||||||
- network_c
|
- network_c
|
||||||
|
- no_gateway
|
||||||
host_service:
|
host_service:
|
||||||
container_name: host_service
|
container_name: host_service
|
||||||
image: leoverto/dummy-image
|
image: leoverto/dummy-image
|
||||||
|
@ -36,3 +37,11 @@ networks:
|
||||||
network_b:
|
network_b:
|
||||||
network_c:
|
network_c:
|
||||||
empty_network:
|
empty_network:
|
||||||
|
no_gateway:
|
||||||
|
driver: bridge
|
||||||
|
driver_opts:
|
||||||
|
com.docker.network.bridge.name: br-no-gateway
|
||||||
|
ipam:
|
||||||
|
driver: default
|
||||||
|
config:
|
||||||
|
- subnet: 172.22.1.0/24
|
||||||
|
|
Loading…
Reference in a new issue