G
G
gubber2017-03-02 17:21:02
Docker
gubber, 2017-03-02 17:21:02

How to run filebeat inside Docker container?

Good afternoon.
Please tell me how to run filebeat inside a docker container.
I started with this Dockerfile

FROM tomcat:8.5
RUN rm -Rf /usr/local/tomcat/webapps/ROOT/*
RUN mkdir /usr/local/tomcat/webapps-my
COPY filebeat/ /opt/filebeat/
RUN chmod +x /opt/filebeat/filebeat
COPY db-creator.jar /opt/db-creator/
COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh"]
ENTRYPOINT ["/opt/filebeat /filebeat", "-e", "-c", "/opt/filebeat/filebeat.yml"]
COPY server.xml /usr/local/tomcat/conf
COPY my.war /usr/local/tomcat/webapps- my/ROOT.war
CMD ["catalina.sh", "run"]

In this state, filebeat starts but does not release control, after which the tomcat does not start.
Now I have reached this option
FROM tomcat:8.5
RUN curl -L -O https://artifacts.elastic.co/downloads/beats/fileb...
RUN dpkg -i filebeat-5.2.2-amd64.deb
COPY filebeat.yml /etc/filebeat
RUN update-rc.d filebeat defaults 95 10
COPY db-creator.jar /opt/db-creator/
COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/docker-entrypoint.sh "]
RUN rm -Rf /usr/local/tomcat/webapps/ROOT/*
COPY server.xml /usr/local/tomcat/conf
RUN mkdir /usr/local/tomcat/webapps-my
COPY my.war /usr/local /tomcat/webapps-iqp/ROOT.war
CMD ["catalina.sh", "run"]

But that's not how the service starts.
There were also intermediate options in the form
CMD ["/etc/init.d/filebeat", "start"]

Still won't start

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Tyranron, 2017-03-02
@Tyranron

By default, it is assumed that only one process is running in one container. If you need more than one process, either separate them into separate containers (Tomcat separately, Filebeat separately), or add some kind of supervisor to the container that will supervise several processes and watch so that they do not fall. Docker images usually use the s6 supervisor, which can be conveniently used via s6-overlay .

G
gubber, 2017-03-02
@gubber

As a result, I had to do a workaround:
create start.sh
#!/bin/bash
OUTPUT_LOGFILES=""
service filebeat start
OUTPUT_LOGFILES+="/var/log/filebeat/filebeat "
cd /usr/local/tomcat/
bin/catalina.sh start
OUTPUT_LOGFILES+="/usr/local/tomcat/logs /catalina*.log"
touch $OUTPUT_LOGFILES
tail -f $OUTPUT_LOGFILES &
wait
And the final Dockerfile looks like this

FROM tomcat:8.5
RUN curl -L -O https://artifacts.elastic.co/downloads/beats/fileb...
RUN dpkg -i filebeat-5.2.2-amd64.deb
COPY filebeat.yml /etc/filebeat
COPY ./start.sh /
RUN chmod +x /start.sh
COPY db-creator.jar /opt/db-creator/
COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
ENTRYPOINT ["/ docker-entrypoint.sh"]
RUN rm -Rf /usr/local/tomcat/webapps/ROOT/*
COPY server.xml /usr/local/tomcat/conf
RUN mkdir /usr/local/tomcat/webapps-my
COPY my. war /usr/local/tomcat/webapps-my/ROOT.war
CMD ["/start.sh"]

There is only one problem with it - it does not capture tomcat logs. But that's because I can't "cook cats".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question