Docker tmpfs mounts: temporary working data
Lab prerequisites
Use only an approved disposable, offline Linux VM with a local Docker Engine, ordinary local volume driver, and reviewed preloaded busybox:1.37 (record its digest, platform, exact Engine version and required utilities first). Verify the active Docker context and endpoint; every bm-v06 resource name in the lesson must be unused before starting. Never reuse a pre-existing volume. Use a dedicated lab shell, run commands individually in order, and stop on unexpected errors (the explicitly labeled negative tests are exceptions). Only delete resources you created after confirming their identity. All outputs are expected, not observed; these are manual labs, not ByteMind runnable editors. Before contacting the Engine, verify the effective local endpoint including DOCKER_HOST, DOCKER_CONTEXT and CLI overrides. Recheck the approved local image ID and native platform; if the recorded digest is unavailable, report it as unknown rather than inventing one. Use owner-set resource and time limits. If prerequisites cannot be confirmed, do the paper exercise instead. Check that the approved fixture has no declared image volumes and that the synthetic destinations and file names are unused. The bind-mount lesson alone uses a fresh host directory; do not extend it to other paths.
Scratch space instead of storage
Use tmpfs for intermediate results that may be discarded, such as a small parser scratch file. Linux backs tmpfs with memory, potentially including swap; it is not a promise that data never touches disk. Specify a small maximum size rather than consuming memory without a plan. The size limit is not additional RAM and is not a reservation.
Observe a stop boundary
This Linux-only fixture starts a short foreground command, keeps the container object after exit, and mounts /scratch with a 1 MiB maximum. On the first run the scratch file is created. When the process exits, the container stops and that tmpfs disappears. Starting the same container again should print fresh again, unlike the writable-layer example.
docker run --pull=never --network none --name bm-v06-scratch --mount type=tmpfs,dst=/scratch,tmpfs-size=1048576 busybox:1.37 sh -c 'if [ -f /scratch/note ]; then printf "old\n"; else printf "fresh\n"; printf "temporary\n" > /scratch/note; fi'docker start -a bm-v06-scratchInspect and clean up
Inspect the stored mount request without relying on the live mount being available after the container stops. Then remove only the stopped lab container. A tmpfs is unsuitable for a database that needs records after restart. Do not test the size boundary by exhausting memory. A saved mount specification is not evidence that the file is currently mounted. Record fresh on both runs and their exit statuses; do not infer swap behavior from this test.
docker inspect --format '{{json .HostConfig.Mounts}}' bm-v06-scratchdocker rm bm-v06-scratchManual practice
Classify three files: a temporary parser buffer, a saved customer record, and a developer-edited settings file. Choose tmpfs, volume or bind mount and justify each.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Docker tmpfs mounts: temporary working data — Knowledge check
Apply the concepts from this lesson.
Which storage is suited to disposable scratch files that should disappear on stop?
Can tmpfs data ever be written to swap?
Does tmpfs-size reserve that amount of extra RAM?