Upgrade to recent docker client

This commit is contained in:
Einar Forselv 2019-04-17 03:45:51 +02:00
parent 197cc16b01
commit 7a647c06b7
4 changed files with 12 additions and 11 deletions

View File

@ -4,12 +4,13 @@ import docker
from restic_volume_backup.config import Config
def run():
client = docker.Client(base_url=DOCKER_BASE_URL)
config = Config()
client = docker.DockerClient(base_url=config.docker_base_url)
container = client.containers.run(
'image',
'command',
labels={"restic-volume-backup.backup_process": True},
'restic-volume-backup_backup',
'echo "Hello"',
labels={"restic-volume-backup.backup_process": 'True'},
auto_remove=True,
remove=True,
detach=True,

View File

@ -3,6 +3,8 @@ import sys
from restic_volume_backup.config import Config
from restic_volume_backup.containers import RunningContainers
from restic_volume_backup import backup_runner
from restic_volume_backup import restic
def main():
@ -22,17 +24,15 @@ def main():
print()
elif args.mode == 'backup':
elif args.action == 'backup':
print("Starting backup ..")
# TODO: Errors when repo already exists
# restic.init_repo(Config.repository)
restic.init_repo(config.repository)
backup_runner.run()
# for vol in containers.backup_volumes():
# restic.backup_volume(Config.repository, vol)
elif args.mode == 'snapshots':
restic.snapshots(config.repository)
def parse_args():
parser = argparse.ArgumentParser(prog='restic_volume_backup')

View File

@ -6,7 +6,7 @@ from restic_volume_backup.config import Config
def list_containers():
"""Easily mockable container list"""
config = Config()
client = docker.Client(base_url=config.docker_base_url)
client = docker.APIClient(base_url=config.docker_base_url)
all_containers = client.containers()
client.close()
return all_containers

View File

@ -8,7 +8,7 @@ setup(
author_email="eforselv@gmail.com",
packages=find_namespace_packages(include=['restic_volume_backup']),
install_requires=[
'docker-py==1.10.6',
'docker==3.7.2',
],
entry_points={'console_scripts': [
'restic-volume-backup = restic_volume_backup.cli:main',