Skip to content

spawn task run: container can't write staged dirs when the image USER isn't root or uid 1000 (bioconda images are uid 57439) #555

Closed

Description

@scttfrdmn

Summary

On the spawn task run container path, staged directories are created as the
instance user but docker run is issued with no --user, so a container whose
image USER is neither root nor uid 1000 cannot write into any of them. Every
bioconda-derived image is in that category: they run as mambauser, uid
57439
. A task whose command writes its output next to its input gets EACCES,
and because the wrapper deliberately doesn't set -e, that surfaces as a
stage-out failure rather than as "your container couldn't write".

Evidence

pkg/taskproto/wrapper.go:87 — stage-in creates each destination's parent
directory as whoever runs the wrapper (the instance user, uid 1000 on AL2023),
with the default umask, so 0755:

p("mkdir -p %s\n", shQuote(dir))

pkg/taskproto/wrapper.go:233 — the container is then started with those
directories bind-mounted identity-mapped, and no --user:

p("  sudo docker run --rm %s%s%s %s\n", gpuFlag, mounts.String(), shQuote(image), quoteArgv(spec.Command))

pkg/taskproto/wrapper.go:241 containerMountDirs confirms the mounted set is
exactly path.Dir() of each input destination and each output source — i.e. the
directories a task naturally writes into are precisely the ones it can't.

The image side, verified against the live registry (quay.io/aarchbio/bwa,
digest sha256:19f0eceab80740b821be7ada082d4434acf778912aac658dd1b4c6692dd2e9ba):

$ docker run --rm quay.io/aarchbio/bwa@sha256:19f0ece... bash -c id
uid=57439(mambauser) gid=57439(mambauser) groups=57439(mambauser)

57439 is the mambaorg/micromamba default, so this applies to the whole
bioconda/conda-forge container ecosystem, not one image.

What I verified and what I didn't

Verified: the uid is 57439; the wrapper creates the dirs as the instance user;
no --user is passed. Not verified: the EACCES itself on a real instance.
I tried to reproduce locally, but Docker Desktop for macOS remaps bind-mount
ownership through its filesystem layer (the mount shows as root:root and the
write succeeds), so a mac repro proves nothing about Linux. On native Linux the
bind mount preserves host uid/gid, and uid 57439 writing into a 0755 directory
owned by uid 1000 must fail — but I'd rather flag that as inference than claim a
run I didn't do.

Suggested fix

Passing the invoking user through is the one-liner, and matches the intent that
the container is a packaging detail rather than a different security context:

p("  sudo docker run --rm --user \"$(id -u):$(id -g)\" %s%s%s %s\n", ...)

That has a cost: it breaks images that need their own USER (anything writing
into $HOME or a conda prefix at runtime). If that's too blunt, chmod 0777 on
the directories mkdir -p creates is uglier but has no such side effect — they
are throwaway staging dirs on a single-tenant ephemeral instance.

Workaround, for the docs either way

Put every input destination and output source directly in /tmp, which is 1777
on the host, so the single resulting bind mount is writable regardless of the
image's user. That's what I ended up doing, and it works — but it's a
non-obvious thing to have to discover from the generated wrapper, and the
natural /data + /work layout in examples/task-spec.json is exactly the
layout that fails.

Activity

  1. scttfrdmn commented on Sep 2, 2026

    @scttfrdmn
    ContributorAuthor

    Confirmed on a real instance: the inference held

    I filed this with the uid measured but the EACCES itself unverified, because
    Docker Desktop on macOS remaps bind-mount ownership and a mac repro proves
    nothing. Ran a deliberate probe task on a c8g.large in us-east-1 to settle it.
    It held exactly:

    == identity inside the container ==
    uid=57439(mambauser) gid=57439(mambauser) groups=57439(mambauser)
    
    == bind-mounted dirs, numeric owner (host uid:gid) and mode ==
    drwxrwxrwt. 12    0    0 /tmp
    drwxr-xr-x.  2 1000 1000 /tmp/pw/in
    drwxr-xr-x.  2    0    0 /tmp/pw/out
    
    == can uid 57439 write into each mounted dir? ==
    WRITE FAIL  /tmp/pw/out  -> /tmp/pw/out/wtest.txt: Permission denied
    WRITE FAIL  /tmp/pw/in   -> /tmp/pw/in/wtest.txt: Permission denied
    WRITE OK    /tmp
    

    Task cookbook-uidprobe-r2, image quay.io/aarchbio/bwa@sha256:19f0ece…,
    declared inputs at /tmp/pw/in/probe.txt and /tmp/probe_tmp.txt. So: a staged
    directory created by the wrapper is owned 1000:1000 mode 0755, the container
    is uid 57439, and the write fails. The /tmp control in the same run succeeded,
    which confirms the flat-/tmp workaround is load-bearing and not superstition.

    Two things the probe added that the original report missed

    1. Output-source directories are worse: they end up owned by root. The
    mkdir -p at pkg/taskproto/wrapper.go:87 iterates spec.Inputs only —

    for _, m := range spec.Inputs {
        dir := path.Dir(m.Destination)

    — so the parent of each output source is never created on the host. Docker
    then auto-creates it for the bind mount, as root: /tmp/pw/out above is
    0:0, not 1000:1000. That matters for the fix, because the --user "$(id -u)"
    suggestion in my original report would make input dirs writable and still leave
    output dirs unwritable. Whatever the fix, it has to create output-source parents
    too.

    2. Any destination outside /tmp fails at mkdir, before uid is even
    relevant.
    pkg/launcher/bootstrap.go:603 runs the wrapper unprivileged:

    su - "$LOCAL_USERNAME" -c '/tmp/spawn-command.sh' 2>&1 | tee /var/log/spawn-command.log &
    

    so mkdir -p /work/in cannot create /work at the filesystem root. From the
    console output of a first probe that used /work:

    cloud-init[2519]: mkdir: cannot create directory ‘/work’: Permission denied
    

    This means the /data + /work destination layout in examples/task-spec.json
    cannot work at all on the task path — not "works but unwritable", but fails at
    stage-in. Worth fixing the example either way.

    The failure signalling around both of these is bad enough to be its own report;
    filing separately.

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