-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreset.sh
36 lines (29 loc) · 1.08 KB
/
reset.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
#!/bin/sh
node_id=-1
if [ $# -ne 1 ] ; then
echo "ERROR: [reset.sh] Incorrect number of arguments. Usage: sh reset.sh NODE_ID"
exit 1
else
node_id=$1
fi
echo "INFO: [reset.sh] Cleaning up Clipper $node_id"
# Clean up containers
containers=`docker network inspect clipper_network_$node_id --format '{{range .Containers}}{{println .Name}}{{end}}'`
docker stop $containers >&- 2>&-
docker rm $containers >&- 2>&-
# Clean up volumns
docker volume prune --force >&- 2>&-
# Clean up networks
docker network rm clipper_network_$node_id >&- 2>&-
# i=0
# while [ $i -lt $num_nodes ] ; do
# containers=`docker network inspect clipper_network_$i --format '{{range .Containers}}{{println .Name}}{{end}}'`
# docker stop $containers >&- 2>&-
# docker rm $containers >&- 2>&-
# docker network rm clipper_network_$i >&- 2>&-
# i=$(($i+1))
# done
images=`docker images --format '{{.Repository}}\t{{.ID}}' | grep '<none>' | cut -f 2`
docker image rm $images >&- 2>&-
echo "INFO: [reset.sh] All Clipper $node_id containers, volumes, networks and outdated images are cleared away."
exit 0