title: how to get process id from a container?
body: <p>How do I get the process IDs of programs (nodejs in this example) running in a container?
  When I use <code>docker top test1</code> (test1 is the container's name)
  I get</p>
  <pre><code>UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
  root                54682               54654               0                   12:38               ?                   00:00:00            /sbin/docker-init -- docker-entrypoint.sh node src/server.js
  root                54728               54682               0                   12:38               ?                   00:00:00            node src/server.js
  </code></pre>
  <p>Note the PIDS are <code>54682</code> and <code>54728</code> but when I run top from inside the container after running <code>docker container exec -it test1 sh</code>, I get different PIDs (<code>7</code>and <code>1</code>)</p>
  <pre><code>  PID  PPID USER     STAT   VSZ %VSZ CPU %CPU COMMAND
      7     1 root     S     248m   6%   1   0% node src/server.js
     15     0 root     S     1664   0%   0   0% sh
     22    15 root     R     1596   0%   0   0% top
      1     0 root     S     1084   0%   0   0% /sbin/docker-init -- docker-entrypoint.sh node src/server.js
  </code></pre>
  <p>The use case for my requirement is that our application uses node's process.pid to write unique log file names per service.
  our log files are named using a format like service.process.pid.log (healthcheck.400.log).</p>