Created
July 23, 2018 16:32
-
-
Save krukru/8c6003c43fe5b58175bee0431c3ebfdd to your computer and use it in GitHub Desktop.
Wait until docker container is healthy
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
#!/usr/bin/env bash | |
CONTAINER_HEALTH=$(docker inspect --format='{{json .State.Health.Status}}' $1) | |
if [ -z $CONTAINER_HEALTH ]; then | |
echo "Container not found" | |
exit 1 | |
fi; | |
until test $CONTAINER_HEALTH = "\"healthy\""; do | |
echo "Waiting..." | |
sleep 1 | |
CONTAINER_HEALTH=$(docker inspect --format='{{json .State.Health.Status}}' $1) | |
if [ -z $CONTAINER_HEALTH ]; then | |
echo "Container crashed" | |
exit 1 | |
fi; | |
done | |
echo "Ready!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment