Bash

Prune Dangling Docker Images

admin by @admin ADMIN
1d ago
May 31, 2026
Public
0 0 up · 0 down Sign in to vote
Reclaim disk space from Docker. `prune` operates on stopped containers, dangling images, build cache, and unused networks. Run periodically on CI runners.
Bash
Raw
# Show what would be removed first
docker system df

# Safe pruning — dangling (untagged) images only
docker image prune -f

# Aggressive — remove ALL unused images, not just dangling
docker image prune -a -f

# Stopped containers
docker container prune -f

# Build cache (newer Docker)
docker builder prune -af

# Everything not in use (most aggressive, most space recovered)
docker system prune -af --volumes

# Crontab entry for nightly cleanup
# 0 3 * * * docker system prune -af --filter "until=168h" >/var/log/docker-prune.log 2>&1
Tags

Save your own code snippets

Create a free account and build your private vault. Share publicly whenever you want.