Skip to content

Instantly share code, notes, and snippets.

@rkusa
Last active December 5, 2017 10:06
Show Gist options
  • Save rkusa/113ec00b80c33fff9d91 to your computer and use it in GitHub Desktop.
Save rkusa/113ec00b80c33fff9d91 to your computer and use it in GitHub Desktop.
list Docker volumes/mounts sizes
#!bash
for id in `docker ps -q`; do \
name=`docker inspect -f {{.Name}} $id | tail -c +2`; \
echo "$name ($id)"; \
mounts=(`docker inspect -f '{{range .Mounts}}{{.Source}} {{end}}' $id`); \
for mount in ${mounts[@]}; do \
du -hLs $mount | tail -n 1; \
done
done
@underyx
Copy link

underyx commented Dec 5, 2017

for id in `docker ps -q`; do \
  name=`docker inspect -f {{.Name}} $id | tail -c +2`; \
  echo "$name ($id)"; \
  mounts=(`docker inspect -f '{{range .Mounts}}{{.Source}} {{end}}' $id`); \
  for mount in ${mounts[@]}; do \
    du -hLs $mount 2>/dev/null | tail -n 1; \
  done
done

This one suppresses all the permission denied errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment