Docker Community Forums

Share and learn in the Docker community.

Healthcheck stays on starting for too long

Hi.

I have a container (running apache), using a custom image that has a healthcheck. The healthcheck itself works as it should (eventually).

This is what I have in my Dockerfile:
HEALTHCHECK --interval=600s --timeout=5s CMD /root/healthcheck.sh

The healthcheck.sh is

#!/bin/bash

statuscode=$(curl -s -o /dev/null -w "%{http_code}" http://localhost)

if [[ $statuscode -ne 200 ]] ;
then
        exit 1;
fi
exit 0;

The problem I am having is, that when I start the container, it takes the 10 minutes before it’s health changes from starting to healthy.

How can I make it so that the container changes to healthy asap? Because during the starting state, the container is unreachable from the web. Could this be a Traefik issue? (That it won’t access a ‘starting’ container?)