Anything better than this:
We use the proc’s sched (/proc/$PID/sched) to extract the PID of the
process. The process’s PID inside the container will differ then it’s
PID on the host (a non-container system).
For example, the output of /proc/1/sched on a container
root@33044d65037c:~# cat /proc/1/sched | head -n 1
bash (5276, #threads: 1)
While on a non-container host:
$ cat /proc/1/sched | head -n 1
init (1, #threads: 1)
This helps to differentiate if you are in a container or not.