dockeramazon-ecsaws-fargate

Cannot get docker healthcheck to work with ECS Fargate v 1.4.0


I have a health check defined for my ECS Fargate Service, it works when I test locally and works with Fargate v 1.3.0.

But when I change to Fargate Platform version 1.4.0 it always turns unhealthy. But the actual service is working. I can access the service on the containers public IP.

The health check is defined as:

"CMD-SHELL", "curl --fail http://localhost || exit 1"

Solution

  • So we looked into this and there's an issue in platform version 1.4 where, if the health check outputs anything to stderr a false negative occurs. We will, obviously, fix this but in the meantime you can work around this by (in this case) run curl in silent mode or simply redirect stderr output to /dev/null:

    curl -s --fail http://localhost || exit 1
    

    or

    curl --fail http://localhost 2>/dev/null || exit 1
    

    Should unblock you for now.