Docker Cleanup Reference

By Engineering Team•October 11, 2026•2 min read

Here is how to clean up unused Docker images, build cache, containers, and volumes safely.

1. The Quick All-in-One Sweep (Safe Default)

Remove stopped containers, dangling images (unnamed images), unused networks, and build cache in a single command:

docker system prune

Note: this leaves named images and volumes untouched.

2. Deep Clean (Reclaim Maximum Space)

To remove all unused images (not just dangling ones) and unused persistent volumes, run:

docker system prune -a --volumes
  • -a / --all: removes all unused images, not just dangling ones.
  • --volumes: removes all volumes not currently used by at least one container.

3. Target Specific Components

If you prefer surgical cleanup instead of a full wipe, clean individual areas.

Build Cache

Build cache often takes up the largest amount of disk space without being obvious.

# Clear all build cache
docker builder prune -a

Images

# Remove dangling (unnamed/untagged) images
docker image prune

# Remove all images not used by a running container
docker image prune -a

Containers

# Remove all stopped containers
docker container prune

Volumes

# Remove all unused local volumes
docker volume prune

Prevent High Disk Usage

To check how much disk space Docker is currently using before and after cleanup:

docker system df

For detailed usage per item (containers, images, volumes, build cache):

docker system df -v
  • Deployment & Infra Standard — the project’s own stack-control commands (docker compose -p ecommerce-shoppee ...), troubleshooting recipe for stale layers/binary issues