Only get stats for running containers (#3268)

This commit is contained in:
Joakim Sørensen 2021-10-26 17:43:02 +02:00 committed by GitHub
parent 5d4ce94155
commit 8458d9e0f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -528,6 +528,10 @@ class DockerInterface(CoreSysAttributes):
except (docker.errors.DockerException, requests.RequestException) as err:
raise DockerError() from err
# container is not running
if docker_container.status != "running":
raise DockerError(f"Container {self.name} is not running", _LOGGER.error)
try:
stats = docker_container.stats(stream=False)
return DockerStats(stats)