DEV Community

Cover image for Setting up fluent bit using docker
Minhaz
Minhaz

Posted on

Setting up fluent bit using docker

Purpose

This is a step by step guide about how to setup fluent bit with docker.

The fluent bit official installation guide only had documentation about how to run fluent bit using docker but it didn't mention how to set it up.

So this is my solution to how to setup fluent bit using docker commands only. No docker compose.

Steps

Designate a folder where you'll store the fluent bit configs. In my case the directory is D:/fluent-bit

Start a temporary container to copy default configs from

docker run -d --rm --name temp cr.fluentbit.io/fluent/fluent-bit
Enter fullscreen mode Exit fullscreen mode

Copy the configs to your designated folder

docker cp temp:/fluent-bit/etc/ D:/fluent-bit
Enter fullscreen mode Exit fullscreen mode

Stop the temporary container

docker stop temp
Enter fullscreen mode Exit fullscreen mode

Now start fluent bit with the config folder mounted as a volume

docker run -dti --name fluent-bit -v D:/fluent-bit:/fluent-bit/etc cr.fluentbit.io/fluent/fluent-bit
Enter fullscreen mode Exit fullscreen mode

By default fluent bit is configured to output to std out. So see docker log to see what fluent bit is logging.

docker logs fluent-bit
Enter fullscreen mode Exit fullscreen mode

You'll see something like this
docker logs output

Now to make sure that fluent bit is indeed taking configs from our folder. Go to the designated folder and open the fluent-bit.conf folder

Look for this string

tag cpu.local
Enter fullscreen mode Exit fullscreen mode

Change it to this

tag CPU_LOCAL
Enter fullscreen mode Exit fullscreen mode

Save the file and restart the container

docker restart fluent-bit
Enter fullscreen mode Exit fullscreen mode

Now look at docker logs

docker logs fluent-bit
Enter fullscreen mode Exit fullscreen mode

Notice that the logs are different.
Config change worked

References

  1. https://github.com/minhaz1217/devops-notes/tree/master/65.%20setting%20up%20fluent%20bit%20with%20docker
  2. https://docs.fluentbit.io/manual/installation/docker

Top comments (0)