I tried to build a container from scratch using only chroot, unshare, and overlayfs. I almost got it working, but PID isolation broke me

Posted by Abject-Hat-4633@reddit | linuxadmin | View on Reddit | 18 comments

I have been learning how containers actually work under the hood. I wanted to move beyond Docker and understand the core Linux primitives—namespaces, cgroups, and overlayfs—that make it all possible.

so i learned about that and i tried to built it all scratch (the way I imagined sysadmins might have before Docker normalized it all) using all isolation and namespace thing ...

what I got working perfectly:

-->$ cat problem
PID namespace isolation. I can't get it to work reliably. I've tried everything:

it was showing me whole host processes , and it should give me 1-2 processes

I tried to follow the runc runtime
i have used the overlayFS , rootfs ( it is debian , later i will use Alpine like docker, but this before error remove )

I have learned more about kernel namespaces from this failure than any success, but I'm stumped.

Has anyone else tried this deep dive? How did you achieve stable PID isolation without a full-blown runtime like runc ?

here is the github link : https://github.com/VAibhav1031/Scripts/tree/main/Container_Setup