dagger/dagger · error
failed to create temp file
Error message
failed to create temp file
What it means
When the local mounter wraps a single file (isFile), it writes an empty placeholder file inside the freshly created temp dir so the file can be bind-mounted; failure to create that file aborts Mount and cleans up the temp dir. The cause is the wrapped os.WriteFile error.
Source
Thrown at engine/snapshots/localmounter_linux.go:70
}
if !fi.IsDir() {
isFile = true
}
}
lm.overlayIncompatDirs = fsdiff.VolatileIncompatDirs(lm.mounts)
dest, err := os.MkdirTemp("", "dagger-mount")
if err != nil {
return "", errors.Wrap(err, "failed to create temp dir")
}
lm.tmpDir = dest
if isFile {
dest = filepath.Join(dest, "file")
if err := os.WriteFile(dest, []byte{}, 0o644); err != nil {
os.RemoveAll(lm.tmpDir)
return "", errors.Wrap(err, "failed to create temp file")
}
}
if err := mount.All(lm.mounts, dest); err != nil {
os.RemoveAll(lm.tmpDir)
return "", errors.Wrapf(err, "failed to mount %s: %+v", dest, lm.mounts)
}
lm.target = dest
return dest, nil
}
func (lm *localMounter) Unmount() error {
lm.mu.Lock()
defer lm.mu.Unlock()
if lm.target != "" {
if err := mount.Unmount(lm.target, 0); err != nil {
return errView on GitHub (pinned to 82ba2681db)
Solutions
- Free space on the filesystem backing TMPDIR
- Ensure TMPDIR is writable and not read-only mounted
- Check LSM/permission policies for the process user
- Inspect the wrapped os.WriteFile error for the exact errno
Example fix
// before TMPDIR=/readonly-tmp dagger ... // after export TMPDIR=$(mktemp -d) # writable location dagger ...
Defensive patterns
Strategy: validation
Validate before calling
probe, err := os.CreateTemp(os.TempDir(), "dagger-probe")
if err != nil {
return fmt.Errorf("cannot write to temp dir: %w", err)
}
probe.Close(); os.Remove(probe.Name()) Try / catch
dir, err := lm.Mount()
if err != nil && strings.Contains(err.Error(), "failed to create temp file") {
return fmt.Errorf("temp filesystem not writable or full: %w", err)
} Prevention
- Ensure the temp filesystem has free space for single-file mounts
- Avoid read-only tmpfs for TMPDIR
- Check LSM policies allow the engine user to create files in /tmp
When it happens
Trigger: Mounting a single host file where the temp dir's filesystem rejects the write: ENOSPC, read-only tmpfs, or permission/ACL restrictions on the dagger-mount temp directory.
Common situations: Disk-full /tmp; containers with read-only rootfs; security policies (SELinux) denying file creation in /tmp.
Related errors
- remount container: %w
- failed to create stable ID temp file: %w
- create checkout pack spool: %w
- finish checkout pack spool: %w
- create uncommitted pack spool: %w
AI-assisted analysis of dagger/dagger@82ba2681db (2026-09-05).
Data as JSON: /api/errors/1f8b520e5413ae2a.
Report an issue: GitHub.