✦ For everyone, free.

Practical knowledge for real and everyday life

Home

14.1.3.2 Host Disk Monitoring

A focused guide to Host Disk Monitoring, connecting core concepts with practical Docker and container operations.

Host disk monitoring tracks the storage consumed by Docker's images, containers, volumes, and build cache on a production host, an often overlooked but important concern since this storage can grow unboundedly over time without periodic attention, eventually risking a disk-exhaustion failure.

Checking Docker's Current Disk Usage

Docker provides a direct way to see exactly how much disk space its various components are consuming.

docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          24        8         4.2GB     2.8GB (66%)
Containers      8         5         120MB     45MB (37%)
Local Volumes   12        6         1.1GB     400MB (36%)
Build Cache     142       0         3.4GB     3.4GB (100%)

This breakdown reveals exactly where reclaimable space exists, useful for understanding what's actually contributing to disk usage.

Why Unused Images and Build Cache Accumulate Over Time

Every build produces layers that remain on disk even after a container using that image is removed, and accumulated build cache in particular can grow substantially without periodic cleanup.

docker images
docker system prune -af --filter "until=168h"

This removes unused images, containers, and build cache older than a week, a reasonable periodic cleanup approach for most production hosts.

Setting Up Automated Disk Usage Alerting

Rather than relying on manual periodic checks, automated alerting on disk usage crossing a meaningful threshold catches a developing problem before it becomes an actual outage.

df -h /var/lib/docker | awk 'NR==2 {print $5}'
Why Volumes Specifically Need Separate Attention

Unlike images and build cache, volumes often contain genuine application data that shouldn't simply be pruned — monitoring their growth specifically, separate from more freely reclaimable Docker artifacts, avoids treating important data the same as disposable build cache.

docker system df -v
Why Host Disk Monitoring Matters

Proactively monitoring and periodically reclaiming Docker's accumulated disk usage prevents an entirely avoidable disk-exhaustion failure, a maintenance concern that's easy to overlook until it actually causes a production incident.