What does a container's `/proc/1/cgroup` or `/proc/self/cgroup` tell you?
AdvancedConceptContainers, VMs & Isolation Internals
Answer
It shows which cgroup the process belongs to. On cgroup v2 with a private cgroup namespace it prints 0::/, while on the host you would see 0::/system.slice/docker-<id>.scope. Tools use this to detect containers and to find limits, but apps must read memory.max rather than /proc/meminfo, which still shows host memory.
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