docker system pruneReclaim disk space from unused Docker data
docker system prune deletes what nothing is using: stopped containers, unused networks, dangling images and build cache, and with flags, every unused image and anonymous volumes. It's the standard fix for a Docker host or CI runner whose /var/lib/docker has filled the disk, and it's destructive if you add flags without thinking.
docker system prune [-a] [--volumes] [--filter until=24h] [-f]Disk alert on a CI runner: / is 94% full and /var/lib/docker is the culprit. Measure before deleting anything.
docker system pruneRemove unused containers, networks, images and build cache in one go.
prune is several API calls in a row: POST /containers/prune, /networks/prune, /images/prune and /build/prune (plus /volumes/prune with --volumes), each with the same filters. 'Unused' is decided by references: a container is removable if it isn't running; a network if no container is attached; an image if no container, running or stopped, was created from it (dangling-only without -a); a volume if no container mounts it. Since Docker 23, volume pruning removes only anonymous volumes unless you also ask for all. Images are removed by deleting their tags and then any layers no other image shares, so the space freed is often less than the image sizes suggest. Running containers, and the images, networks and volumes they use, are never touched.
-a, --allRemove all unused images, not only dangling ones--volumesAlso remove unused anonymous volumes--filter until=24hOnly objects older than this--filter label=env=ciOnly objects with (or label!= without) a label-f, --forceSkip the confirmation promptdocker system df [-v]Show what uses space and what's reclaimable first<type> prunePrune one kind only: image, container, volume, network or builderdocker system prune -a --volumes -f on a production hostRemoves every image not in use (slow restarts while they're re-pulled) and anonymous volumes, which may hold real data.
docker system prune (defaults), then targeted image/volume prunes after checking docker system df -vrm -rf /var/lib/docker/overlay2/... to free spaceDeleting Docker's files behind its back corrupts images and containers; dockerd still references them.
Use docker prune commands, or stop dockerd and wipe /var/lib/docker entirely if you really want a resetPruning to fix a disk that's full because of container logsRunning containers aren't pruned, and their JSON logs keep growing.
Check /var/lib/docker/containers/*/*-json.log and configure log rotation (see docker logs)Try these on a Linux machine of your own. Each task has a hint and a solution.
Show Docker's disk usage per image, container and volume on this host.
In the sandbox, do the first step of every disk investigation: show filesystem usage and the five biggest directories under /var/log.
Write a non-interactive prune for a CI runner that removes unused images and build cache older than 3 days but leaves volumes alone.
docker system pruneReclaim disk space from unused Docker data
docker system prune deletes what nothing is using: stopped containers, unused networks, dangling images and build cache, and with flags, every unused image and anonymous volumes. It's the standard fix for a Docker host or CI runner whose /var/lib/docker has filled the disk, and it's destructive if you add flags without thinking.
docker system prune [-a] [--volumes] [--filter until=24h] [-f]Disk alert on a CI runner: / is 94% full and /var/lib/docker is the culprit. Measure before deleting anything.
docker system pruneRemove unused containers, networks, images and build cache in one go.
prune is several API calls in a row: POST /containers/prune, /networks/prune, /images/prune and /build/prune (plus /volumes/prune with --volumes), each with the same filters. 'Unused' is decided by references: a container is removable if it isn't running; a network if no container is attached; an image if no container, running or stopped, was created from it (dangling-only without -a); a volume if no container mounts it. Since Docker 23, volume pruning removes only anonymous volumes unless you also ask for all. Images are removed by deleting their tags and then any layers no other image shares, so the space freed is often less than the image sizes suggest. Running containers, and the images, networks and volumes they use, are never touched.
-a, --allRemove all unused images, not only dangling ones--volumesAlso remove unused anonymous volumes--filter until=24hOnly objects older than this--filter label=env=ciOnly objects with (or label!= without) a label-f, --forceSkip the confirmation promptdocker system df [-v]Show what uses space and what's reclaimable first<type> prunePrune one kind only: image, container, volume, network or builderdocker system prune -a --volumes -f on a production hostRemoves every image not in use (slow restarts while they're re-pulled) and anonymous volumes, which may hold real data.
docker system prune (defaults), then targeted image/volume prunes after checking docker system df -vrm -rf /var/lib/docker/overlay2/... to free spaceDeleting Docker's files behind its back corrupts images and containers; dockerd still references them.
Use docker prune commands, or stop dockerd and wipe /var/lib/docker entirely if you really want a resetPruning to fix a disk that's full because of container logsRunning containers aren't pruned, and their JSON logs keep growing.
Check /var/lib/docker/containers/*/*-json.log and configure log rotation (see docker logs)Try these on a Linux machine of your own. Each task has a hint and a solution.
Show Docker's disk usage per image, container and volume on this host.
In the sandbox, do the first step of every disk investigation: show filesystem usage and the five biggest directories under /var/log.
Write a non-interactive prune for a CI runner that removes unused images and build cache older than 3 days but leaves volumes alone.