docker build "no space left on device": Reclaim It Safely

Symptom

Builds or pulls fail with ENOSPC; df shows /var/lib/docker full.

Root cause

Layers, dangling images, and build cache accumulate forever unless pruned.

Fix, in order

1. See what is eating the diskdocker system df
2. Prune the safe stuffdocker system prune -f
3. Shrink future images with multi-stage buildsFROM node:20 AS build ... FROM node:20-slim
4. Move data-root if the partition is just too small{"data-root": "/mnt/bigdisk/docker"}

Prevent it coming back

Scheduled prune + build with --no-cache only when you truly need it.

Run it on clean infra

Spinning up a fresh box to reproduce or escape this error?

Servers with headroom

Related

Cloud & DevOps tool comparisons · Hardware build guides

NinjaOps publishes free engineering guides. Some outbound links are affiliate links: they cost you nothing and support the site.

Last reviewed 2026-10-02 · NinjaOps SEO grid · DevOps blog