Skip to content

Containerized processes fail exit 126: nf-spawn's docker run can't reach the Docker socket (task user not in docker group) #92

Closed

Description

@scttfrdmn

Every containerized process fails exit 126 — nf-spawn's docker run on the task instance can't reach the Docker socket

Running a real DAG (5 processes, each with a pinned container, executor = 'spawn', S3 workDir) on Graviton: every process fails immediately with exit 126 and empty output.

.command.err in the S3 work dir:

docker: permission denied while trying to connect to the Docker daemon socket at
unix:///var/run/docker.sock: ... connect: permission denied.

Diagnosis. nf-spawn runs the process's container via docker run on the task instance (ext.ensureDocker=true installs Docker). But that docker run is invoked as a task user that is not in the docker group, so it can't reach /var/run/docker.sock. Confirmed it's nf-spawn's own invocation, not Nextflow's: the docker command does not appear in .command.run, and setting docker { enabled = true; sudo = true } in nextflow.config (which would make Nextflow's docker use sudo) had no effect — the failure is in nf-spawn's dispatch layer.

Repro: any process with a container directive under executor = 'spawn' on a stock AMI (ext.ensureDocker=true). Both a MAFFT and a MUSCLE process failed identically (exit 126) across two runs.

Workaround that works (documented in our recipe as an honest mitigation, not a fix): loosen the socket on the ephemeral single-use instance via the ext.setup hook, which runs after Docker install and before the task with sudo:

process { ext.setup = 'sudo chmod 666 /var/run/docker.sock' }

With that, the same 5-process DAG ran clean (completed=5, all .exitcode==0, outputs landed in S3).

Suggested fix: nf-spawn should run its docker run with sudo (stock cloud AMIs give the instance user passwordless sudo), or add the task user to the docker group during ensureDocker setup in a way that takes effect for the task shell, or run the container as spawn's provisioning does. As shipped, no containerized pipeline runs on a stock AMI without the socket workaround.

Secondary observation (worth a look): instances did not promptly self-terminate. A failed task's instance (exit 126) was still running after the pipeline aborted (I terminated it manually; TTL would eventually reap it), and even a completed task's instance lingered ~1-2 min post-completion. At DAG scale (N instances, N lifecycles) the terminate discipline is worth verifying explicitly rather than assuming — a workflow that fails to signal completion on one branch is how a stranded instance would happen.

Found building the first Shape-F recipe for scientific-codes-cookbook on Graviton (nf-spawn v0.10.0 → installs as 0.8.0, see #91). The DAG itself works once the socket is reachable.

Activity

  1. scttfrdmn commented on Sep 5, 2026

    @scttfrdmn
    CollaboratorAuthor

    To be explicit about severity and ownership: this is a blocker, not a rough edge — with a container directive under executor = 'spawn' on a stock AMI, no pipeline runs out of the box; every process fails exit 126 with a confusing Docker-socket error that doesn't obviously point at nf-spawn. The ext.setup socket-chmod is a user-side mitigation on the ephemeral instance, not a fix — the fix belongs in the executor (run nf-spawn's docker run with sudo, or make the task user's docker-group membership effective for the task shell). Flagging because a first-time nf-spawn user hits this wall immediately.

  2. scttfrdmn commented on Sep 5, 2026

    @scttfrdmn
    CollaboratorAuthor

    Verified fixed in v0.10.1 — externally, by dropping the workaround rather than reading the changelog. Removed the ext.setup = 'sudo chmod 666 /var/run/docker.sock' mitigation entirely and re-ran the 5-process DAG on 0.10.1: completed=5, failed=0, zero docker: permission denied in any .command.err, all five .exitcode=0. So the executor now reaches the socket on its own. Thanks for the fast turnaround. (Filed #96 separately for the instance-termination behavior at DAG scale, which is unrelated to this and still present.)

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions