-1

I am trying to get a thread dump of a Java service running inside Docker container. I got into the container terminal using the following command.

sudo docker exec -u 1000:0 -ti MyService /bin/bash

When I now run the following jstack command,

[ecs-user@myComputer /]$ jstack -l 436 > thread.dump

I get the following error.

bash: thread.dump: Permission denied

My docker container runAsUser is specified as ecs-user and that's the user the bash shell is running as. What permissions do I grant this user on which files to be able to do this thread dump? Or are there any other alternatives with jstack? Would appreciate any suggestions/advice. Thanks in advance.

AnOldSoul
  • 4,017
  • 12
  • 57
  • 118

1 Answers1

1

The issue has nothing to do with jstack. The error says, bash can't create thread.dump file in the root directory. This is quite expected, since / is typically writable only by root. Try creating the output file in a different directory.

apangin
  • 92,924
  • 10
  • 193
  • 247