Mercurial > repos > mvdbeek > docker_scriptrunner
comparison scriptrunner.py @ 4:ea796129e49b draft
planemo upload for repository https://github.com/mvdbeek/docker_scriptrunner/ commit 5461ea5e1f5c935551d37d1a888892146549dcb2
author | mvdbeek |
---|---|
date | Fri, 08 Jul 2016 17:17:30 -0400 |
parents | e1f5be390bc3 |
children | db65a7426ac7 |
comparison
equal
deleted
inserted
replaced
3:e1f5be390bc3 | 4:ea796129e49b |
---|---|
60 binds[host_path]={'bind':container_path, 'ro':ro} | 60 binds[host_path]={'bind':container_path, 'ro':ro} |
61 return binds | 61 return binds |
62 | 62 |
63 def switch_to_docker(opts): | 63 def switch_to_docker(opts): |
64 import docker #need local import, as container does not have docker-py | 64 import docker #need local import, as container does not have docker-py |
65 current_user = getpass.getuser() | |
66 user_id = os.getuid() | 65 user_id = os.getuid() |
67 group_id = os.getgid() | 66 group_id = os.getgid() |
68 docker_client=docker.Client() | 67 docker_client=docker.Client() |
69 toolfactory_path=abspath(sys.argv[0]) | 68 toolfactory_path=abspath(sys.argv[0]) |
70 binds=construct_bind(host_path=opts.script_path, ro=False) | 69 binds=construct_bind(host_path=opts.script_path, ro=False) |
82 image_exists = [ True for image in docker_client.images() if opts.docker_image in image['RepoTags'] ] | 81 image_exists = [ True for image in docker_client.images() if opts.docker_image in image['RepoTags'] ] |
83 if not image_exists: | 82 if not image_exists: |
84 docker_client.pull(opts.docker_image) | 83 docker_client.pull(opts.docker_image) |
85 container=docker_client.create_container( | 84 container=docker_client.create_container( |
86 image=opts.docker_image, | 85 image=opts.docker_image, |
87 user=current_user, | |
88 volumes=volumes, | 86 volumes=volumes, |
89 command=cmd | 87 command=cmd |
90 ) | 88 ) |
91 docker_client.start(container=container[u'Id'], binds=binds) | 89 docker_client.start(container=container[u'Id'], binds=binds) |
92 docker_client.wait(container=container[u'Id']) | 90 docker_client.wait(container=container[u'Id']) |