Redis service docker-compose health check
Published on 2022-12-17 • Modified on 2022-12-17
This snippet shows how to put in place a health check for a docker Redis service in a docker-compose
file. There is the ping function of Redis, which is precisely what we need in this case.
# Cache ——————————————————————————————————————————————————————————————————————
# Redis (official image)
# https://hub.docker.com/_/redis
redis:
container_name: strangebuzz-redis-1
image: redis:5.0.13-alpine
ports:
- '6389:6379'
healthcheck:
test: ["CMD-SHELL", "redis-cli -h 127.0.0.1 ping | grep 'PONG' || exit 1"]
interval: 10s
timeout: 30s
retries: 10
More on Stackoverflow Read the doc More on the web Random snippet
Call to action
Did you like this post? You can help me back in several ways: (use the "reply" link on the right to comment or to contact me )
- Report any error/typo.
- Report something that could be improved.
- Like and repost!
- Follow me on Bluesky 🦋
- Subscribe to the RSS feed.
- Click on the More on Stackoverflow buttons to make me win "Announcer" badges 🏅.
Thank you for reading! And see you soon on Strangebuzz! 😉