From 778550754d747fc3ba060d1136a50c3340d254a7 Mon Sep 17 00:00:00 2001 From: David Boreham Date: Wed, 4 Jan 2023 10:39:16 -0700 Subject: [PATCH] Fix ps display for containers with no mapped ports --- app/deploy_system.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/deploy_system.py b/app/deploy_system.py index 91232094..45f6b61e 100644 --- a/app/deploy_system.py +++ b/app/deploy_system.py @@ -92,9 +92,15 @@ def command(ctx, include, exclude, cluster, command, services): for container in container_list: print(f"id: {container.id}, name: {container.name}, ports: ", end="") ports = container.network_settings.ports + comma = "" for port_mapping in ports.keys(): - print(f"{ports[port_mapping][0]['HostIp']}:{ports[port_mapping][0]['HostPort']}->{port_mapping}", end=",") - # TODO: fix the extra comma + mapping = ports[port_mapping] + print(comma, end="") + if mapping is None: + print(f"{port_mapping}", end="") + else: + print(f"{mapping[0]['HostIp']}:{mapping[0]['HostPort']}->{port_mapping}", end="") + comma = ", " print() else: print("No containers running") -- 2.45.2