Make docker URI part of config

This commit is contained in:
Einar Forselv 2019-04-15 19:49:57 +02:00
parent e441c1fe91
commit 2884fc1eec
3 changed files with 6 additions and 2 deletions

View File

@ -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):

View File

@ -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"

View File

@ -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