The reason why we should not execute ps command in containers:
some containers don't have ps command.
if a container shares the PID namespace with the host machine, the check command would report false positives.
The better way is to get the PID of the first process inside containers in the host PID namespace first, then find all processes whose PPID is the PID of the first process inside the container.
The reason why we should not execute ps command in containers:
The better way is to get the PID of the first process inside containers in the host PID namespace first, then find all processes whose PPID is the PID of the first process inside the container.