# docker builder prune: Clear BuildKit Build Cache

> How docker builder prune works: clearing BuildKit build cache, the -a flag, keep-storage, and freeing disk on CI runners.

Source: https://latchkey.dev/learn/command-reference/docker-builder-prune-command  
Updated: 2026-06-25

Clear BuildKit build cache when it eats the runner disk.

docker builder prune removes BuildKit build cache. This page covers full vs dangling-only cleanup and keep-storage limits for CI.

## What it does

docker builder prune deletes cached build layers from BuildKit. By default it removes dangling cache; -a removes all build cache. docker buildx prune is the equivalent for a buildx builder instance.

## Common usage

```Terminal
docker builder prune -f
docker builder prune -af                 # all build cache
docker buildx prune --keep-storage 5GB -f
```

## Common errors in CI

Build cache often dominates "no space left on device" yet is invisible to docker images - check docker system df, then docker builder prune -af. Without -f it prompts and stalls CI. On runners you reuse, prefer --keep-storage to cap cache size rather than wiping it every run, so you keep cache hits while bounding disk.

## FAQ

### docker builder prune: Clear BuildKit Build Cache?

docker builder prune removes BuildKit build cache. This page covers full vs dangling-only cleanup and keep-storage limits for CI.

### What it does?

docker builder prune deletes cached build layers from BuildKit. By default it removes dangling cache; -a removes all build cache. docker buildx prune is the equivalent for a buildx builder instance.

### Common errors in CI?

Build cache often dominates "no space left on device" yet is invisible to docker images - check docker system df, then docker builder prune -af. Without -f it prompts and stalls CI. On runners you reuse, prefer --keep-storage to cap cache size rather than wiping it every run, so you keep cache hits while bounding disk.

---

Latchkey runs CI/CD that repairs its own failures. Agent entry points: https://latchkey.dev/agent.txt, https://latchkey.dev/openapi.json, https://latchkey.dev/llms.txt
