Skip to content

Instantly share code, notes, and snippets.

@jcmartins
Created January 5, 2016 19:41
Show Gist options
  • Save jcmartins/628ec970f551d6698493 to your computer and use it in GitHub Desktop.
Save jcmartins/628ec970f551d6698493 to your computer and use it in GitHub Desktop.
List all running containers’ sizes and volumes:
for d in `docker ps | awk '{print $1}' | tail -n +2`; do
d_name=`docker inspect -f {{.Name}} $d`
echo "========================================================="
echo "$d_name ($d) container size:"
sudo du -d 2 -h /var/lib/docker/devicemapper | grep `docker inspect -f "{{.Id}}" $d`
echo "$d_name ($d) volumes:"
docker inspect -f "{{.Volumes}}" $d | sed 's/map\[//' | sed 's/]//' | tr ' ' '\n' | sed 's/.*://' | xargs sudo du -d 1 -h
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment