Docker: different PIDs for `top` and` ps`

I do not understand the difference in

$> docker top lamp-test
PID                 USER                COMMAND
31263               root                {supervisord} /usr/bin/python   /usr/bin/supervisord -n
31696               root                {mysqld_safe} /bin/sh /usr/bin/mysqld_safe
31697               root                apache2 -D FOREGROUND
...

and

$> docker exec lamp-test ps
PID TTY          TIME CMD
  1 ?        00:00:00 supervisord
433 ?        00:00:00 mysqld_safe
434 ?        00:00:00 apache2
831 ?        00:00:00 ps

So the question is why is the PID different? I would say that the output from psis a namespace, but if so, what is displayed top!

+4
source share
1 answer

docker exec lamp-test psshow pidsinside the docker container.

docker top lamp-testshow host system pids.

You can see container processes, but you cannot kill them. This "erroneous" isolation does have some great advantages, such as the ability to monitor processes running inside all of your containers from a single monitor running on the host machine.

+4

Source: https://habr.com/ru/post/1616800/


All Articles