Filebeat can not get enviroment variable in docker

Hi All,

Here is my config in filebeat.yml:


Result in the container is:
root@07acb280f9e5:/# echo ${SPRING_PROFILES_ACTIVE}

But I got issue went container start filebeat (version 5.1.1):
Exiting: error unpacking config data: missing field accessing 'fields.env' (source:'/etc/filebeat/filebeat.yml')

I have seen a topic: Cannot use env variables in filebeat! but in my container cannot use the command: systemctl import-environment:
root@07acb280f9e5:/# systemctl import-environment
bash: systemctl: command not found

Do you have another idea to solve this problem?

Thank you.

Have you build a customer container?

How do you start filebeat from within the container?

Yes, it's a customer container.

I have a file it run when start container, in this file it have a command:

FROM debian:stretch

# Start filebeat
/etc/init.d/filebeat start

Which init script are you using? Init scripts normally start processes in the background and return. In this case the container will shutdown right after startup, cause the script didn't block.

Have you had a look at the official docker containers?

Init script has been created default after command install filebeat 5.5.1 (dpkg -i filebeat-5.5.1-amd64.deb - downloaded from in Docker file. This way can not work on Docker container?

No, init scripts are in general not supposed to be used directly from within docker containers. This is true for any init script, not just Beats.
Users wanting to run multiple services in one container often use runit. But this is not required just for running a container. Tools/services often have custom scripts as entry-points. See official docker containers.

Why do you build your own container instead of building on or reusing the existing containers?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.