diff --git a/smoketests/docker.py b/smoketests/docker.py index 7949dd5a1cc..d45848995fe 100644 --- a/smoketests/docker.py +++ b/smoketests/docker.py @@ -57,11 +57,12 @@ def host_ports(self, docker) -> set[int]: """ host_ports = set() info = docker.inspect_container(self) - for ports in info['NetworkSettings']['Ports'].values(): - for ip_and_port in ports: - host_port = ip_and_port.get("HostPort") - if host_port: - host_ports.add(host_port) + for ports in info.get('NetworkSettings', {}).get('Ports', {}).values(): + if ports: + for ip_and_port in ports: + host_port = ip_and_port.get("HostPort") + if host_port: + host_ports.add(host_port) return host_ports def is_running(self, docker, ping_url: Callable[[int], str]) -> bool: