Files
wyczarujprezent.pl/modules/ps_eventbus/.docker/wait-for-container.sh
2024-10-28 22:14:22 +01:00

25 lines
556 B
Bash

#!/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'