Container spawner mockup

This commit is contained in:
Einar Forselv 2019-04-14 01:35:45 +02:00
parent 8d93d478de
commit 871e8a127d
1 changed files with 25 additions and 0 deletions

25
restic-backup/runner.py Normal file
View File

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