Healthcheck to public URL circular failure

I’m trying to implement healthcheck in a container.

My healthchecker script obtains a login token and then uses this to access the public URL for the service. This is necessary as all URLs are protected by oauth, and require a login token with valid redirect URIs and origins.

If the container is started without healthcheck enabled, then the check script will work fine, it reports the service as available.

If I enable docker healthcheck it doesn’t work - because the URL is not available before the first successful health check. Which can never be successful, and so we have a circular health check that can never complete.

What would be the option in this case, do you think? I can’t access the service inside the container by its internal http://localhost (etc) address as the filters deny the request.

Am I going about this the wrong way?

Thanks