Search code examples
amazon-web-servicesdockeramazon-ecs

CMD busybox doesn't work in task definition health check


In my Dockerfile, I have created a healthcheck

HEALTHCHECK --interval=5s --timeout=2s --start-period=5s --retries=3 CMD ["busybox", "nc", "-z", "localhost", "12345"]

This health check is working in the Docker environment as my container is displaying healthy in docker ps STATUS.

Now, I wanted to replicate the same health check method in ECS task definition and had set the Healthcheck Command in AWS Console to be

CMD, busybox, nc -z localhost 12345

But the Task Health Status is always displaying `UNHEALTHY. Is my configuration wrong? Does AWS ECS support non-shell command health check?

Sidenote: I'm running a fluentbit:1.4-debug image that has busybox available.


Solution

  • Solved by having comma separated for all argument and nc directly. So the final Command looks like

    CMD,nc,-z,localhost,12345