Correct an issue when containers ports as no destination

This commit is contained in:
nicolargo 2025-11-01 15:54:30 +01:00
parent 10111cc7f6
commit bdd66c56d3
2 changed files with 12 additions and 2 deletions

View File

@ -361,6 +361,11 @@ class DockerExtension:
# Manage ports (see issue#2054)
if hasattr(container, 'ports'):
stats['ports'] = ','.join([f'{container.ports[cp][0]["HostPort"]}->{cp}' for cp in container.ports])
stats['ports'] = ','.join(
[
f'{container.ports[cp][0]["HostPort"]}->{cp}' if container.ports[cp] else f'{cp}'
for cp in container.ports
]
)
return stats

View File

@ -406,6 +406,11 @@ class PodmanExtension:
# Manage ports (see issue#2054)
if hasattr(container, 'ports'):
stats['ports'] = ','.join([f'{container.ports[cp][0]["HostPort"]}->{cp}' for cp in container.ports])
stats['ports'] = ','.join(
[
f'{container.ports[cp][0]["HostPort"]}->{cp}' if container.ports[cp] else f'{cp}'
for cp in container.ports
]
)
return stats