mirror of
https://github.com/bigbeartechworld/big-bear-scripts.git
synced 2026-03-31 06:33:56 -04:00
feat: Add script to delete Docker volumes by keyword
This commit is contained in:
5
delete-docker-volumes-by-keyword/README.md
Normal file
5
delete-docker-volumes-by-keyword/README.md
Normal file
@@ -0,0 +1,5 @@
|
||||
# Run command
|
||||
|
||||
```bash
|
||||
bash -c "$(wget -qLO - https://raw.githubusercontent.com/bigbeartechworld/big-bear-scripts/master/delete-docker-volumes-by-keyword/run.sh)"
|
||||
```
|
||||
17
delete-docker-volumes-by-keyword/run.sh
Normal file
17
delete-docker-volumes-by-keyword/run.sh
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
# List all Docker volumes
|
||||
echo "Here are all the available Docker volumes:"
|
||||
docker volume ls --format '{{.Name}}'
|
||||
|
||||
# Provide a blank line for better readability
|
||||
echo ""
|
||||
|
||||
# Prompt the user to enter a word associated with the volumes they want to remove
|
||||
echo "Enter the keyword associated with the Docker volumes you want to remove:"
|
||||
read word
|
||||
|
||||
# Use the word to filter and remove Docker volumes
|
||||
docker volume ls --format '{{.Name}}' | grep "$word" | awk '{print $1}' | xargs -r docker volume rm
|
||||
|
||||
echo "Volumes associated with '$word' have been removed."
|
||||
Reference in New Issue
Block a user