byte-buddy icon indicating copy to clipboard operation
byte-buddy copied to clipboard

I want to ask a question, how to attach the main process of docker started by java -jar, thanks a lot

Open 1057105012 opened this issue 2 years ago • 3 comments

I found that the attach of bytebuddy does not support the execution of the docker container whose EntryPoint label is java -jar xxx.jar, and it will prompt that this is a linux process. I know this may not be the problem of bytebuddy, but how can I solve it, because there are many The projects are all started in this way, and they seem to be unable to attach

1057105012 avatar Jun 30 '23 12:06 1057105012

You can use byte-buddy-agent to self-attach also within Docker: ByteBuddyAgent.install(). You can then execute the premain method manually.

raphw avatar Jul 02 '23 20:07 raphw

I found an interesting project, Jattach This project supports instrumentation in the JRE environment and process processing for PID 1, so that they can still be effective for Attach, I hope that Bytebuddy can refer to it as a built-in base module, or provide it as an expensive feature. I think that for pure JRE startup in production and docker restricting the Java main process to Linux process to cause Attach to take effect (losing the sh boot prefix), recognizing Java -jar as the main process, these two scenarios still support attach agent to take effect, this feature is very helpful

sgy-zihan avatar Jul 17 '23 06:07 sgy-zihan

Byte Buddy does support such emulation. Have a look at byte-buddy-agent and use JNA as an additional dependency.

raphw avatar Jul 17 '23 17:07 raphw