docker-scripts/docker-clean-all

22 lines
471 B
Plaintext
Raw Normal View History

2023-02-08 19:46:00 +00:00
#!/bin/bash
2025-01-29 12:24:58 +00:00
# show current space.
echo "Current state:"
docker system df
echo
echo "Performing cleanup..."
2023-02-08 19:46:00 +00:00
# remove exited containers:
2025-01-29 12:24:58 +00:00
docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v 1>/dev/null
2023-02-08 19:46:00 +00:00
# remove unused images
2025-01-29 12:24:58 +00:00
docker image prune -a -f 1>/dev/null
2023-02-08 19:46:00 +00:00
# remove unused volumes:
2025-01-29 12:24:58 +00:00
docker volume prune -a -f 1>/dev/null
2025-01-27 13:38:30 +00:00
# remove buildx cache
2025-01-29 12:24:58 +00:00
docker buildx prune -f 1>/dev/null
2025-01-27 13:38:30 +00:00
# show results
2025-01-29 12:24:58 +00:00
echo
echo "After cleanup:"
2025-01-27 13:38:30 +00:00
docker system df
2023-02-08 19:46:00 +00:00