I am running my spring boot web application as docker service and it is running fine without health check.
But when I tried to create docker service with health check options, my service gets restart automatically after some time (maybe after health heck timeout) and it never is stable.
I create \health
rest endpoint and is simply return ok
Here is command which I am using to create service with health check option and without it.
Command with health check option:
sudo docker service create \
--health-cmd="curl --silent --fail localhost:8090/health || exit 1" \
--health-interval=5s \
--health-retries=12 \
--health-timeout=2s \
--health-start-period=60s \
--name=my-service \
-p "8090:8090" \
my-docker-img
output:
s43fbah1qdlxb01s4x5veecos
overall progress: 0 out of 1 tasks
1/1: starting [============================================> ]
Command without health check:
sudo docker service create \
--name=my-service \
-p "8090:8090" \
my-docker-img
My spring boot application takes 20s to up and running.