基于alpine java的docker容器查看堆栈信息
2021-04-17 13:26
标签:-- exception links etc article snap ror pac 文档 使用docker容器起服务,容器是基于openjdk:8-jre-alpine的,里面没有没有相关的内存分析工具,如jmap,jstack等 解决参考文档: https://www.codeleading.com/article/40862545024/ 由于进程占用pid为1,所以无法使用jmap等工具 解决方法: 1)docker --init启动 2)docker-compose配置文件添加参数 基于alpine java的docker容器查看堆栈信息 标签:-- exception links etc article snap ror pac 文档 原文地址:https://www.cnblogs.com/hujinzhong/p/13301268.html一、问题分析
二、问题解决
2.1、容器安装openjdk8
#进入容器
[root@ZSC ~]#docker exec -it 931c5b99fa53 /bin/sh
#修改源,加入阿里源
/ # cat /etc/apk/repositories
http://dl-cdn.alpinelinux.org/alpine/v3.9/main
http://dl-cdn.alpinelinux.org/alpine/v3.9/community
http://mirrors.aliyun.com/alpine/v3.9/main/
http://mirrors.aliyun.com/alpine/v3.9/community/
#更新
/ # apk update
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
fetch http://mirrors.aliyun.com/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://mirrors.aliyun.com/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
v3.9.6-44-g3992359a2b [http://dl-cdn.alpinelinux.org/alpine/v3.9/main]
v3.9.6-45-g39af6011bf [http://dl-cdn.alpinelinux.org/alpine/v3.9/community]
v3.9.6-44-g3992359a2b [http://mirrors.aliyun.com/alpine/v3.9/main/]
v3.9.6-42-g88b6599af0 [http://mirrors.aliyun.com/alpine/v3.9/community/]
OK: 9790 distinct packages available
#安装openjdk8(很慢)
/ # apk add openjdk8
#查看安装的位置,后续可以考虑将其移出容器
/usr/lib/jvm/java-1.8-openjdk # pwd
/usr/lib/jvm/java-1.8-openjdk
/usr/lib/jvm/java-1.8-openjdk # ls
ASSEMBLY_EXCEPTION LICENSE THIRD_PARTY_README bin include jre lib release
2.2、pid问题解决
#可以将openjdk拷贝出来,然后容器启动后,拷贝进容器
[root@ZSC ~]#docker run --init -d -p 20889:20889 dianchou-service-address:1.0-SNAPSHOT
72bca3bb7bd222b782eff7eec426818dbf3482685adb22c48f06aaf69bd1525b
[root@ZSC service]#docker cp java-1.8-openjdk 72bca3bb7bd2:/
文章标题:基于alpine java的docker容器查看堆栈信息
文章链接:http://soscw.com/index.php/essay/76080.html