diff --git a/cwltool/docker.py b/cwltool/docker.py index 7e7c93507..62b83ca9a 100644 --- a/cwltool/docker.py +++ b/cwltool/docker.py @@ -236,7 +236,7 @@ def add_file_or_directory_volume( """Append volume a file/dir mapping to the runtime option list.""" if not volume.resolved.startswith("_:"): _check_docker_machine_path(volume.resolved) - self.append_volume(runtime, volume.resolved, volume.target) + self.append_volume(runtime, volume.resolved, volume.target, writable=volume.staged) def add_writable_file_volume( self, diff --git a/cwltool/job.py b/cwltool/job.py index 4011641cd..bc926d533 100644 --- a/cwltool/job.py +++ b/cwltool/job.py @@ -100,12 +100,23 @@ def relink_initialworkdir( continue host_outdir_tgt = os.path.join(host_outdir, vol.target[len(container_outdir) + 1 :]) if os.path.islink(host_outdir_tgt) or os.path.isfile(host_outdir_tgt): + try: + ensure_writable(host_outdir_tgt, include_root=True) + except PermissionError: + pass try: os.remove(host_outdir_tgt) except PermissionError: pass elif os.path.isdir(host_outdir_tgt) and not vol.resolved.startswith("_:"): - shutil.rmtree(host_outdir_tgt) + try: + ensure_writable(host_outdir_tgt, include_root=True) + except PermissionError: + pass + try: + shutil.rmtree(host_outdir_tgt) + except PermissionError: + pass if not vol.resolved.startswith("_:"): try: os.symlink(vol.resolved, host_outdir_tgt)