![](/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.