如何对运行在Docker Container中的Spring Boot应用程序进行健康检查? [英] How to do a health check of a Spring Boot application running in a Docker Container?
本文介绍了如何对运行在Docker Container中的Spring Boot应用程序进行健康检查?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Docker容器中运行一个Spring Boot应用程序,使用Docker文件在容器中启动该应用程序。如何检查容器内的Spring Boot应用程序的运行状况?
如果容器停止或应用程序未运行,则需要根据健康检查自动重启容器或应用程序。这样,我可以确保Spring Boot应用程序始终处于启动和运行状态。
推荐答案
如果要将Spring Bootactuator/health
用作扩展坞健康检查,您必须将其添加到扩展坞撰写文件中:
healthcheck:
test: "curl --fail --silent localhost:8081/actuator/health | grep UP || exit 1"
interval: 20s
timeout: 5s
retries: 5
start_period: 40s
编辑:
这里的端口是management.server.port
。如果未指定,则应为server.port value
(默认为8080)
这篇关于如何对运行在Docker Container中的Spring Boot应用程序进行健康检查?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文