Created
June 4, 2018 13:05
-
-
Save SlyDen/1a79a5a447b7813448b6b58f6b8d825c to your computer and use it in GitHub Desktop.
got from bitbucket example - wait for container shell script
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
#!/bin/bash | |
if [ $# -ne 1 ]; then | |
echo "Usage: $0 <container-id>" | |
exit 1 | |
fi | |
function getContainerHealth { | |
docker inspect --format "{{json .State.Health.Status }}" $1 | |
} | |
while STATUS=$(getContainerHealth $1); [ "$STATUS" != '"healthy"' ]; do | |
if [ -z "$STATUS" ]; then | |
echo "Failed to retrieve status of docker container $1" | |
exit 1 | |
fi | |
if [ "$STATUS" == '"unhealthy"' ]; then | |
echo "Failed to start container $1. See docker logs for details." | |
exit 1 | |
fi | |
printf '.' | |
sleep 1 | |
done | |
printf $'\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment