Last active
January 1, 2016 02:09
-
-
Save tomoh1r/8077864 to your computer and use it in GitHub Desktop.
docker の稼働中の container 全て落とす関数
This file contains 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
docker_killall() { | |
# 処理が進んでいる container の id を取得 | |
_get_ids() { docker ps | awk 'NR != 1 { print $1 }' ; } | |
# 処理中の conatainer の数を取得 | |
_ps_count=$(_get_ids | wc -l) | |
# 処理中の container が有れば、全て落とす | |
if [[ $_ps_count != 0 ]] ; then | |
_get_ids | xargs docker kill | |
else | |
echo 'docker container is not running.' | |
fi | |
return 0 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment