PID mapping between docker and host

How is docker namespace different from host namespace and how can pid map between these two? Can someone give me an idea that helps make an easy way to map pid between host n docker using source code?

+5
source share
2 answers

As I mentioned in docker safe launch :

Currently, Docker uses five namespaces to change the appearance of processes in the system: Process, Network, Mount, Hostname, Shared Memory.

The fact that by default, as I mentioned in the previous question, " Docker Namespace at the kernel level ," the pid of the container is isolated from the host (unless you run them with --pid host ) by design.

If you use --pid=host , then these container boxes are visible from the host, but are not easily mapped to a specific container, as long as issue 10163 and --pid=container:id enabled.

Update to 2016: problem 10163 and --pid=container:id actually resolved by PR 22481 for docker 1.12, which allows you to join another container PID namespace.

+5
source

You can find the mapping in the /proc/PID/status file. It contains a string like:

 NSpid: 16950 24 

This means that 16950 on host 24 inside the container.

+3
source

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


All Articles