我正在使用 docker-compose.yml 来启动我的服务。所有服务看起来都像这样:
A-service:
image: A-service
restart: always
network_mode: host
logging:
driver: journald
options:
tag: "{{.ImageName}}/{{.Name}}/{{.ID}}"
fluent-bit:
image: 'bitnami/fluent-bit:latest'
restart: always
network_mode: host
command: /fluent-bit/bin/fluent-bit -c /fluent-bit/etc/fluent-bit.conf
volumes:
- ./service/config/fluent-bit.conf:/fluent-bit/etc/fluent-bit.conf
- type: bind
source: /run/log
target: /run/log
当我运行时,journalctl -e -f -u docker
我看到所有日志都被记录得很好。我遇到的问题是我的 fluent-bit 容器在从 systemd 收集时似乎无法获取任何数据:
fluent-bit.conf:
[SERVICE]
Flush 5
Daemon Off
Log_Level debug
[INPUT]
Name systemd
Tag *
[OUTPUT]
Name stdout
Match *
我想这可能是因为它在容器中并且无法到达日志位置,但绑定目录/run/log:/run/log
没有效果。
所以我的问题是:当它在容器内时,流利的位可以到达 systemd 并阅读日志吗?如果是的话 - 我怎样才能做到这一点?