Issue with openjdk:17 docker image

3.2k Views Asked by At

I'm using the openjdk:17 docker image, the os is Oracle Linux Server v8.5. I ssh into the container with root user and found almost all common commands are not available. I have tried ps, pidof etc but getting command not found error. I'm trying to add a preStop hook to kill the java process gracefully but need a command to find the java process. Any idea how to achieve this?

Here is the output of ls -l /proc/*/exe. There sees to be a number of pid associated to the java process, but I'm sure I only have one. What is the clear way to find the pid and kill it? one liner is preferred

lrwxrwxrwx 1 root root 0 Mar  3 16:45 /proc/1/exe -> /usr/java/openjdk-17/bin/java
lrwxrwxrwx 1 root root 0 Mar  3 20:35 /proc/106/exe -> /usr/bin/bash
lrwxrwxrwx 1 root root 0 Mar  3 20:45 /proc/164/exe -> /usr/java/openjdk-17/bin/jshell
lrwxrwxrwx 1 root root 0 Mar  3 20:45 /proc/185/exe -> /usr/java/openjdk-17/bin/java
lrwxrwxrwx 1 root root 0 Mar  3 21:15 /proc/self/exe -> /usr/bin/coreutils
lrwxrwxrwx 1 root root 0 Mar  3 21:15 /proc/thread-self/exe -> /usr/bin/coreutils
0

There are 0 best solutions below