Skip to content

Commit bee7d93

Browse files
authored
Fail if expecting to run in Docker but not available. (#307)
* Fail if expecting to run in Docker but not available. * Try to improve error handling when Docker is not available to run job in container.
1 parent dd3f90a commit bee7d93

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

cwltool/job.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,22 @@ def run(self, dry_run=False, pull_image=True, rm_container=True,
135135

136136
img_id = None
137137
env = None # type: Union[MutableMapping[Text, Text], MutableMapping[str, str]]
138-
if docker_req and kwargs.get("use_container") is not False:
139-
env = os.environ
140-
img_id = docker.get_from_requirements(docker_req, docker_is_req, pull_image)
141-
elif kwargs.get("default_container", None) is not None:
142-
env = os.environ
143-
img_id = kwargs.get("default_container")
144-
145-
if docker_is_req and img_id is None:
146-
raise WorkflowException("Docker is required for running this tool.")
138+
try:
139+
if docker_req and kwargs.get("use_container") is not False:
140+
env = os.environ
141+
img_id = docker.get_from_requirements(docker_req, True, pull_image)
142+
elif kwargs.get("default_container", None) is not None:
143+
env = os.environ
144+
img_id = kwargs.get("default_container")
145+
146+
if docker_req and img_id is None and kwargs.get("use_container"):
147+
raise Exception("Docker image not available")
148+
except Exception as e:
149+
_logger.debug("Docker error", exc_info=True)
150+
if docker_is_req:
151+
raise WorkflowException("Docker is required to run this tool: %s" % e)
152+
else:
153+
raise WorkflowException("Docker is not available for this tool, try --no-container to disable Docker: %s" % e)
147154

148155
if img_id:
149156
runtime = ["docker", "run", "-i"]

0 commit comments

Comments
 (0)