Skip to content

Commit db5c3b7

Browse files
zhxtCapri2014
authored andcommitted
docker: add an option to stop apollo containers
1 parent e631a26 commit db5c3b7

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

docker/scripts/dev_start.sh

+24-1
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,29 @@ OPTIONS:
5959
-h, --help Display this help and exit.
6060
-t, --tag <version> Specify which version of a docker image to pull.
6161
-l, --local Use local docker image.
62+
stop Stop all running Apollo containers.
6263
EOF
6364
exit 0
6465
}
6566

67+
function stop_containers()
68+
{
69+
running_containers=$(docker ps --format "{{.Names}}")
70+
71+
for i in ${running_containers[*]}
72+
do
73+
if [[ "$i" =~ apollo_* ]];then
74+
printf %-*s 70 "stopping container: $i ..."
75+
docker stop $i > /dev/null
76+
if [ $? -eq 0 ];then
77+
printf "\033[32m[DONE]\033[0m\n"
78+
else
79+
printf "\033[31m[FAILED]\033[0m\n"
80+
fi
81+
fi
82+
done
83+
}
84+
6685
APOLLO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"
6786

6887
if [ ! -e /apollo ]; then
@@ -118,7 +137,11 @@ do
118137
shift
119138
source ${APOLLO_ROOT_DIR}/docker/scripts/restart_map_volume.sh \
120139
"${map_name}" "${VOLUME_VERSION}"
121-
;;
140+
;;
141+
stop)
142+
stop_containers
143+
exit 0
144+
;;
122145
*)
123146
echo -e "\033[93mWarning\033[0m: Unknown option: $1"
124147
exit 2

0 commit comments

Comments
 (0)