docker-scripts/docker-clean-all

22 lines
471 B
Bash
Executable File

#!/bin/bash
# show current space.
echo "Current state:"
docker system df
echo
echo "Performing cleanup..."
# remove exited containers:
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v 1>/dev/null
# remove unused images
docker image prune -a -f 1>/dev/null
# remove unused volumes:
docker volume prune -a -f 1>/dev/null
# remove buildx cache
docker buildx prune -f 1>/dev/null
# show results
echo
echo "After cleanup:"
docker system df