From 2884fc1eec2ec0f0fc2da9dea02e0bf610b8b04d Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Mon, 15 Apr 2019 19:49:57 +0200 Subject: [PATCH] Make docker URI part of config --- restic_volume_backup/config.py | 1 + restic_volume_backup/containers.py | 1 - restic_volume_backup/utils.py | 6 +++++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/restic_volume_backup/config.py b/restic_volume_backup/config.py index c885c72..e26ed6c 100644 --- a/restic_volume_backup/config.py +++ b/restic_volume_backup/config.py @@ -4,6 +4,7 @@ import os class Config: repository = os.environ['RESTIC_REPOSITORY'] password = os.environ['RESTIC_PASSWORD'] + docker_base_url = os.environ.get('DOCKER_BASE_URL') or "unix://tmp/docker.sock" @classmethod def check(cls): diff --git a/restic_volume_backup/containers.py b/restic_volume_backup/containers.py index 4886a34..7b140fe 100644 --- a/restic_volume_backup/containers.py +++ b/restic_volume_backup/containers.py @@ -5,7 +5,6 @@ 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" diff --git a/restic_volume_backup/utils.py b/restic_volume_backup/utils.py index e100f13..f6d3406 100644 --- a/restic_volume_backup/utils.py +++ b/restic_volume_backup/utils.py @@ -1,8 +1,12 @@ import docker +import pprint + +from restic_volume_backup.config import Config def list_containers(): - client = docker.Client(base_url=DOCKER_BASE_URL) + client = docker.Client(base_url=Config.docker_base_url) all_containers = client.containers() + pprint.pprint(all_containers, indent=2) client.close() return all_containers