A mini container runtime implementation in Odin, inspired by runc. This project provides basic container management functionality including create, start, list, delete, and exec operations.
| Feature | Yggdrasil | runc | Docker | containerd |
|---|---|---|---|---|
| Binary Size | 473 KB | 13.5 MB | 55.2 MB | ~25 MB |
| Memory Usage | ~1-2 MB | ~5-10 MB | ~50-100 MB | ~20-30 MB |
| Lines of Code | 572 lines | ~50K+ lines | ~1M+ lines | ~200K+ lines |
| Dependencies | None | libc, libseccomp | Many | libc, gRPC |
| Container Creation | ✅ | ✅ | ✅ | ✅ |
| Container Start/Stop | ✅ | ✅ | ✅ | ✅ |
| Interactive Exec | ✅ | ✅ | ✅ | ✅ |
| Background Containers | ✅ | ✅ | ✅ | ✅ |
| Namespace Isolation | ✅ | ✅ | ✅ | ✅ |
| Overlay Filesystem | ✅ | ✅ | ✅ | ✅ |
| State Persistence | ✅ | ✅ | ✅ | ✅ |
| Image Management | ❌ | ❌ | ✅ | ✅ |
| Networking | Basic | ✅ | ✅ | ✅ |
| Resource Limits | ❌ | ✅ | ✅ | ✅ |
| Security Features | Basic | Advanced | Advanced | Advanced |
| Production Ready | ❌ | ✅ | ✅ | ✅ |
| Learning/Educational | ✅ | ❌ | ❌ | ❌ |
- Yggdrasil: 473 KB (0.5 MB) - 122x smaller than Docker!
- runc: 13.5 MB - 28x larger than Yggdrasil
- Docker: 55.2 MB - 117x larger than Yggdrasil
- ✅ Create containers with custom rootfs and commands
- ✅ Start containers in background mode
- ✅ Stop containers with graceful shutdown
- ✅ List containers with status and process information
- ✅ Delete containers and clean up resources
- ✅ Execute commands in running containers (interactive shell support)
- ✅ Linux namespaces (PID, mount, UTS, network)
- ✅ Overlay filesystem support for rootfs isolation
- ✅ chroot filesystem isolation
- ✅ Process isolation with fork/exec
- ✅ Root privilege checking with helpful error messages
- ✅ Container state persistence using state files
- ✅ Background container execution (daemon mode)
- ✅ Process monitoring and automatic status updates
- ✅ Container lifecycle management
- ✅ Simple command-line interface
- ✅ Helpful usage messages
- ✅ Error handling with clear feedback
- ✅ Status reporting for all operations
- Odin compiler (https://odin-lang.org/docs/install/)
- Linux system with kernel support for namespaces
- Root filesystem image (e.g., Alpine Linux)
- Root privileges (required for namespace operations)
./build.shThis will create a yggdrasil binary in the current directory.
./ygg create mycontainer --rootfs ./rootfs --hostname myhost -- /bin/shOptions:
--rootfs <path>: Path to root filesystem (default: ./rootfs)--hostname <name>: Container hostname--net <mode>: Network mode - host|none (default: host)-- <command>: Command to run in container
sudo ./ygg start mycontainersudo ./ygg stop mycontainer./ygg ps# Execute a single command
sudo ./ygg exec mycontainer /bin/ls
# Get interactive shell (like docker exec -it)
sudo ./ygg exec mycontainer /bin/sh./ygg delete mycontainer- Created: Container configuration created but not started
- Running: Container is currently running
- Stopped: Container has finished execution
- Deleted: Container has been removed
The runtime uses several Linux features:
- Namespaces: Process, mount, and network isolation
- Overlay filesystem: Union mount for rootfs protection
- chroot: Change root directory for container filesystem
- fork/exec: Process management and command execution
Yggdrasil/
├── main.odin # Main runtime implementation
├── build.sh # Build script
├── README.md # This file
├── rootfs.gz # Root filesystem image
└── containers/ # Container state directory (created at runtime)
└── *.json # Container state files
-
Prepare rootfs:
# Download Alpine Linux rootfs wget https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/alpine-minirootfs-3.22.0-x86_64.tar.gz tar -xzf alpine-minirootfs-3.22.0-x86_64.tar.gz mv alpine-minirootfs-3.22.0-x86_64 rootfs -
Create and start container:
./ygg create test --rootfs ./rootfs -- /bin/sleep 3600 sudo ./ygg start test # Requires root privileges
-
List containers:
./ygg ps
-
Execute commands in container:
sudo ./ygg exec test /bin/ls sudo ./ygg exec test /bin/sh # Interactive shell
-
Stop and clean up:
sudo ./ygg stop test ./ygg delete test
- No TTY support (containers run without terminal)
- Basic namespace joining (exec uses chroot instead of setns)
- No resource limits or cgroups
- No advanced networking configuration
- No image management (requires manual rootfs setup)
- No security profiles or seccomp
- No volume mounts or bind mounts
- No container orchestration features
- This is a learning project and should not be used in production
- Containers run with the same privileges as the host
- No security isolation beyond basic namespaces
- Always run in a safe environment for testing
This project is for educational purposes. Use at your own risk.

