podman-container-tools/podman · error

error creating temporary file: %m

Error message

error creating temporary file: %m

What it means

During pause-process creation the intermediate parent creates a temp file with mkstemp('<state_dir>/pause.pid.XXXXXX') as staging for the atomic pause.pid write (pkg/rootless/rootless_linux.c:1048-1054). Failure _exits after SIGKILLing the pause child. The errno tells the story: ENOENT when the state dir ($XDG_RUNTIME_DIR/libpod/tmp) is missing, EACCES/EROFS when not writable, ENOSPC/EDQUOT when the runtime tmpfs is full, EMFILE/ENFILE on fd exhaustion.

Source

Thrown at pkg/rootless/rootless_linux.c:1051

          if (asprintf (&tmp_file_path, "%s/pause.pid.XXXXXX", state_dir) < 0)
            {
              fprintf (stderr, "unable to print to string\n");
              kill (pid, SIGKILL);
              _exit (EXIT_FAILURE);
            }

          if (tmp_file_path == NULL)
            {
              fprintf (stderr, "temporary file path is NULL\n");
              kill (pid, SIGKILL);
              _exit (EXIT_FAILURE);
            }

          fd = mkstemp (tmp_file_path);
          if (fd < 0)
            {
              fprintf (stderr, "error creating temporary file: %m\n");
              kill (pid, SIGKILL);
              _exit (EXIT_FAILURE);
            }

          r = TEMP_FAILURE_RETRY (write (fd, pid_str, strlen (pid_str)));
          if (r < 0)
            {
              fprintf (stderr, "cannot write to file descriptor: %m\n");
              kill (pid, SIGKILL);
              _exit (EXIT_FAILURE);
            }
          close (fd);

          /* There can be another process at this point trying to configure the user namespace and the pause
           process, do not override the pid file if it already exists. */
          if (rename_noreplace (AT_FDCWD, tmp_file_path, AT_FDCWD, pause_pid_file_path) < 0)
            {
              unlink (tmp_file_path);

View on GitHub (pinned to a2409076ef)

Solutions

  1. Check space and permissions: 'df -h /run/user/$(id -u)' and 'ls -ld $XDG_RUNTIME_DIR/libpod/tmp'; free space or grow the tmpfs (logind RuntimeDirectorySize) if full
  2. Recreate the state dir if missing: 'mkdir -p $XDG_RUNTIME_DIR/libpod/tmp' with normal perms, then retry
  3. Check 'ulimit -n' and fd usage if errno was 'Too many open files'; raise the limit and retry
  4. Avoid running 'podman system reset/Clean' concurrently with other podman commands
  5. If errno is unexplained, capture 'strace -f -e trace=mkstemp,rename podman <cmd>' and report upstream

Example fix

# before
$ df -h /run/user/1000
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           1.6G  1.6G     0 100% /run/user/1000
$ podman ps
error creating temporary file: No space left on device

# after
# free tmpfs space (or raise logind RuntimeDirectoryMaxUSec/RuntimeDirectorySize), then
$ podman ps
Defensive patterns

Strategy: retry

Validate before calling

# Ensure the pause state dir exists and the runtime tmpfs has room
rt="${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"
mkdir -p "$rt/libpod/tmp" 2>/dev/null || { echo "cannot create $rt/libpod/tmp" >&2; exit 1; }
touch "$rt/libpod/tmp/.writable" && rm -f "$rt/libpod/tmp/.writable" || { echo "state dir not writable" >&2; exit 1; }
df -Pk "$rt" | awk 'NR==2 { if ($4 < 10240) { print "runtime tmpfs nearly full" > "/dev/stderr"; exit 1 } }'
podman "$@"

Try / catch

if ! podman "$@"; then
  rc=$?
  # 'error creating temporary file' is often transient (ENOSPC/EMFILE)
  df -h "${XDG_RUNTIME_DIR:-/run/user/$(id -u)}"; ulimit -n
  sleep 2   # let a concurrent system reset finish, then retry once
  podman "$@" && exit 0
  exit "$rc"
fi

Prevention

When it happens

Trigger: First rootless podman run after $XDG_RUNTIME_DIR was recreated empty (state dir absent); /run/user/<uid> tmpfs quota exhausted; another actor removed $XDG_RUNTIME_DIR/libpod/tmp mid-run ('podman system clean', manual rm); fd limit reached (EMFILE).

Common situations: Disk-full conditions on the runtime tmpfs (default size is a fraction of RAM, easily exhausted by large images in other tmpfs uses); stale or wiped XDG_RUNTIME_DIR after a session hiccup; systems with very low RLIMIT_NOFILE; races with concurrent 'podman system reset' by another terminal.

Related errors


AI-assisted analysis of podman-container-tools/podman@a2409076ef (2026-08-15). Data as JSON: /api/errors/99cbfa67a585119d. Report an issue: GitHub.