Skip to content

Instantly share code, notes, and snippets.

@guilhermegazzinelli
Created July 2, 2022 23:11
Show Gist options
  • Save guilhermegazzinelli/8f7c2e0b4205914a3617d79d9726ad02 to your computer and use it in GitHub Desktop.
Save guilhermegazzinelli/8f7c2e0b4205914a3617d79d9726ad02 to your computer and use it in GitHub Desktop.
Show the volumes and associated containers
#!/bin/sh
#!/bin/sh
volumes=$(docker volume ls --format '{{.Name}}')
dangling=()
for volume in $volumes
do
if result=$(docker ps -a --filter volume="$volume" --format '{{.Names}}' | sed 's/^/ => Used in:/' )
then
echo $volume
echo $result
else
dangling+=($volume)
fi
#echo $dangling
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment