Linux  ·  high  ·  Day-to-day operations

Docker: "no space left on device" with plenty of disk free

Docker's own storage area is full of dangling images, stopped containers, build cache and unused volumes, even though the host filesystem looks healthy.

What you see

docker pull or docker build fails with no space left on device. df on / shows free space, or /var/lib/docker is on a filesystem that is genuinely full.

What is actually wrong

Accumulated layers and build cache. On a busy CI host this grows by gigabytes a day and nothing removes it automatically.

Codes and articles

no space left on device dockeroverlay2failed to register layerdevmapperThin Pool

The fix

Reclaim Docker's storage safely
Shell as root25 minutesmedium risknot reversible

Docker is out of space. Work from the safest reclaim to the most aggressive and stop when you have enough.

  1. See where the space has gone before deleting anything.

    Shell
    docker system df -v | head -40sudo du -sh /var/lib/docker/*
  2. Check whether /var/lib/docker is even on the filesystem you think it is.

    Shell
    df -h /var/lib/dockerdf -i /var/lib/docker

    Overlay2 creates enormous numbers of small files, so a Docker host can exhaust inodes while showing free blocks — check -i as well as -h.

  3. Remove stopped containers, unused networks and dangling images. This is the safe one.

    Shell
    docker system prune
  4. Clear the build cache, which is usually the biggest single consumer on a CI host.

    Shell
    docker builder prune -a
  5. Remove images not used by any container. Read the list before confirming.

    Shell
    docker image prune -a

    -a removes every image without a running container, including ones you intend to run later. On a machine with slow internet that is an expensive mistake.

  6. Volumes last, and only after checking what is in them — this is where data lives.

    Shell
    docker volume ls -f dangling=truedocker volume prune

    A dangling volume is one no container currently references. That includes the database volume of a container you stopped ten minutes ago.

  7. Stop it recurring by capping the log driver, which grows without limit by default.

    Shell
    printf '{\n  "log-driver": "json-file",\n  "log-opts": { "max-size": "50m", "max-file": "3" }\n}\n' | sudo tee /etc/docker/daemon.jsonsudo systemctl restart docker
Confirm it workedDocker reports reclaimed space and pulls succeed.
Shell
docker system dfdf -h /var/lib/docker
If you need to undo itNone — pruned images must be pulled again, pruned volumes are gone.

Where this stops. This write-up was written and checked by hand. It says what each step changes, how to confirm it worked and how to reverse it, and anything destructive is flagged before you reach it. If it does not match what your machine is doing, search the Support Centre for the exact code or message — and when something needs a person, get in touch.