diff --git a/nf_core/pipelines/download/docker.py b/nf_core/pipelines/download/docker.py index 2061d0888a..77966078e8 100644 --- a/nf_core/pipelines/download/docker.py +++ b/nf_core/pipelines/download/docker.py @@ -77,8 +77,17 @@ def check_and_set_implementation(self) -> None: """ Check if Docker is installed and set the implementation. """ - if not shutil.which("docker"): + docker_binary = shutil.which("docker") + if not docker_binary: raise OSError("Docker is needed to pull images, but it is not installed or not in $PATH") + + try: + nf_core.utils.run_cmd(docker_binary, "info") + except RuntimeError: + raise OSError( + "Docker daemon is required to pull images, but it is not running or unavailable to the docker client" + ) + self.implementation = "docker" def gather_registries(self, workflow_directory: Path) -> set[str]: diff --git a/nf_core/pipelines/download/download.py b/nf_core/pipelines/download/download.py index 0a39c820b4..9b133ff877 100644 --- a/nf_core/pipelines/download/download.py +++ b/nf_core/pipelines/download/download.py @@ -494,26 +494,29 @@ def setup_container_fetcher(self) -> None: Create the appropriate ContainerFetcher object """ assert self.outdir is not None # mypy - if self.container_system == "singularity": - self.container_fetcher = SingularityFetcher( - outdir=self.outdir, - container_library=self.container_library, - registry_set=self.registry_set, - container_cache_utilisation=self.container_cache_utilisation, - container_cache_index=self.container_cache_index, - parallel=self.parallel, - hide_progress=self.hide_progress, - ) - elif self.container_system == "docker": - self.container_fetcher = DockerFetcher( - outdir=self.outdir, - registry_set=self.registry_set, - container_library=self.container_library, - parallel=self.parallel, - hide_progress=self.hide_progress, - ) - else: - self.container_fetcher = None + try: + if self.container_system == "singularity": + self.container_fetcher = SingularityFetcher( + outdir=self.outdir, + container_library=self.container_library, + registry_set=self.registry_set, + container_cache_utilisation=self.container_cache_utilisation, + container_cache_index=self.container_cache_index, + parallel=self.parallel, + hide_progress=self.hide_progress, + ) + elif self.container_system == "docker": + self.container_fetcher = DockerFetcher( + outdir=self.outdir, + registry_set=self.registry_set, + container_library=self.container_library, + parallel=self.parallel, + hide_progress=self.hide_progress, + ) + else: + self.container_fetcher = None + except OSError as e: + raise DownloadError(e) def prompt_use_singularity(self, fail_message: str) -> None: use_singularity = questionary.confirm(