For each test we run, we clone the worker process, then make a bunch of Linux syscalls to set everything up for the container, then exec the test. We use the trick of having the child process share the virtual memory of the parent until the test is exec'ed.
We also use a technique where we build up a "program" of simple operations (each operation more or less maps to a syscall) in the parent before cloning, then evaluate the program in the child. This gives us the same performance benefits of using posix_spawn or vfork, but lets us configure all of the namespace stuff while we're spawning.
The code that's run in the child can be found here: https://github.com/maelstrom-software/maelstrom/blob/main/cr...
Doing it well is a different story.
I hope these guys are into doing it well, else runc would be more than adequate for low-level stuff.
Cgroups are nice and add some fun features, but they’re just icing on the cake and are also not necessary, even for a very functional and nicely secure container, unless the stuff inside the container needs cgroup delegation.
Using iptables to make a container is IMO pathetic, and I’m hoping to find time at some point to work out something better.
Could you please tell what exactly this API is? I'd like to try and use it.
https://lwn.net/Articles/829496/
And here’s an article about an old version of the syscalls:
https://github.com/maelstrom-software/maelstrom/blob/main/cr...
For bind mounts, you want to look at open_tree and move_mount. For "regular" mounts, you want to look at fsopen, fsconfig, fsmount, and move_mount.
I found this video very useful: https://www.youtube.com/watch?v=gMWKFPnmJSc