Docker compose docker compose:docker容器中的Rsyslog和Fluentd不通信

Docker compose docker compose:docker容器中的Rsyslog和Fluentd不通信,docker-compose,fluentd,rsyslog,Docker Compose,Fluentd,Rsyslog,我正在做一些“游戏”,看看使用Rsyslog将数据发送到Fluentd作为集中服务器,然后将结果发送到ElasticSearch的可行性。查看文档,如果rsyslog.conf文件中设置了以下内容,rsyslog可以将数据转发到fluentd: $WorkDirectory /var/lib/rsyslog # where to place spool files $ActionQueueFileName fwdRule1 # unique name prefix for spool files

我正在做一些“游戏”,看看使用Rsyslog将数据发送到Fluentd作为集中服务器,然后将结果发送到ElasticSearch的可行性。查看文档,如果rsyslog.conf文件中设置了以下内容,rsyslog可以将数据转发到fluentd:

$WorkDirectory /var/lib/rsyslog # where to place spool files
$ActionQueueFileName fwdRule1 # unique name prefix for spool files
$ActionQueueMaxDiskSpace 1g   # 1gb space limit (use as much as possible)
$ActionQueueSaveOnShutdown on # save messages to disk on shutdown
$ActionQueueType LinkedList   # run asynchronously
$ActionResumeRetryCount -1    # infinite retries if host is down
*.* @fluentd:9881
*.* @@fluentd:9881
docker-compose.yml文件为:

version: '3'
services:
  rsyslog:
    image: vimagick/rsyslog
    volumes:
      - ./rsyslog/config/rsyslog.conf:/etc/rsyslog.conf
      - ./rsyslog/data:/var/log
    ports:
      - "8514:514"
      - "8514:514/udp"
      - "1601:1601"
    depends_on:
      - "fluentd"
    networks:
      - demo-network
    environment:
      - TX=UTC
  fluentd:
    build: ./fluentd
    volumes:
      - ./fluentd/conf:/fluentd/etc
    ports:
      - "9880:9880"
      - "9880:9880/udp"
      - "9881:9881"
      - "9881:9881/udp"
    networks:
      - demo-network
networks:
  demo-network:
当我开始使用docker compose up时,会看到以下输出:

fluentd_1  | 2020-01-09 14:14:48 +0000 [info]: spawn command to main:  cmdline=["/usr/local/bin/ruby", "-Eascii-8bit:ascii-8bit", "/usr/local/bundle/bin/fluentd", "-c", "/fluentd/etc/fluent.conf", "-p", "/fluentd/plugins", "--under-supervisor"]
rsyslog_1  | rsyslogd: cannot connect to fluentd:9881: Connection refused [v8.1911.0 try https://www.rsyslog.com/e/2027 ]
rsyslog_1  | rsyslogd: cannot connect to fluentd:9881: Connection refused [v8.1911.0 try https://www.rsyslog.com/e/2027 ]

rsyslog容器无法通过主机名与fluentd容器通信。有人知道为什么会出现这种情况吗?

您确定fluentd正在监听端口9881吗?有。那是verified@EdSoftwareArchitect你能分享你的
fluent.conf
?(只要
源代码部分就足够了)。并共享当fluentd容器出现时发出的日志。