Skip to content

DockerでFluentdを構築 ​

Fluentdおよび、ログ収集対象とするnginxを起動します。

  • docker-compose.yaml
yaml
services:
  fluentd:
    container_name: fluentd
    image: fluent/fluentd:latest
    hostname: fluentd
    ports:
      - "24224:24224"
    volumes:
      - ./volumes/fluentd/etc:/fluentd/etc
    healthcheck:
      test: ["CMD-SHELL", "/bin/bash -c '</dev/tcp/127.0.0.1/24224' || exit 1"]
      interval: 10s
      timeout: 5s
      retries: 3
  nginx:
    container_name: nginx
    image: nginx:stable
    hostname: nginx
    ports:
      - 80:80
    depends_on:
      fluentd:
        condition: service_healthy
    logging:
      driver: "fluentd"
      options:
        fluentd-address: host.docker.internal:24224
        tag: nginx
  • fluent.conf
ini
<match **>
  @type stdout
</match>

<source>
  @type forward
  port 24224
  bind 0.0.0.0
</source>