如何在 docker 容器内启动 filebeat?
How start filebeat inside docker container?
我尝试在 dockercontainer 中启动 filebeat。
一开始我尝试从这个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"]
在这种情况下,filebeat 正在启动,但它在控制台中工作并且 tomcat 没有启动。
现在我尝试启动 filebeat 作为服务
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"]
但它仍然根本没有启动。
在这些 varint 之间,我还有一些其他的 varint,但它们也不起作用。
例如像这样的
CMD ["/etc/init.d/filebeat", "start"]
如何启动 filebeat?
你的做法有点不对。
想想微服务架构。每个容器需要一个微服务。
尝试以下操作:
这里需要 2 个单独的容器。一个用于 tomcat
,另一个用于 filebeat
。然后,您将在 tomcat
容器中的适当位置安装一个卷,以便在那里获取日志文件。
然后您将在 filebeat
上同时以只读方式挂载相同的日志卷,并开始使用 filebeat 传送日志。
这样您将尊重微服务架构和 docker 哲学。
更新:如果您配置 tomcat 以记录到 stdout 和 stderr,您将能够使用 available 和更新时的列表如下。
Driver Description
none No logs are available for the container and docker logs does not return any output.
json-file The logs are formatted as JSON. The default logging driver for Docker.
local Writes logs messages to local filesystem in binary files using Protobuf.
syslog Writes logging messages to the syslog facility. The syslog daemon must be running on the host machine.
journald Writes log messages to journald. The journald daemon must be running on the host machine.
gelf Writes log messages to a Graylog Extended Log Format (GELF) endpoint such as Graylog or Logstash.
fluentd Writes log messages to fluentd (forward input). The fluentd daemon must be running on the host machine.
awslogs Writes log messages to Amazon CloudWatch Logs.
splunk Writes log messages to splunk using the HTTP Event Collector.
etwlogs Writes log messages as Event Tracing for Windows (ETW) events. Only available on Windows platforms.
gcplogs Writes log messages to Google Cloud Platform (GCP) Logging.
logentries Writes log messages to Rapid7 Logentries.
我尝试在 dockercontainer 中启动 filebeat。
一开始我尝试从这个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"]
在这种情况下,filebeat 正在启动,但它在控制台中工作并且 tomcat 没有启动。 现在我尝试启动 filebeat 作为服务
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"]
但它仍然根本没有启动。 在这些 varint 之间,我还有一些其他的 varint,但它们也不起作用。 例如像这样的
CMD ["/etc/init.d/filebeat", "start"]
如何启动 filebeat?
你的做法有点不对。 想想微服务架构。每个容器需要一个微服务。
尝试以下操作:
这里需要 2 个单独的容器。一个用于 tomcat
,另一个用于 filebeat
。然后,您将在 tomcat
容器中的适当位置安装一个卷,以便在那里获取日志文件。
然后您将在 filebeat
上同时以只读方式挂载相同的日志卷,并开始使用 filebeat 传送日志。
这样您将尊重微服务架构和 docker 哲学。
更新:如果您配置 tomcat 以记录到 stdout 和 stderr,您将能够使用 available 和更新时的列表如下。
Driver Description
none No logs are available for the container and docker logs does not return any output.
json-file The logs are formatted as JSON. The default logging driver for Docker.
local Writes logs messages to local filesystem in binary files using Protobuf.
syslog Writes logging messages to the syslog facility. The syslog daemon must be running on the host machine.
journald Writes log messages to journald. The journald daemon must be running on the host machine.
gelf Writes log messages to a Graylog Extended Log Format (GELF) endpoint such as Graylog or Logstash.
fluentd Writes log messages to fluentd (forward input). The fluentd daemon must be running on the host machine.
awslogs Writes log messages to Amazon CloudWatch Logs.
splunk Writes log messages to splunk using the HTTP Event Collector.
etwlogs Writes log messages as Event Tracing for Windows (ETW) events. Only available on Windows platforms.
gcplogs Writes log messages to Google Cloud Platform (GCP) Logging.
logentries Writes log messages to Rapid7 Logentries.