2024-11-02 13:52:41 +03:00

44 lines
682 B
Bash
Executable File

#!/bin/sh
if [ "$1" = "docker-cli-plugin-metadata" ]; then
cat << HERE
{
"SchemaVersion": "0.1.0",
"Vendor": "Thek4n",
"Version": "0.1.0",
"ShortDescription": "Check health of docker container"
}
HERE
exit
fi
usage() {
cat <<EOF
Usage: docker health CONTAINER
Check health of docker container
EOF
}
shift
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
usage
exit 0
fi
readonly CONTAINER="$1"
if [ -z "$CONTAINER" ]; then
echo "Error: Container name was not specified"
exit 1
fi
set -e
status="$(docker container inspect --format='{{index .State.Health.Status}}' "$CONTAINER")"
readonly status
echo "$status"
test "$status" = 'healthy'