From 871e8a127dcc4bdddfdb736c92fd90921cb25a05 Mon Sep 17 00:00:00 2001 From: Einar Forselv Date: Sun, 14 Apr 2019 01:35:45 +0200 Subject: [PATCH] Container spawner mockup --- restic-backup/runner.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 restic-backup/runner.py diff --git a/restic-backup/runner.py b/restic-backup/runner.py new file mode 100644 index 0000000..f5c5031 --- /dev/null +++ b/restic-backup/runner.py @@ -0,0 +1,25 @@ +import os +import docker + + +client = docker.Client(base_url=DOCKER_BASE_URL) + +container = client.containers.run( + 'image', + 'command', + labels={"restic-volume-backup.process": True}, + auto_remove=True, + remove=True, + detach=True, + environment={ + 'test1': 'value1', + 'test2': 'value2', + }, + volumes={ + '/home/user1/': {'bind': '/mnt/vol2', 'mode': 'rw'}, + '/var/www': {'bind': '/mnt/vol1', 'mode': 'ro'}, + }, + working_dir=os.getcwd(), +) + +# Pull logs and exist status of container