Founding prices until 15 December: 30% off Pro, locked for life. See pricing

$ … no space left on device (Docker)

Docker 'no space left on device': clean up images, volumes and build cache

Old images, stopped containers, volumes, build cache or container logs filled /var/lib/docker.

Docker

What it means

Docker keeps every image layer, stopped container, volume and build cache until you remove them, and by default container logs grow without limit. On a busy host or CI runner they fill the disk.

Causes and fixes

Most likely first. Run the check, and if it matches, apply the fix.

1. Unused images, containers and build cache

Check:

docker system df

Fix: docker system prune (add -a for unused images; volumes only with care, they hold data).

2. A container's json log file grows forever

Check:

du -sh /var/lib/docker/containers/*/*-json.log | sort -h | tail

Fix: Set log-opts max-size and max-file in /etc/docker/daemon.json (or per service in Compose).

3. A huge build context or image (node_modules, .git, data copied in)

Check:

docker history <image>

Fix: Add a .dockerignore and use multi-stage builds.

Fix it yourself

A live machine in your browser with this problem already on it. The grader checks the result.

Open the lab

No account needed for your first tries.

Related errors

  • No space left on device

    A write failed because the filesystem is full, or out of inodes, or a deleted file is still held open.