Course contentsShow
← Cloud and Infrastructure
Lesson 1039 of 2,98920. Docker in DepthFree lesson

tmpfs Mounts

Learn tmpfs mounts for storing sensitive data in memory without writing to host or container filesystem.

tmpfs Mounts

What you'll learn: How to use tmpfs mounts to store sensitive data in memory, bypassing the filesystem entirely.


What is a tmpfs Mount?

A tmpfs mount is a special type of Docker mount that stores data directly in your host machine's memory (RAM), never writing to the host's filesystem or the container's writable layer. When the container stops, all data in the tmpfs mount disappears completely.

Think of it like a whiteboard in a spy movie: you write sensitive information on it during a mission, and once you're done, you wipe it clean—no trace left behind.


Why Use tmpfs Mounts?

Unlike volumes (persistent, stored on disk) and bind mounts (mapped to host directories), tmpfs mounts are ideal for:

  • Sensitive data: Passwords, API keys, temporary tokens
  • Performance: Memory access is faster than disk I/O
  • Security: Data never touches disk, reducing forensic traces
  • Temporary state: Session data, cache, build artifacts you don't need to keep

How tmpfs Mounts Work

When you create a tmpfs mount:

  1. Docker allocates a portion of the host's RAM
  2. The container sees it as a regular directory
  3. All writes go to memory, not disk
  4. When the container stops, the memory is freed and data vanishes

You can only use tmpfs mounts on Linux hosts (not Windows or Mac Docker Desktop in certain configurations), and you must set size limits to prevent consuming all system memory.


Key Takeaway:
tmpfs mounts store data in memory, not on disk—perfect for sensitive or temporary data that should vanish when your container stops.