现象:CAS banner 后持续 ERROR Could not determine local host name UnknownHostException: <容器短ID>: Temporary failure in name resolution。 根因:容器 hostname 默认为容器短 ID,当前网络环境下 /etc/hosts 未含该行、 内网 DNS 亦无法解析,InetAddress.getLocalHost() 失败;连锁导致 CAS TicketIdSanitizationUtils 静态初始化抛 ExceptionInInitializerError(票据日志带病)。 修复:ENTRYPOINT 改为 entrypoint.sh,启动前把 hostname 兜底写入 /etc/hosts (已存在则跳过),再 exec java -jar cas.war。不依赖 projman 侧改动,任何部署方式均生效。
This commit is contained in:
+6
-1
@@ -24,4 +24,9 @@ COPY etc/cas/config/log4j2.xml /etc/cas/config/log4j2.xml
|
|||||||
# 业务配置(cas.server.name / cas.authn.jdbc / Redis / custom.login.* 等)来自 projman
|
# 业务配置(cas.server.name / cas.authn.jdbc / Redis / custom.login.* 等)来自 projman
|
||||||
# 配置管理挂载的 /app/config/application.yml(Boot 1.5 自动加载 file:./config/ 且优先于 classpath),镜像保持环境无关。
|
# 配置管理挂载的 /app/config/application.yml(Boot 1.5 自动加载 file:./config/ 且优先于 classpath),镜像保持环境无关。
|
||||||
EXPOSE 8443
|
EXPOSE 8443
|
||||||
ENTRYPOINT ["sh", "-c", "java ${JAVA_OPTS:--Xms512m -Xmx1024m} -Dfile.encoding=UTF-8 -jar /app/cas.war"]
|
# 兜底:把容器 hostname 写入 /etc/hosts。Docker 默认 hostname=容器短ID,某些 network_mode 下
|
||||||
|
# /etc/hosts 不含该行且内网 DNS 无法解析 → InetAddress.getLocalHost 抛 UnknownHostException,
|
||||||
|
# 导致 CAS TicketIdSanitizationUtils 类初始化失败(ExceptionInInitializerError),票据日志带病运行。
|
||||||
|
RUN printf '#!/bin/sh\nHN=$(hostname)\ngrep -qw "$HN" /etc/hosts || echo "127.0.0.1 $HN" >> /etc/hosts\nexec java ${JAVA_OPTS:--Xms512m -Xmx1024m} -Dfile.encoding=UTF-8 -jar /app/cas.war\n' > /app/entrypoint.sh \
|
||||||
|
&& chmod +x /app/entrypoint.sh
|
||||||
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
|
|||||||
Reference in New Issue
Block a user