Skip to content

Instantly share code, notes, and snippets.

@SlyDen
Created June 4, 2018 13:05
Show Gist options
  • Save SlyDen/1a79a5a447b7813448b6b58f6b8d825c to your computer and use it in GitHub Desktop.
Save SlyDen/1a79a5a447b7813448b6b58f6b8d825c to your computer and use it in GitHub Desktop.
got from bitbucket example - wait for container shell script
#!/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