diff --git a/restic_volume_backup/containers.py b/restic_volume_backup/containers.py index c9258d0..4886a34 100644 --- a/restic_volume_backup/containers.py +++ b/restic_volume_backup/containers.py @@ -3,6 +3,8 @@ import docker import json import pprint +from restic_volume_backup import utils + DOCKER_BASE_URL = os.environ.get('DOCKER_BASE_URL') or "unix://tmp/docker.sock" VOLUME_TYPE_BIND = "bind" VOLUME_TYPE_VOLUME = "volume" @@ -121,10 +123,7 @@ class Mount: class RunningContainers: def __init__(self): - client = docker.Client(base_url=DOCKER_BASE_URL) - all_containers = client.containers() - client.close() - + all_containers = utils.list_containers() self.containers = [] self.this_container = None diff --git a/restic_volume_backup/utils.py b/restic_volume_backup/utils.py new file mode 100644 index 0000000..e100f13 --- /dev/null +++ b/restic_volume_backup/utils.py @@ -0,0 +1,8 @@ +import docker + + +def list_containers(): + client = docker.Client(base_url=DOCKER_BASE_URL) + all_containers = client.containers() + client.close() + return all_containers