From f0d38fb7f40e01904bc3f788b7c29545f0c9fab2 Mon Sep 17 00:00:00 2001 From: Jay Turner Date: Tue, 27 Jun 2023 12:51:40 +0100 Subject: [PATCH 1/2] Add health property to Containers model Signed-off-by: Jay Turner --- docker/models/containers.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docker/models/containers.py b/docker/models/containers.py index 2eeefda1e..6febb19eb 100644 --- a/docker/models/containers.py +++ b/docker/models/containers.py @@ -62,6 +62,13 @@ def status(self): return self.attrs['State']['Status'] return self.attrs['State'] + @property + def health(self): + """ + The healthcheck status of the container. For example, ``healthy`, or ``unhealthy`. + """ + return self.attrs.get('State', {}).get('Health', {}).get('Status', 'unknown') + @property def ports(self): """ From b2378db7f174fee78f67748308b3c98855454d68 Mon Sep 17 00:00:00 2001 From: Milas Bowman Date: Mon, 20 Nov 2023 16:18:08 -0500 Subject: [PATCH 2/2] chore: fix lint issue Signed-off-by: Milas Bowman --- docker/models/containers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker/models/containers.py b/docker/models/containers.py index f8aeb39b1..4725d6f6f 100644 --- a/docker/models/containers.py +++ b/docker/models/containers.py @@ -66,7 +66,9 @@ def status(self): @property def health(self): """ - The healthcheck status of the container. For example, ``healthy`, or ``unhealthy`. + The healthcheck status of the container. + + For example, ``healthy`, or ``unhealthy`. """ return self.attrs.get('State', {}).get('Health', {}).get('Status', 'unknown')