From c860132cbb21dd25c870232f4eac1b146c3ea2d8 Mon Sep 17 00:00:00 2001 From: Rowan Wookey Date: Wed, 11 Jun 2025 10:44:28 +0100 Subject: [PATCH] Fixed bugs in docker plugin * Fixed typo in docs * Fixed not running containers not appearing in all containers * Fixed excluding containers not working on docker_size --- plugins/docker/docker_ | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/docker/docker_ b/plugins/docker/docker_ index 7dd69c6d..92a3ced3 100755 --- a/plugins/docker/docker_ +++ b/plugins/docker/docker_ @@ -127,7 +127,7 @@ class ClientWrapper: and support caching. In addition, when the exclude_re parameter is not None, - any container which name is matched by the RE will not be excluded from reports. + any container which name is matched by the RE will be excluded from reports. """ client = None exclude = None @@ -146,7 +146,7 @@ class ClientWrapper: def all_containers(self): return [ c for c in self.client.containers.list(all=True) - if (c.status == 'running') and (not self.exclude or not self.exclude.search(c.name)) + if not self.exclude or not self.exclude.search(c.name) ] @cached_property @@ -281,6 +281,8 @@ def parallel_container_stats(client): proc_list = [] stats = {} for container in client.all_containers: + if container.status != 'running': + continue q = Queue() p = Process(target=get_container_stats, args=(container, q)) proc_list.append({'proc': p, 'queue': q, 'container': container}) @@ -292,7 +294,11 @@ def parallel_container_stats(client): def print_containers_size(client): + include_containers = [container.id for container in client.all_containers] for container in client.api.df()['Containers']: + # exclude containers not in all_containers + if container['Id'] not in include_containers: + continue size = container['SizeRw'] if 'SizeRw' in container else 0 # first char of name is always / so we skip it clean_container_name = clean_fieldname(container['Names'][0][1:])