<p>I was following the steps mentioned here <a href="https://stackoverflow.com/questions/64121941/how-to-get-a-heap-dump-from-kubernetes-k8s-pod">How to get a heap dump from Kubernetes k8s pod?</a></p>
<p>I'm able to get the the process id using top command inside the pod. However, when I run jmap I get this:</p>
<pre><code>~ $ jmap
sh: jmap: not found
</code></pre>
<p>I access the pod with this command: kubectl exec -it  -- sh</p>
<p>I also tried this command:</p>
<pre><code>kubectl exec -it &lt;pod&gt; -- jmap -dump:live,format=b,file=heapdump.bin 1
</code></pre>
<p>But I was getting:</p>
<pre><code>OCI runtime exec failed: exec failed: container_linux.go:349: starting container process caused &quot;exec: \&quot;jmap\&quot;: executable file not found in $PATH&quot;: unknown command terminated with exit code 126
</code></pre>
<p>Is there any other way to get the java heap dump from the pod?</p>

MahmooDs
<p>Normally containers are limited on the tools available(like you get 'more', but you don't get 'less'), so the tools available for you depends on your container.</p>
<p>The 2 tools that are used to get a heap dump are jmap and jcmd, check if you got jcmd in the container.</p>
<p><a href="https://www.adam-bien.com/roller/abien/entry/taking_a_heap_dump_with" rel="nofollow noreferrer">https://www.adam-bien.com/roller/abien/entry/taking_a_heap_dump_with</a></p>
<p>If not, I recommend to put the java app in a container that has either jmap or jcmd and then run it; even if the container is &quot;heavier&quot; that won't affect the java app nor the heap dump so it will be the same.</p>
<p>If that's not an option, maybe this will be
<a href="https://techblog.topdesk.com/coding/extracting-a-heap-dump-from-a-running-openj9-java-process-in-kubernetes/" rel="nofollow noreferrer">https://techblog.topdesk.com/coding/extracting-a-heap-dump-from-a-running-openj9-java-process-in-kubernetes/</a>
(not mine).</p>
