我正在查看 docker hub 等,通常我可以找到一种机制来查找不同容器的运行状况检查。 不过我没有看到 FluentD 的任何内容。
我想从容器中做一个卷曲以确认它是健康的。
我的问题是我有底层容器,它们会立即启动但会失败,因为 fluidd 上的 24224 不可用。
所以我想做的是写类似:
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
在这个示例测试中,我设置的 Curl 命令似乎不是验证 Fluentd 运行状况的正确命令。
我似乎没有从我的搜索中找到任何具体的内容,但也许其他人可能知道该怎么做。
我的错误是:
Error response from daemon: failed to initialize logging driver: dial tcp [::1]:24224: connect: connection refused
当它尝试设置日志记录到 fluidd 时。
我通过使用 netcat 使其工作,但它需要一个自定义 Dockerfile 来安装 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"]
编写配置:
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