2019-04-17 01:28:07 +00:00
|
|
|
import os
|
|
|
|
import docker
|
|
|
|
|
|
|
|
from restic_volume_backup.config import Config
|
|
|
|
|
|
|
|
def run():
|
2019-04-17 01:45:51 +00:00
|
|
|
config = Config()
|
|
|
|
client = docker.DockerClient(base_url=config.docker_base_url)
|
2019-04-17 01:28:07 +00:00
|
|
|
|
|
|
|
container = client.containers.run(
|
2019-04-17 01:45:51 +00:00
|
|
|
'restic-volume-backup_backup',
|
|
|
|
'echo "Hello"',
|
|
|
|
labels={"restic-volume-backup.backup_process": 'True'},
|
2019-04-17 01:28:07 +00:00
|
|
|
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
|