Created
February 7, 2018 07:52
-
-
Save stefanbuck/8d9e2bd6b939e6ab792a69c99a0352fe to your computer and use it in GitHub Desktop.
Returns the health status for the given docker image
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 | |
IMAGE_NAME=$1 | |
# Grep container id | |
CONTAINER_ID=$(docker ps -qf "name=$IMAGE_NAME") | |
if [ "$CONTAINER_ID" ] ; then | |
# Get the health status | |
STATUS=$(docker inspect --format='{{json .State.Health.Status}}' $CONTAINER_ID); | |
echo $STATUS | |
fi | |
if ! [ "$CONTAINER_ID" ] ; then | |
echo "unavailable" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment