Skip to content

Instantly share code, notes, and snippets.

@ludenus
Last active March 23, 2023 17:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ludenus/7b9b9a8454389ffdf3f4d8c6798dd5e9 to your computer and use it in GitHub Desktop.
Save ludenus/7b9b9a8454389ffdf3f4d8c6798dd5e9 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e
echo "==================== before cleanup: `date --utc --iso-8601=seconds`"
df -h | grep -v ^overlay | grep -v ^tmpfs | grep -v ^shm | grep -v /snap/
echo ""
if which docker; then
echo 'run docker cleanup ... '
docker system prune -a -f --volumes
elif which crictl; then
echo 'run crictl cleanup ... '
crictl rmi --prune
elif which ctr; then
ctr -n k8s.io i rm $(ctr -n k8s.io i ls -q )
else
echo "ERROR: neither docker nor crictl nor ctr found in PATH:$PATH"
fi
echo ""
echo "==================== after cleanup: `date --utc --iso-8601=seconds`"
df -h | grep -v ^overlay | grep -v ^tmpfs | grep -v ^shm | grep -v /snap/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment