Docker 安装 Fluentd - 详细步骤指南
以下是在 Docker 中安装 Fluentd 的步骤:
-
**在 Docker 中安装 Fluentd 的镜像:**可以使用以下命令从 Docker Hub 中下载 Fluentd 的官方镜像。
dockr pull fluent/fluentd
2. **创建 Fluentd 的配置文件:**在 Docker 中,可以使用环境变量或者挂载配置文件的方式来配置 Fluentd。以下是使用挂载配置文件的方式。
首先,创建一个名为'fluentd.conf' 的文件,内容如下:
<match **> @type stdout
该配置文件指定了 Fluentd 的输入源为 forward 协议的 24224 端口,输出到标准输出。
3. **运行 Fluentd 容器:**使用以下命令运行 Fluentd 容器,并将配置文件挂载到容器中。
dockr run -it --name fluentd -v /path/to/fluentd.conf:/fluentd/etc/fluentd.conf fluent/fluentd
其中,'/path/to/fluentd.conf' 为本地的配置文件路径,'/fluentd/etc/fluentd.conf' 为容器内的配置文件路径。
4. **测试 Fluentd:**可以使用以下命令在容器内发送测试数据,查看 Fluentd 是否正确接收并输出。
echo '{"message":"hello, fluentd"}' | fluent-cat test
然后,在容器的日志中可以看到输出的内容。
2021-05-14 06:29:50.000000000 +0000 test: {"message":"hello, fluentd"}
可以看到,Fluentd 正确接收并输出了测试数据。
原文地址: https://www.cveoy.top/t/topic/kNCy 著作权归作者所有。请勿转载和采集!