|
28 | 28 |
|
29 | 29 | found_images = set() # type: Set[Text]
|
30 | 30 | found_images_lock = threading.Lock()
|
| 31 | +__docker_machine_mounts = None # type: List[Text] |
| 32 | +__docker_machine_mounts_lock = threading.Lock() |
| 33 | + |
| 34 | +def _get_docker_machine_mounts(): # type: () -> List[Text] |
| 35 | + global __docker_machine_mounts |
| 36 | + if __docker_machine_mounts is None: |
| 37 | + with __docker_machine_mounts_lock: |
| 38 | + if 'DOCKER_MACHINE_NAME' not in os.environ: |
| 39 | + __docker_machine_mounts = [] |
| 40 | + else: |
| 41 | + __docker_machine_mounts = [u'/' + line.split(None, 1)[0] |
| 42 | + for line in subprocess.check_output( |
| 43 | + ['docker-machine', 'ssh', |
| 44 | + os.environ['DOCKER_MACHINE_NAME'], |
| 45 | + 'mount', '-t', 'vboxsf'], |
| 46 | + universal_newlines=True).splitlines()] |
| 47 | + return __docker_machine_mounts |
| 48 | + |
| 49 | +def _check_docker_machine_path(path): # type: (Text) -> None |
| 50 | + mounts = _get_docker_machine_mounts() |
| 51 | + if mounts: |
| 52 | + found = False |
| 53 | + for mount in mounts: |
| 54 | + if path.startswith(mount): |
| 55 | + found = True |
| 56 | + break |
| 57 | + if not found: |
| 58 | + raise WorkflowException( |
| 59 | + "Input path {path} is not in the list of host paths mounted " |
| 60 | + "into the Docker virtual machine named {name}. Already mounted " |
| 61 | + "paths: {mounts}.\n" |
| 62 | + "See https://docs.docker.com/toolbox/toolbox_install_windows/#optional-add-shared-directories" |
| 63 | + " for instructions on how to add this path to your VM.".format(path=path, |
| 64 | + name=os.environ["DOCKER_MACHINE_NAME"], mounts=mounts)) |
| 65 | + |
31 | 66 |
|
32 | 67 | class DockerCommandLineJob(ContainerCommandLineJob):
|
33 | 68 |
|
@@ -162,6 +197,8 @@ def add_volumes(self, pathmapper, runtime, secret_store=None):
|
162 | 197 | host_outdir_tgt = None
|
163 | 198 | if vol.type in ("File", "Directory"):
|
164 | 199 | if not vol.resolved.startswith("_:"):
|
| 200 | + _check_docker_machine_path(docker_windows_path_adjust( |
| 201 | + vol.resolved)) |
165 | 202 | runtime.append(u"--volume=%s:%s:ro" % (
|
166 | 203 | docker_windows_path_adjust(vol.resolved),
|
167 | 204 | docker_windows_path_adjust(vol.target)))
|
|
0 commit comments