This project is a simple container runtime implementation using C++. It provides basic functionalities to create, isolate and run commands in a containerized environment using:
- Overlay File Systems
- Control Groups
- Process Namespace Isolation
- Change Root
- A Linux Machine/Virtual Machine
- g++-14
- Valgrind (for memory checking)
- sudo privileges
To build and run the project in development mode:
make dev ARGS="<command>"To build and run the project with Valgrind for memory leak checking:
make dev-valgrind ARGS="<command>"main.cpp: Entry point of the application and handles CLI argument pre-processing.constants.cppandconstants.hpp: Contains constant values used in the project.container_overlayfs.cppandcontainer_overlayfs.hpp: Handles the creation and destructions of the container overlay file system.containerization.cppandcontainerization.hpp: Manages container creation, isolation, and execution.
Provide the command you want to run inside the container as an argument to the make command. For example:
make dev ARGS="sh"When I was at Cisco Meraki, there was an engineer who was sparked my interest in UNIX-based operating systems. We spent countless evenings across whiteboards delving into the unique history of UNIX and how the decisions then have had so much influence on the computer engineering world today.
He once sent me a comic some random day over Slack. It was a single page and had 7 commands to create a container. I was like "7 commands? Is it really that simple?" and the answers is yes from a fundamental perspective. Obviously things like Docker do a lot more, but on a fundamental level this is what a container is (plus a bit more). So here is my C++ implementation of it and I dedicate this project to him ;)
A huge shout out the individuals below. I'm not too sure how I would of otherwise got it done without these guides.
- Run your own container without Docker by Alexander Murylev
- Primer on Linux container filesystems by Michal Pitr
- Linux container from scratch by Michal Pitr
You may also find these references helpful during your adventures 🤠