How to overcome the Container is unhealthy issue when starting multiple docker containers


How to overcome the Container is unhealthy issue when starting multiple docker containers

This is a quick discussion about an error I faced recently when working with docker containers. Hear, I will discuss how we can overcome the error with a few simple steps.

Some times when we attempt to start multiple docker containers we are hit with an issue where the second fails with an error as below. Lets say we have started the is-with-analytics successfully using docker-compose up and now we want to start integrator-broker-bps-analytics/. Some occasions we may come across an error as below.

ERROR: for wso2ei-business-process  Container "802f54b84de9" is unhealthy.
ERROR: for wso2ei-integrator  Container "802f54b84de9" is unhealthy.
ERROR: Encountered errors while bringing up the project. 
 
This issue is caused by the 'healthcheck' failing as it begin to poll before the container was fully started. The way we can overcome this issue is by changing 
the polling interval in docker-compose.yml. Within the yml file you will find a section of configurations as below. So we need to increase the interval and
start_period from its default value where the values are incrementally increased . Once this change is done start the docker container using the  docker-compose up
command.

healthcheck:
      test: ["CMD-SHELL", "curl -k -f https://localhost:9444/carbon/admin/login.jsp"]
      interval: 20s
      timeout: 3s
      retries: 10
      start_period: 40s 
 
 wso2ei-business-process:
    .
    .
    healthcheck:
      test: ["CMD-SHELL", "curl -k -f https://localhost:9445/carbon/admin/login.jsp"]
      interval: 30s
      timeout: 3s
      retries: 10
      start_period: 70s
 

Comments