作者:yyuunn传奇 | 来源:互联网 | 2023-02-10 11:17
我尝试在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之后,我有一些其他的变形,但它们也不起作用.例如像这样的东西
CMD ["/ etc/init.d/filebeat","start"]
我该如何开始filebeat?
1> Farhad Farah..:
你的方法有点不对劲.想想微服务架构.每个容器需要一个微服务.
请尝试以下方法:
这里需要2个独立的容器.一个为tomcat
另一个为filebeat
.然后,您将在tomcat
容器中的适当位置安装卷,以便在那里获取日志文件.
然后,您将同时filebeat
以只读方式挂载相同的日志卷,并开始使用filebeat发送日志.
通过这种方式,您将荣获微服务架构和docker哲学.
更新:如果您将tomcat配置为登录到stdout和stderr,您将能够使用各种可用的日志驱动程序,并且更新时的列表如下所示.
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.