Skip to content

Commit

Permalink
docker: add an option to stop apollo containers
Browse files Browse the repository at this point in the history
  • Loading branch information
zhxt authored and Capri2014 committed May 17, 2018
1 parent cd98822 commit 0b7c8fd
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion docker/scripts/dev_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,29 @@ OPTIONS:
-h, --help Display this help and exit.
-t, --tag <version> Specify which version of a docker image to pull.
-l, --local Use local docker image.
stop Stop all running Apollo containers.
EOF
exit 0
}

function stop_containers()
{
running_containers=$(docker ps --format "{{.Names}}")

for i in ${running_containers[*]}
do
if [[ "$i" =~ apollo_* ]];then
printf %-*s 70 "stopping container: $i ..."
docker stop $i > /dev/null
if [ $? -eq 0 ];then
printf "\033[32m[DONE]\033[0m\n"
else
printf "\033[31m[FAILED]\033[0m\n"
fi
fi
done
}

APOLLO_ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"

if [ ! -e /apollo ]; then
Expand Down Expand Up @@ -118,7 +137,11 @@ do
shift
source ${APOLLO_ROOT_DIR}/docker/scripts/restart_map_volume.sh \
"${map_name}" "${VOLUME_VERSION}"
;;
;;
stop)
stop_containers
exit 0
;;
*)
echo -e "\033[93mWarning\033[0m: Unknown option: $1"
exit 2
Expand Down

0 comments on commit 0b7c8fd

Please sign in to comment.