I would recommend you to read the LWN series on namespaces.
The articles are not very recent, but this low level part of docker (kernel namespaces) has not changed.
He goes into cgroups, namespaces, etc. Then does a demo where is manually does what docker does, like untars an image, creates namespaces, creates the networking.
I’m trying to find a really good blog from years ago but having trouble. This looks good though: https://ericchiang.github.io/post/containers-from-scratch/