Why can a container "see" only its own processes with `ps`?
IntermediateConceptContainers, VMs & Isolation Internals
Answer
Because of the PID namespace plus its own /proc mount. ps reads /proc, and the container's /proc reflects only its PID namespace. docker run --pid=host shares the host's PID namespace and makes all host processes visible, which is a security risk but useful for debugging.
More on Containers, VMs & Isolation Internals
What is a container, in one sentence?BeginnerHow do containers differ from virtual machines?BeginnerCan a Linux container run a Windows application, or the reverse?IntermediateWhat are Linux namespaces? Name the ones Docker uses.BeginnerWhat are cgroups and what do they do for containers?BeginnerWhat is PID 1 in a container and why does it matter?Intermediate