[RFE] --in-memory flag for ephemeral tmpfs-backed storage
Feature request description
Is your feature request related to a problem? Please describe.
Running container builds and test suites on disk-based storage causes significant SSD wear. DRAM prices rose 90–95% in Q1 2026, and consumer SSD prices rose 35–40% in Q2, making unnecessary hardware degradation a concrete economic concern for developers and CI pipelines.
A single NVMe drive with ~600 TBW endurance can lose a measurable percentage of its lifespan in just a few days of intensive container development. For example, in a recent heavy build and test cycle, my NVMe logged 23.6 TB of physical writes in 56 hours—consuming roughly 4% of the drive's total lifespan in less than 3 days.
This problem is compounded by write amplification in overlay filesystems. While native overlayfs is the preferred driver on modern kernels, rootless Podman falls back to fuse-overlayfs on systems where native overlay is unavailable (e.g., graphroot on filesystems without overlay support, or incomplete subuid/subgid configuration). In both cases, overlay drivers amplify writes by copying files between layers: a build that logically modifies 2 GB can generate tens of gigabytes of physical disk writes. Native overlayfs improves execution speed, but it does not eliminate write amplification or physical flash wear.
Suggest potential solution
Describe the solution you'd like
A native, high-level flag --in-memory for podman run and podman build that uses a temporary, memory-backed filesystem (tmpfs) for the container's storage root and writable layer.
Proposed UX:
podman run --in-memory --in-memory-size=16g my_image
podman build --in-memory -t my_image .
### Have you considered any alternatives?
1. **`--tmpfs /path`**: Mounts a tmpfs volume inside the container, but does not alter the storage backend. Container root, image pulls, intermediate layers, and build operations still write directly to disk.
2. **`--transient-storage`** (Podman 4.4+): Excellent for state/metadata I/O reduction, but leaves heavy container data and layer writes on disk.
3. **Manual `--root` / `--runroot` pointing to `/dev/shm`**: Works, but requires manual tmpfs creation, permission/unshare handling (`podman unshare`), and complex wrapper scripts. It lacks a clean, native user experience.
4. **In-memory volumes**: Useful for specific data mount points, but does not cover the container's root filesystem or build context.
### Additional context
I have validated this concept using a custom script that automates `--root /dev/shm/podman-storage --runroot /dev/shm/podman-run`.
**Real-world benchmark results:**
- **First build (cold cache):**
- *On disk (fuse-overlayfs):* several minutes, with heavy write amplification.
- *In tmpfs (native overlay):* ~10 minutes (pulling base images and initial software installs in RAM), near-zero disk writes.
- **Incremental build (warm cache, one file changed):**
- *In tmpfs:* **16 seconds** (measured).
- *On disk:* Historically slower and with non-zero disk writes.
- **Disk I/O:** No container storage writes hit the physical disk during build and test cycles (only host-level execution logs touch the disk, measuring a few KB).
*Scope note:* `podman run --in-memory` would primarily involve Podman's storage handling, while `podman build --in-memory` would also require coordination with the Buildah project. I would suggest discussing both, but treating them as two separate workstreams if needed.
The use case makes sense, but the question is whether the reduction in disk writes justifies the long-term maintenance complexity this would introduce into Podman’s storage model. Tmpfs will come will own set of complexity (eg memory limits, concurrent builds, storage lifecycle and cleanup, cache reuse, image persistence, and behavior under memory pressure).
Setting --root / --runroot/ --tmpdir already enables this.
You can configure storage.conf with the graphroot/runroot paths and in containers.conf you can set the tmp_dir and volume_path paths. Since runroot and tmpdir already default to tmpfs you would just need to set the graphroot. Because the volume dir then for podman volumes default to a location under the graphroot you then likely want to set volume_path in containers.conf to a persistent location in case you use podman volumes otherwise you can ignore it.
So from a UX you just need to set a config file setting and then podman haves exactly the same cli wise and uses your tmpfs graphroot. Mounting a tmpfs on the host is trival, you could also just reuse a path under /tmp even in most cases.
AS such I do not see anything for us to add here
I tried the flags mentioned above to emulate an all 'in-RAM' Podman experience, but cleanup is throwing permission errors:
d="$(mktemp -d)" # Assumes your /tmp runs on tmpfs
chmod 700 "$d"
mkdir "$d/root" "$d/runroot" "$d/tmpdir"
podman run --rm -it --root "$d/root" --runroot "$d/runroot" --tmpdir "$d/tmpdir" --transient-store alpine
rm -fr -- "$d"
Everything seems to work fine, but the rm command throws this:
rm: cannot remove '/tmp/tmp.UI4rexF5c3/root/overlay/75f1d9657d880da5f75298e8f40e9928bb6e260c50d26f97af196845307e3064/diff/var': Permission denied rm: cannot remove '/tmp/tmp.UI4rexF5c3/root/overlay/75f1d9657d880da5f75298e8f40e9928bb6e260c50d26f97af196845307e3064/diff/usr': Permission denied rm: cannot remove '/tmp/tmp.UI4rexF5c3/root/overlay/75f1d9657d880da5f75298e8f40e9928bb6e260c50d26f97af196845307e3064/diff/tmp': Permission denied ...
Given this, I have two questions:
- Am I missing any flags (is there anything Podman is still storing on disk given the flags I passed)?
- How do I properly cleanup the tmp directory without root?