Created
April 9, 2018 10:06
-
-
Save rasschaert/9143eddf2f65e7ec5bf0b632efa63c30 to your computer and use it in GitHub Desktop.
Live Docker health check
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
# If you have a healthcheck defined in your Dockerfile | |
# | |
# HEALTHCHECK --interval=5s --timeout=4s --start-period=10s CMD-SHELL pg_isready -U postgres -t 0 || exit 1 | |
# | |
# or in your docker-compose.yml | |
# | |
# healthcheck: | |
# test: ["CMD-SHELL", "pg_isready -U postgres -t 0 || exit 1"] | |
# timeout: 4s | |
# interval: 5s | |
# start_period: 10s | |
# | |
# You can view the result of those checks in the docker inspect json output. You can filter it out with jq. | |
# I like to watch it live as the container starts up when I'm working on a new setup, to see if I tuned the timing parameters correctly. | |
watch -n1 "docker inspect compose_postgres_1 2>/dev/null | jq '.[0].State.Health' 2>/dev/null" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment