Skip to content

Instantly share code, notes, and snippets.

@dmcallejo
Last active October 1, 2024 08:01
Show Gist options
  • Save dmcallejo/ee3a903e329e4b59763ad45b812e3aba to your computer and use it in GitHub Desktop.
Save dmcallejo/ee3a903e329e4b59763ad45b812e3aba to your computer and use it in GitHub Desktop.
Docker internals cheatsheet
# Check logs size of containers, sorted by size and show total usage
sudo du -ch $(docker inspect --format='{{.LogPath}}' $(docker ps -qa)) | sort -h | sed 's/\/var\/lib\/docker\/containers\///' | awk '{if ($1 != "total") {split($NF, arr, "/"); id = arr[1]; print $1 " " $2 " " id} else {print $1 " " $2 " " $1}}' | while read size unit id; do if [ "$size" != "total" ]; then name=$(docker ps --format "{{.Names}}" --filter id=$id); echo "$size $unit $name"; else echo "$size $unit $id"; fi; done
# Check all volumes and images sizes
docker system df -v
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment