I was looking through docker hub, etc and generally I can find a mechanism to look up healthchecks for different containers. I didnt see any for FluentD though.
I would like to essentially do a curl from the container to confirm it is healthy.
My issue is that i have underlying containers which will start immediately but fail because 24224 on fluentd is not available.
So what I thought to do was to write similar to:
version: "3.3"
services:
fluentd:
ports:
- "24224:24224"
- "24224:24224/udp"
healthcheck:
test: curl --fail -s http://localhost:24224 || exit 1
interval: 30s
timeout: 30s
retries: 5
start_period: 30s
sample:
depends_on:
fluentd:
condition: container_healthy
In this sample test, It seems that the Curl command I set up was not the correct command to validate the health of fluentd.
I did not seem to find anything specific to this from my searches, but maybe others might know what to do.
My error was: Error response from daemon: failed to initialize logging driver: dial tcp [::1]:24224: connect: connection refused
when it attempts to set up logging to fluentd.
I made it work through using netcat but it requires a custom Dockerfile for installing netcat:
FROM fluent/fluentd:v1.17-debian-1
USER root
RUN apt-get update && \
apt-get install -y build-essential libpq-dev curl netcat-openbsd && \
fluent-gem install fluent-plugin-postgres && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
USER fluent
ENTRYPOINT ["tini", "--", "/bin/entrypoint.sh"]
CMD ["fluentd"]
Compose configuration:
fluentd:
build:
context: .
dockerfile: fluentd.Dockerfile
container_name: fluentd
volumes:
- ./fluentd.conf:/fluentd/etc/fluentd.conf
ports:
- "24224:24224"
- "24224:24224/udp"
healthcheck:
test: ["CMD", "nc", "-z", "localhost", "24224"]
interval: 10s
timeout: 5s
retries: 3