说明:
1.该镜像内默认配置文件路径是/fluentd/etc/fluent.conf
2.该镜像默认启用tcp的5140和24224端口
3.镜像dockerhub地址:https://hub.docker.com/_/fluentd
4.版本
# 拉取镜像
docker pull fluentd
# 创建挂载目录和配置文件
mkdir -p /opt/fluentd/
cd /opt/fluentd/
vim fluentd.conf
<source>
@type http
@id input_http
bind 0.0.0.0
port 5140
</source>
<match test.cycle>
@type stdout
@id output_stdout
</match>
# 启动容器
docker run -it -d -p 5140:5140 --name=fluentd -v /opt/fluentd/fluent.conf:/fluentd/etc/fluent.conf fluentd
# 查看容器
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
99940246e5b3 fluentd "tini -- /bin/entryp…" 15 seconds ago Up 14 seconds 0.0.0.0:5140->5140/tcp, 24224/tcp fluentd
# 测试
curl -i -X POST -d 'json={"action":"login","user":5555}' http://localhost:5140/test.cycle root@Test-Linux
HTTP/1.1 200 OK
Content-Type: text/plain
Connection: Keep-Alive
Content-Length: 0