I am trying to understand how linux containers work internally. One of the things that I have learned is that you can containerize a shell by passing in special flags to it. Out of the flags one is for the PIDs.
This however, does not give the desired effect for the
ps command, as it still shows all the processes from the host and the container. This is probably because
ps reads from
One of the methods I have seen to get
ps to show processes that are running only on the container is via chrooting into a fake root file system (which just contains the directories/utilities of the operating system) and then mounting the
/proc directory of the host to the proc directory of the fake fs.
I just can't understand why this actually works. Why does mounting the
/proc directory into another mount point make it behave like it is containerized.
Why do you even need a fake root filesystems for containers like Docker to work properly?
Am I missing something?
The technique that I describe is from this video at DockerCon.
I have set the link to the exact time this method is done.