I have a container image that has two binaries - application
and health
. The application
exposes two endpoints - one for application at 0.0.0.0:8080/app
and a health check endpoint at localhost:9000/health
. These endpoints are created using Fastify. The health
binary does a HTTP GET
on the health check endpoint and the binary is invoked by the healthcheck.test
in the Docker Compose file. The service
uses network_mode
as host
because the application must connect to Kafka on a different host.
The health check never goes through because the health
binary hangs. I ran a docker exec -it
for the container and ran the health
binary in container shell. The command never finishes - it won’t even terminate with a timed out message - just keeps on running. However, on the host where the Docker Compose project is running, if I do a curl http://localhost:9000/health
I get a health output correctly.
So, why does the health
binary hang?
This is the Compose YAML.
services:
payload:
container_name: payload
image: username/payload:v0.0.0
env_file:
- ./conf/payload.env
network_mode: "host"
healthcheck:
test: /health
interval: 2s
timeout: 1s
retries: 3
start_period: 10s