Skip to content

Instantly share code, notes, and snippets.

@bofm
Created November 6, 2015 14:57
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 bofm/0bc71b45a34ed2295ec7 to your computer and use it in GitHub Desktop.
Save bofm/0bc71b45a34ed2295ec7 to your computer and use it in GitHub Desktop.
Shows disk space usage of Docker containers.
#!/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