Customize Fluentd docker image
What is Fluentd
Briefly speaking, Fluentd is an open source data collector, which lets you unify the data collection and consumption for a better use and understanding of data. Click here for more details.
You could use Fluentd by either installing the Fluentd agent manually as the daemon process or running a docker image. This article will mainly focus on how to build you own Fluentd docker image which fits your use cases.
Get started
Create folder with the following skeleton
#$:~/fluentd-docker$ tree .
.
├── Dockerfile
├── fluent.conf
└── plugins
1 directory, 2 filesEdit the
Dockerfile
FROM fluent/fluentd:v1.4-debian-onbuild
# Use root account to use apt
USER root
# below RUN includes plugin as examples elasticsearch is not required
# you may customize including plugins as you wish
RUN buildDeps="sudo make gcc g++ libc-dev ruby-dev" \
&& apt-get update \
&& apt-get install -y --no-install-recommends $buildDeps \
&& apt-get install -y libsystemd0 \
&& sudo gem install fluent-plugin-vmware-loginsight \
&& sudo gem install fluent-plugin-systemd -v 1.0.1 \
&& sudo gem sources --clear-all \
&& SUDO_FORCE_REMOVE=yes \
apt-get purge -y --auto-remove \
-o APT::AutoRemove::RecommendsImportant=false \
$buildDeps \
&& rm -rf /var/lib/apt/lists/* \
/home/fluent/.gem/ruby/2.3.0/cache/*.gem
USER fluentfluent.confis required to build the custom docker image. It could be a default conf file. When you run the docker image the config file could be replaced from thedocker runcommand.
The following fluent.conf is just an example for fetching the systemd log:
You could leave plugins folder empty in this example
Build the new image by using
docker buildcommandRefer to the official doc for running the container with your own configuration files and other additional options.
Last updated
Was this helpful?