Skip to content

Instantly share code, notes, and snippets.

@ronanguilloux
Created October 8, 2016 08:48
Show Gist options
  • Save ronanguilloux/90d37a820c15fc58168058efaf79980f to your computer and use it in GitHub Desktop.
Save ronanguilloux/90d37a820c15fc58168058efaf79980f to your computer and use it in GitHub Desktop.
Docker images disk usage calculation
#!/bin/bash
# disk-usage from docker-experiments
# https://github.com/rsp/docker-experiments
# by Rafał Pocztarski - https://github.com/rsp
if [ $# -ne 1 ]; then
echo "Usage: $0 \"image1 image2 ...\""
exit 1
fi
images="$1"
echo "docker-experiments/disk-usage - data from `date -I`"
echo "See: https://github.com/rsp/docker-experiments"
echo -e "Image\tDisk usage"
echo -e "-----\t----------"
for image in $images; do
echo -ne "$image\t"
docker run --entrypoint=/bin/sh $image -c \
'du -sh / 2>/dev/null | cut -f1' \
|| echo "ERROR!"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment