✦ For everyone, free.

Practical knowledge for real and everyday life

Home

8 Docker Storage

A focused guide to Docker Storage, connecting core concepts with practical Docker and container operations.

Docker storage encompasses how Docker manages persistent and ephemeral data — image layers, container writable layers, and volumes — each with distinct lifecycles and purposes, collectively determining how data is stored, shared, and discarded across the system.

The Layered Foundation: Image Layers

An image's own layers are read-only and shared across every container created from that image, forming the immutable foundation every container's filesystem builds upon.

docker history myapp:1.0

This reveals the distinct layers making up the image, each contributing part of its overall filesystem content.

The Container's Own Writable Layer

Each container receives its own writable layer, capturing any filesystem changes made during that specific container's life, kept separate from both the underlying image and every other container's own writable layer.

docker diff myapp

This reveals exactly what has changed in this specific container's writable layer relative to the image it was created from.

Volumes for Genuinely Persistent Data

For data that needs to outlive a specific container — and ideally be more deliberately managed than relying on the writable layer — volumes provide dedicated, independently lifecycled storage.

docker volume create mydata
docker run -d -v mydata:/var/lib/myapp/data myapp:1.0
Checking Overall Storage Usage

Docker's total disk usage, broken down by category, can be reviewed directly, useful for understanding where storage is actually being consumed.

docker system df
Why Understanding Docker Storage Matters

A clear mental model of these distinct storage layers — immutable image layers, ephemeral container writable layers, and durable, independently managed volumes — is foundational to correctly reasoning about where data lives, how long it persists, and how to manage Docker's overall disk usage effectively.

Content in this section