Public | Automated Build

Last pushed: a day ago
Short Description
Fluentd Docker image by fluent project: http://www.fluentd.org/
Full Description

Fluentd docker image




This container image is to create endpoint to collect logs on your host.

docker run -d -p 24224:24224 -v /data:/fluentd/log fluent/fluentd

Default configurations are to:

  • listen port 24224 for fluentd forward protocol
  • store logs with tag docker.** into /fluentd/log/docker.*.log (and symlink docker.log)
  • store all other logs into /fluentd/log/data.*.log (and symlink data.log)

This image uses Alpine Linux. Since v0.12.26, we separate tags into vX.XX.XX and vX.XX.XX-onbuild.

Ubuntu based image

This is deprecated. You can use ubuntu-base tag for your build but we don't maintain ubuntu based image with latest fluentd release.
We recommend to fork ubuntu/Dockerfile for your case.

Configurable ENV variables

Environment variable below are configurable to control how to execute fluentd process:

FLUENTD_CONF

It's for configuration file name, specified for -c.

If you want to use your own configuration file (without any optional plugins), you can use it over this ENV variable and -v option.

  1. write configuration file with filename yours.conf
  2. execute docker run with -v /path/to/dir:/fluentd/etc to share /path/to/dir/yours.conf in container, and -e FLUENTD_CONF=yours.conf to read it

FLUENTD_OPT

Use this variable to specify other options, like -v or -q.

How to build your own image

It is very easy to use this image as base image. Write your Dockerfile and configuration files, and/or your own plugin files if needed.

FROM fluent/fluentd:latest
MAINTAINER your_name <...>
USER fluent
WORKDIR /home/fluent
ENV PATH /home/fluent/.gem/ruby/2.2.0/bin:$PATH
RUN gem install fluent-plugin-secure-forward
EXPOSE 24284
CMD fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT

Files below are automatically included in build process:

  • fluent.conf: used instead of default file
  • plugins/*: copied into /fluentd/plugins and loaded at runtime

Note: Default image removed several apk packages, build-base and ruby-dev, to keep docker image small. If you want to install the plugin which depends on native extension gems, needs to re-install these packages to build it.

Testing

docker run --log-driver=fluentd --log-opt fluentd-address=192.168.0.1:24224 IMAGE echo "Hello Fluentd"

Should produce a log-file with Hello Fluentd, depending on you fluent.conf file.

References

Docker Logging | fluentd.org

Fluentd logging driver - Docker Docs

Docker Pull Command
Owner
fluent
Source Repository

Comments (9)
rajkirangade
8 months ago

@activatedgeek
The docker logscommand is available only for the json-file and journald logging drivers.

repeatedly
9 months ago

Sorry we can't notice the comment in the DockerHub so don't use this comment for reporting issue or asking question.
Use github repository or fluentd mailing list instead: https://github.com/fluent/fluentd-docker-image / https://groups.google.com/forum/#!forum/fluentd

apollov
10 months ago

This start script helped me to finally make plugin work:

#!/bin/sh

export PATH=/home/fluent/.gem/ruby/2.3.0/bin:$PATH
export GEM_PATH=/home/fluent/.gem/ruby/2.3.0:$GEM_$PATH
fluent-gem install fluent-plugin-elasticsearch
exec fluentd -c /fluentd/etc/$FLUENTD_CONF -p /fluentd/plugins $FLUENTD_OPT
activatedgeek
a year ago

Doesn't the logging driver work with docker-compose?

I get the following error: "logs" command is supported only for "json-file" and "journald" logging drivers (got: fluentd)

jesaja
a year ago

Shouldn't this container print log messages to stdout due to the stdout_filter? For me the log messages end up in the files in /fluentd/log/. But except the output of fluentd itself nothing is written to stdout in the container.
I'm not familiar with fluentd, maybe I understand something wrong?

repeatedly
a year ago

Thanks for the comment. I just added tags. I thought DockerHub builds the image for each github tag automatically...

sstiehl
a year ago

+1 for tagging

robertfirek
a year ago

I suggest to add version-specific tags. Dockerfile on this page is out of data and it doesn't show the latest version of fluentd installed in the image.

chiefy
2 years ago

Can you tag specific versions (not just 'latest')? Thanks!