Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Script to remove orphaned docker volumes
#!/bin/bash
# Usage:
# - To only show the possbible volumes to be removed:
# ./docker-cleanup-volumes.sh
# - To remove orphaned docker volumes:
# ./docker-cleanup-volumes.sh clean
if [ "$1" == 'clean' ]; then
echo "cleaning..."
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes
else
echo "showing..."
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes --dry-run
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.