Skip to content

Commit 15a76a7

Browse files
prismofeverythingtetron
authored andcommitted
Allow the disabling of the network inside a docker container, and add the ability to provide a default docker container if one is not specified (#207)
Reversed --enable-net flag to --disable-net, since network has been enabled this whole time and we don't want to surprise anyone, and added a --default-container flag to force use of a docker container if one is not declared in the workflow
1 parent 083a2dd commit 15a76a7

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

cwltool/job.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ def run(self, dry_run=False, pull_image=True, rm_container=True,
8787
if docker_req and kwargs.get("use_container") is not False:
8888
env = os.environ
8989
img_id = docker.get_from_requirements(docker_req, docker_is_req, pull_image)
90+
elif kwargs.get("default_container", None) is not None:
91+
env = os.environ
92+
img_id = kwargs.get("default_container")
9093

9194
if docker_is_req and img_id is None:
9295
raise WorkflowException("Docker is required for running this tool.")
@@ -106,11 +109,11 @@ def run(self, dry_run=False, pull_image=True, rm_container=True,
106109
runtime.append(u"--volume=%s:%s:rw" % (os.path.realpath(self.tmpdir), "/tmp"))
107110
runtime.append(u"--workdir=%s" % ("/var/spool/cwl"))
108111
runtime.append("--read-only=true")
109-
if (kwargs.get("enable_net", None) is None and
110-
kwargs.get("custom_net", None) is not None):
111-
runtime.append("--net=none")
112-
elif kwargs.get("custom_net", None) is not None:
112+
113+
if kwargs.get("custom_net", None) is not None:
113114
runtime.append("--net={0}".format(kwargs.get("custom_net")))
115+
elif kwargs.get("disable_net", None):
116+
runtime.append("--net=none")
114117

115118
if self.stdout:
116119
runtime.append("--log-driver=none")

cwltool/main.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,11 @@ def arg_parser(): # type: () -> argparse.ArgumentParser
154154
help="Allow loading and running development versions "
155155
"of CWL spec.", default=False)
156156

157-
parser.add_argument("--enable-net", action="store_true",
157+
parser.add_argument("--default-container",
158+
help="Specify a default docker container that will be used if the workflow fails to specify one.")
159+
parser.add_argument("--disable-net", action="store_true",
158160
help="Use docker's default networking for containers;"
159-
" the default is to disable networking.")
161+
" the default is to enable networking.")
160162
parser.add_argument("--custom-net", type=Text,
161163
help="Will be passed to `docker run` as the '--net' "
162164
"parameter. Implies '--enable-net'.")

0 commit comments

Comments
 (0)