Created
November 11, 2019 19:39
-
-
Save nguni52/778f7acbf172457cdf0d30f0d61a1bf1 to your computer and use it in GitHub Desktop.
Stop multiple docker machines
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
machine_names=( $(docker-machine ls | awk '{print $1}') ) | |
echo $1 | |
case "$1" in | |
start) | |
echo "Starting docker machines $1" | |
for (( i=0; i<${#machine_names[@]}; i++ )); do | |
echo ${machine_names[i]}; | |
docker-machine start ${machine_names[i]} | |
done | |
;; | |
stop) | |
for (( i=0; i<${#machine_names[@]}; i++ )); do | |
echo ${machine_names[i]}; | |
docker-machine stop ${machine_names[i]} | |
done | |
;; | |
restart) | |
echo –n “Stopping swarm docker-machines” | |
for (( i=0; i<${#machine_names[@]}; i++ )); do | |
echo ${machine_names[i]}; | |
docker-machine stop ${machine_names[i]} | |
done | |
echo "." | |
echo –n "Starting swarm docker-machines" | |
for (( i=0; i<${#machine_names[@]}; i++ )); do | |
echo ${machine_names[i]}; | |
docker-machine start ${machine_names[i]} | |
done | |
echo "." | |
;; | |
*) | |
echo "Usage: ./my-docker-machines.sh start|stop|restart" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment