List all containers including non-running ones

This commit is contained in:
Einar Forselv 2019-12-08 00:26:02 +01:00
parent 6085f5fc03
commit d9e5a62458
2 changed files with 7 additions and 3 deletions

View File

@ -142,7 +142,7 @@ class Container:
@property
def is_running(self) -> bool:
"""Is the container running?"""
"""bool: Is the container running?"""
return self._state.get('Running', False)
@property
@ -326,10 +326,14 @@ class RunningContainers:
if not self.this_container:
raise ValueError("Cannot find metadata for backup container")
# Gather all containers in the current compose setup
# Gather all running containers in the current compose setup
for container_data in all_containers:
container = Container(container_data)
# We only care about running containers
if not container.is_running:
continue
# Detect running backup process container
if container.is_backup_process_container:
self.backup_process_container = container

View File

@ -16,7 +16,7 @@ def list_containers():
"""
config = Config()
client = docker.DockerClient(base_url=config.docker_base_url)
all_containers = client.containers.list()
all_containers = client.containers.list(all=True)
client.close()
return [c.attrs for c in all_containers]