Skip to content

container directive ignored — task script runs on OS, not inside Docker/Singularity #30

Closed

Description

@scttfrdmn

Summary

When a process has a container directive (e.g. container 'community.wave.seqera.io/library/sra-tools_pigz:...'), nf-spawn's staging script runs the task script directly on the OS rather than inside the specified container. Tools that only exist in the container (e.g. fasterq-dump) are not found.

Evidence

.command.sh: line 9: fasterq-dump: command not found

The container directive is set in the Nextflow process; the tool exists in the container image but not on the host OS.

Expected

nf-spawn's buildStagingScript() should wrap the task execution in docker run (or singularity exec) when task.container is set, the same way the AWS Batch executor does.

Roughly:

if task.container is set:
    docker run --rm \
        -v ${LOCAL_DIR}:/work -w /work \
        ${task.container} \
        bash .command.sh
else:
    bash .command.sh
fi

Workaround

Invoke Docker explicitly in the task script:

script:
"""
docker run --rm -v \$(pwd):/work -w /work ${container_image} \\
    fasterq-dump ...
"""

This is brittle — it defeats the purpose of the container directive.

Context

Activity

  1. added
    bug
    on Jun 5, 2026
  2. scttfrdmn commented on Jun 9, 2026

    @scttfrdmn
    CollaboratorAuthor

    Concrete failure from nf-core/taxprofiler

    With nf-spawn 0.2.7 and spawn 0.37.2, FETCH_FASTQ (custom process with explicit Docker invocation in the script body) works end-to-end. But when nf-core/taxprofiler processes run, every process fails because the tools aren't on the OS:

    .command.sh: line 7: fastqc: command not found
    

    The taxprofiler FASTQC process has container 'biocontainers/fastqc:0.12.1--hdfd78af_0' in its module definition. nf-spawn ignores this and runs the script on the bare OS — which doesn't have fastqc, fastp, kraken2, etc.

    This blocks using nf-spawn as the executor for any nf-core pipeline. The workaround (explicit docker run in the script body) only works for custom processes we control, not the ~50 nf-core module processes in taxprofiler.

    What's needed

    When nf-spawn launches a task instance, it needs to:

    1. Detect that container is set on the process
    2. Wrap the task script in docker run --rm -v $workdir:/work -w /work <container> bash .command.sh
    3. Ensure Docker is available on the instance (it is — Docker is pre-installed on the AMI)

    Or alternatively: honour Nextflow's existing Docker executor configuration (docker.enabled = true) so the generated .command.run script handles the container invocation as it does for local/slurm executors.

    Context

  3. added a commit that references this issue on Jun 9, 2026
  4. scttfrdmn commented on Jun 9, 2026

    @scttfrdmn
    CollaboratorAuthor

    Fixed in #36, released as v0.2.8. When a process has a container directive, the task now runs inside that image via docker run --rm -v ${LOCAL_DIR}:${LOCAL_DIR} -w ${LOCAL_DIR} <image> bash .command.sh (work dir bind-mounted at the same path + set as cwd; exit code propagated). No container → unchanged bare-OS run. This unblocks nf-core pipelines — worth a taxprofiler rerun on v0.2.8 to confirm FASTQC/FASTP/KRAKEN2 etc. run instead of command not found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions