在docker中,运行Jcmd命令,报错
起因:
想调整JVM的设置,观察一下当前jvm进程的资源情况。
输入:docker exec -it xxxxx /bin/sh
输入: jcmd 1 help ,报错
com.sun.tools.attach.AttachNotSupportedException: Unable to get pid of LinuxThreads manager thread at sun.tools.attach.LinuxVirtualMachine.<init>(LinuxVirtualMachine.java:86) at sun.tools.attach.LinuxAttachProvider.attachVirtualMachine(LinuxAttachProvider.java:63) at com.sun.tools.attach.VirtualMachine.attach(VirtualMachine.java:208) at sun.tools.jcmd.JCmd.executeCommandForPid(JCmd.java:147) at sun.tools.jcmd.JCmd.main(JCmd.java:131)
根本原因:
进程1 编号是Linux定义的管理进程
解决办法:
重新添加JDK基础镜像
FROM openjdk:8-jdk-alpine LABEL MAINTAINER="cn-coder(https://www.cnblogs.com/cn-coder)" RUN echo "http://mirrors.aliyun.com/alpine/latest-stable/main/" > /etc/apk/repositories RUN echo "http://mirrors.aliyun.com/alpine/latest-stable/community/" >> /etc/apk/repositories RUN apk update && \ apk add --no-cache tini ENTRYPOINT ["/sbin/tini", "--"]