I do not understand how namespaces interact with /proc. I assumed that /proc returns values based on the process that queries them.
For example, let's determine the PID of the current process inside the global PID namespace:
$ bwrap --bind / / readlink /proc/self 6182 This makes sense to me. However, when I isolate readlink in its own PID namespace:
$ bwrap --bind / / --unshare-pid readlink /proc/self 6177 I get the same result! To get the PID inside the namespace, I need to add --proc /proc:
$ bwrap --bind / / --unshare-pid --proc /proc readlink /proc/self 2 But shouldn't /proc always take the context of the reading process into account? Why is the extra procfs required and how is it related to the readlink process?
If I do not create a new PID namespace, the extra procfs makes no difference:
$ bwrap --bind / / --proc /proc readlink /proc/self 6179