Interview's MateDocker
Interview's Mate

Docker

Compose · Networking · Security · Ops

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
Docker topics
Lesson 42/ 160
03. Storage, Volumes & Data Persistence

Docker Storage Drivers (overlay2, btrfs, zfs)

Compare overlay2 defaults with btrfs/zfs drivers and when platform choice matters.

Advancedoverlay2 · btrfs3 quiz questions
Practice DevOps Q&A
In plain wordsDiagramTheoryStep by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice

In plain words

The driver belongs to the daemon host’s data layout, not to an individual Dockerfile or container image tag.

Think of it like…

A shipping company can use standard rack shelving or specialized warehouse floors; switching floor systems is not just repainting the boxes.

Where you’ve seen it

In practice, docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"} is the concrete move for this job: compare overlay2 defaults with btrfs/zfs drivers and when platform choice matters. The release is not accepted until inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup confirms the result.

Words you’ll hear

overlay2
The implementation control in docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"} for compare overlay2 defaults with btrfs/zfs drivers and when platform choice matters.
btrfs
The result to observe with inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup, rather than infer from a successful command alone.
zfs
The production boundary exposed when changing storage-driver in daemon.json and expecting old /var/lib/docker containers to appear automatically.

Visual diagram

Loading interactive diagram

Theory & deep dive

overlay2 control path

The concrete mechanism is docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"}. The observable result is inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup; if those disagree, inspect the runtime evidence before changing unrelated settings.

Compare overlay2 defaults with btrfs/zfs drivers and when platform choice matters. Keep overlay2, btrfs and zfs in the same deployment record so the intent and the observed state cannot drift apart.

Concrete overlay2 setup

docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"}

Key takeaway: Prove btrfs with inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup, not with command success alone.

zfs failure boundary

Changing drivers can make existing images and writable layers invisible because the daemon’s data root is tied to the old format. Native filesystems can offer snapshots and quotas, but they need separate expertise, kernel support and capacity monitoring. The narrow failure to design for is changing storage-driver in daemon.json and expecting old /var/lib/docker containers to appear automatically.

Accept this compromise explicitly: overlay2 is broadly compatible; native CoW filesystems add features when a fleet already manages those filesystems end to end. The controlled check-inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup-also identifies the point where a different design is safer.

Deliberate failure test

Exercise this failure safely: changing storage-driver in daemon.json and expecting old /var/lib/docker containers to appear automatically.

Key takeaway: overlay2 is broadly compatible; native CoW filesystems add features when a fleet already manages those filesystems end to end.

How it works, step by step

Step 1 of 4
Design

1. State the boundary

Write down why the workload needs this: Changing drivers can make existing images and writable layers invisible because the daemon’s data root is tied to the old format. Native filesystems can offer snapshots and quotas, but they need separate expertise, kernel support and capacity monitoring.

The driver belongs to the daemon host’s data layout, not to an individual Dockerfile or container image tag.
Key numbers at this step
Intent
overlay2

When to use it & trade-offs

What it is

The storage or graph driver selects how image layers and container writable layers are represented. overlay2 is the common Linux default; btrfs and zfs use native CoW snapshot/filesystem features and impose host-format, kernel and operational constraints.

Why it matters: Changing drivers can make existing images and writable layers invisible because the daemon’s data root is tied to the old format. Native filesystems can offer snapshots and quotas, but they need separate expertise, kernel support and capacity monitoring.

When to reach for it

  • The fit is strongest for this job: compare overlay2 defaults with btrfs/zfs drivers and when platform choice matters. Pair it with inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup in the runbook.
  • Production overlay2 changes should make btrfs observable through docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"}, rather than trusting the runtime default.
  • Keep a rollback example for the case where changing storage-driver in daemon.json and expecting old /var/lib/docker containers to appear automatically.

When to avoid or be careful

  • Do not accept command success while the system can still fail by changing storage-driver in daemon.json and expecting old /var/lib/docker containers to appear automatically.
  • Avoid erasing zfs protection merely to dodge this cost: “overlay2 is broadly compatible; native CoW filesystems add features when a fleet already manages those filesystems end to end”.
  • Do not replace the evidence path-inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup-with a screenshot or a mutable tag.

docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"}: practical choices

Explicit overlay2
Best for: Compare overlay2 defaults with btrfs/zfs drivers and when platform choice matters, with a reviewed runbook.

Strengths: The storage or graph driver selects how image layers and container writable layers are represented. overlay2 is the common Linux default; btrfs and zfs use native CoW snapshot/filesystem features and impose host-format, kernel and operational constraints.

Watch out: overlay2 is broadly compatible; native CoW filesystems add features when a fleet already manages those filesystems end to end.

Ambient default
Best for: Short-lived btrfs experiments with low blast radius.

Strengths: It can begin with docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"} and fewer surrounding controls.

Watch out: It silently accepts changing storage-driver in daemon.json and expecting old /var/lib/docker containers to appear automatically, which makes the result hard to reproduce after promotion.

Managed zfs
Best for: Teams that centralize zfs policy across many workloads.

Strengths: Changing drivers can make existing images and writable layers invisible because the daemon’s data root is tied to the old format. Native filesystems can offer snapshots and quotas, but they need separate expertise, kernel support and capacity monitoring.

Watch out: The platform adds an ownership and debugging layer; retain inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup as the direct check.

Interview signals & numbers to know

When this topic comes up

  • docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"}
  • inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup
  • Failure signature: changing storage-driver in daemon.json and expecting old /var/lib/docker containers to appear automatically
  • Trade-off: overlay2 is broadly compatible; native CoW filesystems add features when a fleet already manages those filesystems end to end.

Benchmarks & rules of thumb

/var/lib/docker -
usual Engine data root
1 active driver -
selected per Docker daemon
btrfs or zfs -
host filesystems must already satisfy kernel and format requirements

Common mistakes & follow-ups

Common interview mistakes

  • Treating a successful docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"} as proof and skipping inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup.
  • Changing storage-driver in daemon.json and expecting old /var/lib/docker containers to appear automatically
  • Optimizing overlay2 without accepting that overlay2 is broadly compatible; native CoW filesystems add features when a fleet already manages those filesystems end to end.

Likely interviewer follow-ups

  • Why does docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"} address overlay2 here rather than through application code?
  • How would you distinguish healthy btrfs from the failure “changing storage-driver in daemon.json and expecting old /var/lib/docker containers to appear automatically” using inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup?
  • When would this trade-off-“overlay2 is broadly compatible; native CoW filesystems add features when a fleet already manages those filesystems end to end”-justify a different zfs design?
Interview tip: Give one concrete operation-docker info --format {{.Driver}}:{{.DockerRootDir}}; cat /etc/docker/daemon.json with {"storage-driver":"overlay2"}-and one proof-inspect mount /var/lib/docker and mount new images after a controlled data-root migration or backup. Then name the boundary: changing storage-driver in daemon.json and expecting old /var/lib/docker containers to appear automatically.

Knowledge check

Loading quiz

Put it into practice

Practice related interview Q&A

Apply Docker Storage Drivers (overlay2, btrfs, zfs) with generative AI interview Q&A and hands-on practice.

Open DevOps Q&A →Tech Learn Q&A
Previous topic
Ephemeral Container Filesystems & Why Data Gets Lost
Next topic
Types of Mounts in Docker (Volumes, Bind Mounts, tmpfs)