Created
August 14, 2015 10:21
-
-
Save violetyk/afd8a215ae643f0dcbac to your computer and use it in GitHub Desktop.
docker run をコンテナの並列実行
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/bash | |
DIRS=("/bin" "/etc" "/usr") # SUCCESS | |
# DIRS=("/bin" "/etc" "/usr" "/hogehoge") # FAILURE | |
IDS="" | |
for D in ${DIRS[*]}; do | |
IDS=$IDS" `docker run -d ubuntu du -sh $D`" | |
done | |
echo "containers : $IDS" | |
# 各コンテナの結果を集める | |
RESULT=0 | |
for S in `time docker wait $IDS`; do | |
RESULT=`expr $RESULT + $S` | |
done | |
# 失敗してたら各コンテナのログを表示 | |
if [ $RESULT -eq 0 ]; then | |
echo "SUCCESS!" | |
exit 0 | |
else | |
for c in ${IDS[*]}; do | |
docker logs $c | |
done | |
echo "FAILURE!!" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment