Created
November 6, 2015 14:57
-
-
Save bofm/0bc71b45a34ed2295ec7 to your computer and use it in GitHub Desktop.
Shows disk space usage of Docker containers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for d in `docker ps -aq`; do | |
d_name=`docker inspect -f {{.Name}} $d` | |
echo "=========================================================" | |
echo "$d_name ($d) container size:" | |
sudo du -d 2 -h /var/lib/docker/aufs | grep `docker inspect -f "{{.Id}}" $d` | |
echo "$d_name ($d) volumes:" | |
for mount in `docker inspect -f "{{range .Mounts}} {{.Source}}:{{.Destination}} | |
{{end}}" $d`; do | |
size=`echo $mount | cut -d':' -f1 | sudo xargs du -d 0 -h` | |
mnt=`echo $mount | cut -d':' -f2` | |
echo "$size mounted on $mnt" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment