Answer the question
In order to leave comments, you need to log in
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"]
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"]
CMD ["/etc/init.d/filebeat", "start"]
Answer the question
In order to leave comments, you need to log in
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 .
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"]
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question