Skip to content

Instantly share code, notes, and snippets.

@stefanbuck
Created February 7, 2018 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stefanbuck/8d9e2bd6b939e6ab792a69c99a0352fe to your computer and use it in GitHub Desktop.
Save stefanbuck/8d9e2bd6b939e6ab792a69c99a0352fe to your computer and use it in GitHub Desktop.
Returns the health status for the given docker image
#!/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