-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrm
executable file
·54 lines (49 loc) · 1.13 KB
/
drm
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
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
all_container=$(dls -a)
all_live=$(dls -ll)
if [ $# == 0 ]; then
echo Please use '-a', '-f <id>' or '-af' to remove all containers.
elif [ $# == 1 ]; then
if [ "$1" == "-a" ]; then
for item in ${all_container[*]}
do
rmv="1"
for live in ${all_live[*]}
do
test "$item" == "$live" && { rmv="0"; }
done
if [ "$rmv" == "1" ]; then
docker rm $item
fi
done
elif [ "$1" == "-af" -o "$1" == "-fa" ]; then
dkill -a
docker rm $all_container
else
rmv="1"
for live in ${all_live[*]}
do
test "$1" != "$live" && { rmv="0"; }
done
if [ "$rmv" == "1" ]; then
docker rm $1
fi
fi
elif [ $# -gt 1 ]; then
if [ "$1" == "-f" ]; then
dkill ${@:2}
docker rm -f ${@:2}
else
for item in $@
do
rmv="1"
for live in ${all_live[*]}
do
test "$item" != "$live" && { rmv="0"; }
done
if [ "$rmv" == "1" ]; then
docker rm $item
fi
done
fi
fi