Why healthcheck status stays 'unhealthy'?

Hi guys, I would like to know what’s the criteria in determining whether a service is healthy or unhealthy?

I have a healthcheck in my docker-compose.yml, but no matter what I do, the status stays ‘unhealthy’

I posted a question here in SO with more details:

The weird thing is, the healthcheck is working, all services are working.

But I do not want this thing to bite me later in production. There must be something I do not understand here.