Interview Q&A / Docker & Kubernetes

IntermediateQuick answer1 min readUpdated 3 Oct 2026

What is a tmpfs mount in Docker and when would you use it?

SHORT ANSWER

A tmpfs mount stores data in the host's memory only, never on disk, and it vanishes when the container stops. It suits temporary or sensitive scratch data and fast temporary files.

Explain it simply

A tmpfs mount is a whiteboard in the exam hall: fast to write on, never saved, wiped when the session ends.

The data lives in RAM (or swap), so reads and writes are quick and nothing is left on the disk afterwards. Use it for caches, session scratch files, or decrypted secrets you do not want written to storage. Because it is memory, a large tmpfs eats into available RAM, so set a size limit. It works only on Linux hosts and cannot be shared between containers.

It is often paired with a read-only root filesystem: the container cannot write anywhere except the tmpfs path, such as /tmp, which reduces what an attacker can change.

Example

bash
docker run -d --tmpfs /tmp:rw,size=64m nginx
# or with --mount
docker run -d --mount type=tmpfs,destination=/cache,tmpfs-size=67108864 nginx
docker run -d --read-only --tmpfs /tmp nginx

What to say in the interview

"tmpfs mounts keep data in memory only and discard it when the container stops. I use them for temporary or sensitive scratch data, set a size limit, and often combine them with --read-only."

Common mistakes

  • Using tmpfs for data that must survive a restart.

#docker#volumes#tmpfs

Related questions

Practise more Docker & Kubernetes questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Docker & Kubernetes quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.