-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker-destroy.sh
executable file
·44 lines (38 loc) · 1.2 KB
/
docker-destroy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
source ./decorate.sh
declare -i STEP=0
title -d 1 "Destroying Recipe site containerized development environment" "from ./docker-compose.yml"
windowBottom
title -d 1 "Stopping services..."
docker-compose stop
windowBottom
title -d 1 "Removing all containers..."
docker-compose rm -vf
windowBottom
title -d 1 "Destroying persistent volumes..."
basedir=`pwd | xargs basename | awk '{print tolower($0)}'`
a_VOLS=(
"recipe_site_dev_db_data"
)
a_PVOLS=()
for vol in ${a_VOLS[@]}; do
SCANTXT=$(printf "Scanning for '%s'... " "$vol")
printf "%50s" "$SCANTXT"
DOCKERVOLNAME=$(docker volume ls | grep -v DRIVER | awk {'print $2'} | grep $vol)
if (( ${#DOCKERVOLNAME} )); then
printf "${Green}[ %s ]${NC}\n" "$DOCKERVOLNAME"
else
printf "${Red}[ Not found. ]${NC}\n"
fi
a_PVOLS+=($DOCKERVOLNAME)
done
printf "\n"
for VOL in ${a_PVOLS[@]} ; do
printf "${Cyan}Do you want to remove persistent volume ${Green}[ $VOL ]${Cyan}?${NC}"
read -p " [y/n] " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]] ; then
docker volume rm $VOL
fi
done
windowBottom