說明:
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