@@ -90,9 +90,10 @@ def __init__(
9090 ) -> None :
9191 """Initialize a command line builder using the Docker software container engine."""
9292 super ().__init__ (builder , joborder , make_path_mapper , requirements , hints , name )
93+ self .docker_exec = "docker"
9394
94- @staticmethod
9595 def get_image (
96+ self ,
9697 docker_requirement : Dict [str , str ],
9798 pull_image : bool ,
9899 force_pull : bool ,
@@ -117,7 +118,7 @@ def get_image(
117118
118119 for line in (
119120 subprocess .check_output ( # nosec
120- ["docker" , "images" , "--no-trunc" , "--all" ]
121+ [self . docker_exec , "images" , "--no-trunc" , "--all" ]
121122 )
122123 .decode ("utf-8" )
123124 .splitlines ()
@@ -151,7 +152,7 @@ def get_image(
151152 if (force_pull or not found ) and pull_image :
152153 cmd = [] # type: List[str]
153154 if "dockerPull" in docker_requirement :
154- cmd = ["docker" , "pull" , str (docker_requirement ["dockerPull" ])]
155+ cmd = [self . docker_exec , "pull" , str (docker_requirement ["dockerPull" ])]
155156 _logger .info (str (cmd ))
156157 subprocess .check_call (cmd , stdout = sys .stderr ) # nosec
157158 found = True
@@ -160,7 +161,7 @@ def get_image(
160161 with open (os .path .join (dockerfile_dir , "Dockerfile" ), "w" ) as dfile :
161162 dfile .write (docker_requirement ["dockerFile" ])
162163 cmd = [
163- "docker" ,
164+ self . docker_exec ,
164165 "build" ,
165166 "--tag=%s" % str (docker_requirement ["dockerImageId" ]),
166167 dockerfile_dir ,
@@ -169,7 +170,7 @@ def get_image(
169170 subprocess .check_call (cmd , stdout = sys .stderr ) # nosec
170171 found = True
171172 elif "dockerLoad" in docker_requirement :
172- cmd = ["docker" , "load" ]
173+ cmd = [self . docker_exec , "load" ]
173174 _logger .info (str (cmd ))
174175 if os .path .exists (docker_requirement ["dockerLoad" ]):
175176 _logger .info (
@@ -203,7 +204,7 @@ def get_image(
203204 found = True
204205 elif "dockerImport" in docker_requirement :
205206 cmd = [
206- "docker" ,
207+ self . docker_exec ,
207208 "import" ,
208209 str (docker_requirement ["dockerImport" ]),
209210 str (docker_requirement ["dockerImageId" ]),
@@ -225,8 +226,8 @@ def get_from_requirements(
225226 force_pull : bool ,
226227 tmp_outdir_prefix : str ,
227228 ) -> Optional [str ]:
228- if not shutil .which ("docker" ):
229- raise WorkflowException ("docker executable is not available" )
229+ if not shutil .which (self . docker_exec ):
230+ raise WorkflowException (f" { self . docker_exec } executable is not available" )
230231
231232 if self .get_image (
232233 cast (Dict [str , str ], r ), pull_image , force_pull , tmp_outdir_prefix
@@ -341,10 +342,10 @@ def create_runtime(
341342 runtime = [user_space_docker_cmd , "--quiet" , "run" , "--nobanner" ]
342343 else :
343344 runtime = [user_space_docker_cmd , "run" ]
344- elif runtimeContext .podman :
345- runtime = ["podman" , "run" , "-i" , "--userns=keep-id" ]
346345 else :
347- runtime = ["docker" , "run" , "-i" ]
346+ runtime = [self .docker_exec , "run" , "-i" ]
347+ if runtimeContext .podman :
348+ runtime .append ("--userns=keep-id" )
348349 self .append_volume (
349350 runtime , os .path .realpath (self .outdir ), self .builder .outdir , writable = True
350351 )
@@ -460,3 +461,20 @@ def create_runtime(
460461 )
461462
462463 return runtime , cidfile_path
464+
465+
466+ class PodmanCommandLineJob (DockerCommandLineJob ):
467+ """Runs a CommandLineJob in a software container using the podman engine."""
468+
469+ def __init__ (
470+ self ,
471+ builder : Builder ,
472+ joborder : CWLObjectType ,
473+ make_path_mapper : Callable [..., PathMapper ],
474+ requirements : List [CWLObjectType ],
475+ hints : List [CWLObjectType ],
476+ name : str ,
477+ ) -> None :
478+ """Initialize a command line builder using the Podman software container engine."""
479+ super ().__init__ (builder , joborder , make_path_mapper , requirements , hints , name )
480+ self .docker_exec = "podman"
0 commit comments