- Notifications
You must be signed in to change notification settings - Fork20
A simple educational linux container runtime.
License
w-vi/diyC
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A simple educational Linux container runtime.
It is intentionally simple and leaves a lot of stuff out. It is asingle C file of roughly 500 lines including comments showing the corefeatures of the Linux used to build containers. It includes also thecreation of a container from an image to clarify how images andcontainers are related.
http://wvi.cz/diyC/ or pure markdownin the docs directory.
This is a educational piece of software and has not been tested onmany systems, here are the prerequisites:
- recent Linux kernel supporting needed namespaces and cgroups
- overlayfs
- ip tool (iproute2 package)
- iptables
- gcc
- make
- bash
Apart from overlayfs most of the distros are prepared and ready, if notplease consult your distro package manager. Overlayfs is in themainline kernel so it should be straightforward.
Note: Kernel needs to be configured to support following namespacesPID, mount, network and UTS, cgroups are needed as well. Most of the GNU/Linux distros havethis support enabled by default.
make setup
It creates the necessary directory structure as well as prepares thenetworking part like iptables rules, bridge (diyc0) and so on. Toremove the networking bits like bridge and iptables rules runmake net-clean
which removes them all.
make
Builds the runtime.
- Done
It also builds ansexec
which executes a local command in namespaces. Seensexec --help
to see what namespaces are available. Usage is very simplesudo ./nsexec -pnu myhost bash
will start a new bash in new pid, network and UTS namespace.