Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot attach to process in docker container #203

Closed
mpapirkovskyy opened this issue Feb 14, 2019 · 7 comments
Closed

Cannot attach to process in docker container #203

mpapirkovskyy opened this issue Feb 14, 2019 · 7 comments

Comments

@mpapirkovskyy
Copy link

Documentation says attaching to java process in docker from host machine should be possible, but requirements are not clear.

I get following error when trying to attach to java process in docker container:

# ./profiler.sh start 8453
Failed to inject profiler into 8453
	linux-vdso.so.1 =>  (0x00007fff0229e000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f02ebe98000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f02ebc7b000)
	librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f02eba73000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f02eb6f1000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f02eb3e8000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f02eb1d2000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f02eae08000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f02ec749000)

There no jdk on host machine.
Folder with profiler is mounted inside container, but into different folder

@apangin
Copy link
Collaborator

apangin commented Feb 14, 2019

This issue is documented in Troubleshooting section. The different folder is the problem.

Failed to inject profiler into <pid>

The connection with the target JVM has been established, but JVM is unable to load profiler shared library. Make sure the user of JVM process has permissions to access libasyncProfiler.so by exactly the same absolute path. For more information see #78.

@apangin apangin closed this as completed May 20, 2019
@buhtr
Copy link

buhtr commented Sep 7, 2020

It's not obviously cleared what the cause of the error from troubleshooting. Spent some time to figure out. So there are three main points:

  1. Mount async's folder to the same folder as it in a host machine. (docker ... -v /opt/async-profiler:/opt/async-profiler).
  2. Check permissions.
  3. Run async_profiler on a host machine from /opt/async-profiler folder.

May be it should by mentioned some where ?

@apangin
Copy link
Collaborator

apangin commented Sep 7, 2020

@buhtr Do you have a suggestion how to improve the documentation? Ideally without focusing on docker, as the problem is not docker-specific.

@huangshiyou
Copy link

buhtr

Hi could you please share your changes? I mount the folder to docker and run the profiler from the host from the same path, but it still fails to inject the profiler to the user process. Thanks

@apangin
Copy link
Collaborator

apangin commented Sep 4, 2022

@huangshiyou What OS image and Java version does your container run? Do you use the latest release of async-profiler? Did you try to run the profiler inside the container?

@huangshiyou
Copy link

@huangshiyou What OS image and Java version does your container run? Do you use the latest release of async-profiler? Did you try to run the profiler inside the container?

Thanks for your reply. Yes, I tried to run the profiler inside the container and it works. I guess the reason why it fails to work from the host machine is that: the main container launches another sub-container where the Java process runs. I can only mount the profiler folder to the main container so that in the sub-container, the Java process cannot access the profile library. I am not a docker expert. As it works by running the profiler from the container, it is good enough for me.

@apangin
Copy link
Collaborator

apangin commented Sep 7, 2022

@huangshiyou You're right - subcontainer must be the issue. In the future version, I'll try to handle copying of libasyncProfiler into the target container automatically. In the meantime, the workaround is to run profiler inside the container.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants