Skip to main content

Docker · 6 common causes

no space left on device

Updated

The filesystem holding Docker's data — or the virtual disk on Docker Desktop — is full.

The exact message

$ docker compose build
[+] Building 12.4s (8/14)
 => ERROR [builder 4/9] RUN npm ci
------
failed to solve: write /var/lib/docker/tmp/GetImageBlob123456789:
no space left on device

Paths, line numbers and stack frames differ on every machine, and the wording is tightened between versions. The part that identifies the problem is no space left on device.

How to fix it

Cause 1 of 6

Accumulated images, stopped containers and build cache.

docker system df shows exactly what is using space and how much is reclaimable — run it first. Then docker system prune removes stopped containers, unused networks, dangling images and build cache. Read the list it prints before confirming, and add --volumes only when you are certain no volume holds data you need, because that deletes databases.

Cause 2 of 6

The build cache specifically has grown large.

docker builder prune clears BuildKit cache without touching images, containers or volumes. It is usually the biggest single reclaim and the safest one, so try it before the broader prune.

Cause 3 of 6

The host disk is full, not Docker.

df -h for the filesystem and du -sh /var/lib/docker for Docker's share. If another directory is the real consumer, pruning Docker frees nothing and you will be back in an hour.

Cause 4 of 6

Docker Desktop's virtual disk has reached its configured maximum.

The VM disk can be full while the Mac or Windows host has hundreds of free gigabytes. Raise the disk image size in Settings, Resources, Advanced — or use the same screen to reclaim space.

Cause 5 of 6

Inodes are exhausted rather than bytes.

df -i. Layers full of tiny files, node_modules being the classic, can use up every inode while df -h still shows free capacity. Pruning images is the practical remedy.

Cause 6 of 6

A container writes into its own writable layer instead of a volume.

Logs, uploads and caches written inside the container grow that layer without limit. Mount a volume for them, and cap container logs with the json-file driver's max-size and max-file options.

Stopping it coming back

Run docker system df occasionally rather than waiting for a build to fail, set log rotation in the daemon config, and keep persistent data in named volumes so image pruning never touches it.

no space left on device — common questions

Is docker system prune safe to run?
Without --volumes it removes stopped containers, unused networks, dangling images and build cache — things that can be rebuilt. With --volumes it also deletes anonymous volumes, which is where a database's data may live. Read what it lists, and skip the flag unless you are sure.
What is the difference between dangling and unused images?
Dangling images are untagged layers left behind by rebuilds. Unused images are tagged images no container currently references — which may include ones you want to keep offline. Plain prune removes only dangling ones; -a removes both.
Why does the Mac still show free space?
Docker Desktop runs containers inside a Linux VM with its own virtual disk. That disk fills independently of macOS, so the host disk figure tells you nothing about Docker's remaining space.

Test the fix before you paste it back

Reproducing the failure in a scratch file is usually faster than editing the real one. AltF Code is a free in-browser editor with real syntax highlighting for HTML, CSS, JavaScript, TypeScript, Python, SQL and JSON, and it runs HTML, CSS and JavaScript live in a preview panel. No install and no sign-up.

Open the editor