ποΈ Educational container runtime implementation using Linux namespaces and cgroups
RT (Rukun Tetangga) adalah bash script container runtime yang dibuat untuk memahami bagaimana container bekerja di level sistem operasi. Script ini menggunakan analogi RT di dalam perumahan untuk menjelaskan konsep-konsep container technology dengan cara yang mudah dipahami.
- β Linux Namespace Management - PID, Mount, UTS, IPC, User, Network isolation
- β Cgroup Resource Management - Memory dan CPU limiting dengan monitoring
- β Container-to-Container Networking - Direct communication tanpa host routing
- β Busybox Integration - Lightweight container base dengan static binary
- β Educational Output - Step-by-step explanations dengan analogi perumahan
- β Comprehensive Error Handling - Recovery mechanisms dan troubleshooting
- β Security Features - Input sanitization dan privilege management
- β Docker Compose Development - Easy setup untuk macOS developers
- macOS dengan Docker Desktop installed
- Docker Compose (included dengan Docker Desktop)
- Git untuk cloning repository
# Clone repository
git clone <repository-url>
cd pak-rt
# Setup development environment
make setup
# Start development container (Linux environment)
make dev
# Dalam development container, test basic functionality
./rt.sh create rumah-a --ram=512 --cpu=50
./rt.sh list
./rt.sh run rumah-a
./rt.sh delete rumah-a# Create container dengan resource limits
./rt.sh create rumah-jakarta --ram=256 --cpu=25
# List semua containers dengan status
./rt.sh list
# Run container dengan interactive shell
./rt.sh run rumah-jakarta
# Create multiple containers untuk networking test
./rt.sh create rumah-bandung --ram=512 --cpu=50
./rt.sh create rumah-surabaya --ram=256 --cpu=30
# Test container-to communication
./rt.sh run rumah-bandung
# Dalam container: ping 10.0.0.3 (IP rumah-surabaya)
# Cleanup containers
./rt.sh delete rumah-jakarta
./rt.sh cleanup-all # Delete semua containers| Command | Description | Analogi RT |
|---|---|---|
make setup |
Setup development environment | Menyiapkan kantor RT |
make dev |
Start interactive development container | Masuk ke kantor RT |
make test |
Run all tests dalam Linux environment | Tes semua sistem kompleks |
make test-unit |
Run unit tests only | Tes komponen individual |
make test-integration |
Run integration tests | Tes integrasi antar sistem |
make test-network |
Run network connectivity tests | Tes sambungan telepon antar rumah |
make test-stress |
Run stress tests | Tes beban maksimal kompleks |
make clean |
Cleanup containers dan volumes | Bersih-bersih kantor RT |
| Command | Description | Analogi RT |
|---|---|---|
make demo |
Show available demo scenarios | Lihat demo yang tersedia |
make demo-basic |
Basic container lifecycle demo | Demo dasar kelola rumah |
make demo-namespace |
Namespace isolation demo | Demo isolasi antar rumah |
make demo-resources |
Resource management demo | Demo pembagian listrik |
make demo-network |
Container networking demo | Demo telepon antar rumah |
make demo-multi |
Multi application demo | Demo kompleks lengkap |
make demo-tour |
Complete educational tour | Tur lengkap kompleks |
make demo-all |
Run all demo scenarios | Jalankan semua demo |
# Test specific components
make test-busybox # Test busybox management
make test-namespace # Test namespace isolation
make test-cgroup # Test resource limiting
make test-network # Test container networking
# Performance and reliability tests
make test-stress # Concurrent operations test
make test-resources # Resource validation test
make test-cleanup # Cleanup verification testpak-rt/
βββ rt.sh # π Main RT script (Rukun Tetangga)
βββ demo-scenarios.sh # π¬ Educational demo scenarios
βββ Makefile # π§ Development commands untuk macOS
βββ docker-compose.yml # π³ Linux development environment
βββ Dockerfile.dev # π¦ Development container setup
βββ README.md # π This documentation
βββ docs/ # π Additional documentation
β βββ README.md # Project overview
β βββ ANALOGY.md # ποΈ Detailed housing analogy
β βββ TROUBLESHOOTING.md # π Common issues dan solutions
β βββ SECURITY.md # π Security considerations
β βββ TESTING.md # π§ͺ Testing methodology
βββ tests/ # π§ͺ Comprehensive test suite
βββ run-all-tests.sh # Main test runner
βββ unit-tests.sh # Unit tests
βββ integration-tests.sh # Integration tests
βββ busybox-tests.sh # Busybox management tests
βββ namespace-tests.sh # Namespace isolation tests
βββ cgroup-tests.sh # Resource management tests
βββ network-tests.sh # Network connectivity tests
βββ security-tests.sh # Security feature tests
βββ stress-tests.sh # Performance stress tests
βββ resource-validation-tests.sh # Resource limiting tests
βββ cleanup-verification-tests.sh # Cleanup verification tests
RT menggunakan analogi perumahan untuk menjelaskan konsep container technology:
- ποΈ Host System = Kompleks Perumahan yang dikelola RT
- π Container = Rumah Individual dengan penghuni
- π¨ PID 1 (busybox) = Ayah sebagai kepala keluarga (nomor 1 di rumah)
- π© Shell Process = Ibu yang mengelola aktivitas rumah
- π¦π§ Child Processes = Anak-anak dalam keluarga
- PID Namespace: Setiap rumah punya penomoran sendiri, Ayah selalu nomor 1
- Network Namespace: Setiap rumah punya telepon internal, bisa nelpon rumah lain
- Mount Namespace: Setiap rumah punya rak buku sendiri, tidak bisa lihat rak tetangga
- UTS Namespace: Setiap rumah punya nama sendiri (hostname)
- IPC Namespace: Setiap rumah punya papan tulis keluarga sendiri
- User Namespace: Ayah di rumah A berbeda dengan Ayah di rumah B
- π‘ Memory Limit = Kuota listrik bulanan untuk setiap rumah
- β‘ CPU Limit = Pembagian daya listrik yang adil
- π Resource Monitoring = Tagihan listrik dan air real-time
- π¨ Resource Alerts = Peringatan jika mendekati batas kuota
- π Container-to-Container = Telepon langsung antar rumah
- π Host Network = Telepon umum kompleks untuk internet
- π veth pairs = Kabel telepon yang menghubungkan rumah
- π IP Addresses = Nomor telepon setiap rumah (10.0.0.x)
RT Container Runtime menyediakan demo scenarios yang interaktif untuk pembelajaran:
# Start development environment
make dev
# Run basic demo
make demo-basic
# Run complete educational tour
make demo-tour
# Run all demos
make demo-all-
Basic Lifecycle (
make demo-basic)- Container creation, running, dan deletion
- Seperti RT yang menunjukkan siklus hidup rumah
-
Namespace Isolation (
make demo-namespace)- PID dan Mount namespace demonstration
- Seperti RT yang menunjukkan isolasi antar rumah
-
Resource Management (
make demo-resources)- Memory dan CPU limiting
- Seperti RT yang menunjukkan pembagian listrik
-
Container Networking (
make demo-network)- Container-to communication
- Seperti RT yang menunjukkan sistem telepon
-
Multi-Container (
make demo-multi)- Multiple containers working together
- Seperti RT yang mengelola kompleks lengkap
-
Educational Tour (
make demo-tour)- Complete guided tour of all features
- Seperti RT yang memberikan tur lengkap kompleks
# Understand namespace isolation
./rt.sh create belajar-namespace --ram=128 --cpu=25
./rt.sh run belajar-namespace
# Dalam container: ps aux # Lihat PID isolation
# Dalam container: mount # Lihat filesystem isolation# Create multiple containers untuk network testing
./rt.sh create server --ram=256 --cpu=30
./rt.sh create client --ram=128 --cpu=20
# Test direct container communication
./rt.sh run server
# Dalam server: nc -l -p 8080 # Start simple server
# Dari container lain
./rt.sh run client
# Dalam client: nc 10.0.0.2 8080 # Connect ke server# Create container dengan memory limit
./rt.sh create memory-test --ram=64 --cpu=10
# Monitor resource usage
./rt.sh run memory-test
# Dalam container: stress --vm 1 --vm-bytes 100M # Test memory limit# Enable verbose educational output
export VERBOSE_MODE=true
./rt.sh create verbose-demo --ram=256 --cpu=25
# Enable debug mode untuk detailed system information
export DEBUG_MODE=true
./rt.sh list
# Enable resource monitoring
export MONITORING_ENABLED=true
./rt.sh run monitoring-demo# High-performance container
./rt.sh create high-perf --ram=1024 --cpu=80
# Minimal resource container
./rt.sh create minimal --ram=64 --cpu=5
# Balanced container
./rt.sh create balanced --ram=512 --cpu=50# Full test suite (requires Linux environment)
make test
# Quick validation
make test-unit
# Network functionality test
make test-network
# Performance validation
make test-stress# Scenario 1: Basic container lifecycle
./rt.sh create test1 --ram=256 --cpu=25
./rt.sh list
./rt.sh run test1
./rt.sh delete test1
# Scenario 2: Multi networking
./rt.sh create web --ram=512 --cpu=50
./rt.sh create db --ram=256 --cpu=30
# Test ping between containers
# Scenario 3: Resource limiting
./rt.sh create limited --ram=128 --cpu=10
# Monitor resource usage dalam container-
Permission Denied
# Ensure running dalam Docker container dengan privileged mode make dev -
Container Creation Fails
# Check system resources ./rt.sh debug system # Verify busybox availability ./rt.sh debug busybox
-
Network Issues
# Check network configuration ./rt.sh debug network # Cleanup orphaned network interfaces ./rt.sh cleanup-all
# System information
./rt.sh debug system
# Container status
./rt.sh debug containers
# Network topology
./rt.sh debug network
# Resource usage
./rt.sh debug resources
# Recovery from corrupted state
./rt.sh recover-state- ANALOGY.md - Detailed penjelasan analogi perumahan RT
- TROUBLESHOOTING.md - Common issues dan solutions
- SECURITY.md - Security considerations dan best practices
- TESTING.md - Testing methodology dan test scenarios
- Fork repository
- Create feature branch:
git checkout -b feature/amazing-feature - Make changes dalam development container:
make dev - Run tests:
make test - Commit changes:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Submit pull request
- Follow bash scripting best practices
- Add educational analogies untuk new features
- Include comprehensive error handling
- Write tests untuk new functionality
- Update documentation accordingly
MIT License - see LICENSE file for details.
- Linux kernel developers untuk namespace dan cgroup features
- Busybox project untuk lightweight container base
- Docker community untuk container technology inspiration
- Indonesian RT system untuk educational analogy inspiration
π Seperti RT yang melayani warga kompleks, script ini melayani developer yang ingin memahami container technology dengan cara yang mudah dan menyenangkan!