[alibaba/arthas]spring boot 集成arthas,只能在容器内部访问

2025-11-10 426 views
7
环境信息 arthas-boot.jar 或者 as.sh 的版本: 3.4.5 Arthas 版本: 3.4.5 操作系统版本: xxx 目标进程的JVM版本: xxx 执行arthas-boot的版本: xxx 重现问题的步骤 引入arthas com.taobao.arthas arthas-spring-boot-starter 3.4.5

2.配置arthas arthas.http-port=8563 arthas.telnet-port=3658 arthas.session-timeout=1800 arthas.ip= 0.0.0.0

制作镜像 FROM 172.25.40.208:9090/pids_test/openjdk:8-jdk-alpine

MAINTAINER Long Mingfeng yxlmf@126.com

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ echo "Asia/Shanghai" > /etc/timezone && \ mkdir -p /home/pids/ && \ chmod -R 777 /home/pids/

ENV APP_NAME="pids-source-manage"

ADD target/${APP_NAME}.jar /home/pids/app.jar

ENV JAVA_OPTS=""

ENV APP_OPTS=""

设置需要暴露的端口号

EXPOSE 9003 EXPOSE 8563

ENTRYPOINT [ "sh", "-c", "java $JAVA_OPTS -jar /home/pids/app.jar $APP_OPTS" ]

4.运行docker,不能通过宿主机ip访问 进入docker容器内部发现,8563不能被外部访问 / # netstat -anltp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:3658 0.0.0.0: LISTEN 1/java tcp 0 0 0.0.0.0:9003 0.0.0.0: LISTEN 1/java tcp 0 0 127.0.0.1:8563 0.0.0.0: LISTEN 1/java tcp 0 0 127.0.0.11:41507 0.0.0.0: LISTEN -

期望的结果

期望可以通过宿主机ip+端口方式访问arthas

实际运行的结果

查看arthas日志如下: ~/logs/arthas # more arthas.log 2022-06-28 17:09:03 [main] INFO c.t.arthas.core.util.ArthasBanner -Current arthas version: 3.4.5, recommend latest version: 2022-06-28 17:09:03 [main] INFO c.t.arthas.core.util.ArthasBanner -Current arthas version: 3.4.5, recommend latest version: 2022-06-28 17:09:04 [arthas-NettyHttpTelnetBootstrap-3-1] INFO c.a.a.d.i.n.h.logging.LoggingHandler -[id: 0xc3e42e38] REGISTERED 2022-06-28 17:09:04 [arthas-NettyHttpTelnetBootstrap-3-1] INFO c.a.a.d.i.n.h.logging.LoggingHandler -[id: 0xc3e42e38] BIND: /127.0.0.1:3658 2022-06-28 17:09:04 [arthas-NettyHttpTelnetBootstrap-3-1] INFO c.a.a.d.i.n.h.logging.LoggingHandler -[id: 0xc3e42e38, L:/127.0.0.1:3658] ACTIVE 2022-06-28 17:09:04 [arthas-NettyWebsocketTtyBootstrap-4-2] INFO c.a.a.d.i.n.h.logging.LoggingHandler -[id: 0x2f669165] REGISTERED 2022-06-28 17:09:04 [arthas-NettyWebsocketTtyBootstrap-4-1] INFO c.a.a.d.i.n.h.logging.LoggingHandler -[id: 0xad1f2397] REGISTERED 2022-06-28 17:09:04 [arthas-NettyWebsocketTtyBootstrap-4-2] INFO c.a.a.d.i.n.h.logging.LoggingHandler -[id: 0x2f669165] BIND: local:arthas-netty-localaddress 2022-06-28 17:09:04 [arthas-NettyWebsocketTtyBootstrap-4-1] INFO c.a.a.d.i.n.h.logging.LoggingHandler -[id: 0xad1f2397] BIND: /127.0.0.1:8563 2022-06-28 17:09:04 [arthas-NettyWebsocketTtyBootstrap-4-1] INFO c.a.a.d.i.n.h.logging.LoggingHandler -[id: 0xad1f2397, L:/127.0.0.1:8563] ACTIVE 2022-06-28 17:09:04 [arthas-NettyWebsocketTtyBootstrap-4-2] INFO c.a.a.d.i.n.h.logging.LoggingHandler -[id: 0x2f669165, L:local:arthas-netty-localaddress] ACTIVE 2022-06-28 17:09:04 [main] INFO c.t.a.core.server.ArthasBootstrap -as-server listening on network=127.0.0.1;telnet=3658;http=8563;timeout=6000; 2022-06-28 17:09:04 [main] INFO c.t.a.core.server.ArthasBootstrap -as-server started in 5963 ms

把异常信息贴到这里

回答

6

试下用最新版本, 3.4.5 太老了。

7

换成3.6.2成功