![](/img/trans.png)
[英]/actuator/info Endpoint not working with spring boot 2.5.0
[英]Spring Boot - Actuator Metrics Endpoint not working in docker image
在我的 Spring 引导应用程序 Yaml 中,我有:
management:
metrics:
export:
simple:
enabled: true
endpoints:
web:
exposure:
include: "*"
然而,当我打
localhost:8080/actuator/metrics
它在 spring 启动独立应用程序中工作,但在 docker 映像中,端点执行器/指标不起作用,它将我重定向到默认页面,该应用程序仍然可以正常工作。
我的 docker 文件:
FROM openjdk:11-jre-buster
RUN apt update && apt install curl -y \
&& rm -rf /var/lib/apt/lists/*
MAINTAINER xxxxx
ARG VERSION
ENV SERVER_PORT 80
ENV JAVA_OPTS -Xmx1g
# add this to solve buster sso issue
ENV OPENSSL_CONF=/etc/ssl
ENV SPRINGPROFILES=actuator
WORKDIR /app
COPY maven/docker-package/ /app
# Tesseract installation
RUN apt-get install apt-transport-https && \
echo "deb [trusted=yes] https://notesalexp.org/tesseract-ocr/buster/ buster main" >> /etc/apt/sources.list && \
apt-get update -oAcquire::AllowInsecureRepositories=true && \
apt-get install notesalexp-keyring -oAcquire::AllowInsecureRepositories=true && \
apt-get update && \
apt-get -y install tesseract-ocr
EXPOSE ${SERVER_PORT}
HEALTHCHECK --interval=5s --timeout=5s --retries=3 \
CMD curl -f http://localhost:80/actuator/health || exit 1
ENTRYPOINT ["sh", "/app/docker-entrypoint.sh"]
码头入口点.sh:
java $JAVA_OPTS -Djava.security.egd=file:/dev/./urandom -Dlicense.path=/app/licenses/ "-Dspring.profiles.active=${SPRINGPROFILES}" -Dlogging.config=/app/config/log4j2.xml -Dserver.port=80 -jar /app/app-executable.jar
我错过了什么? 是否需要进行任何配置才能公开 docker 中的指标? 感谢您的回复。
您应该在运行 docker 时打开端口:
sudo docker run **** 8080/8080 *****
复制 Config 目录下的 application.yml 并将其设置到我的应用程序的 configDir 中,然后将其移动到图像中解决了我的问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.