All container resource settings are now fully configurable through config.yaml.
container:
enabled: true # Enable/disable containerization
mode: "native" # "native" or "docker"
base_path: "/var/pastebox/containers" # Container storage pathControl CPU, memory, and process limits per container:
container:
limits:
cpu_quota_micros: 100000 # CPU quota in microseconds
cpu_period_micros: 100000 # CPU period in microseconds
memory_mb: 512 # Memory limit in MB
pids_limit: 100 # Max number of processes- cpu_quota_micros: How much CPU time the container gets per period
- cpu_period_micros: The period length
Examples:
# 1 CPU (100% of one core)
cpu_quota_micros: 100000
cpu_period_micros: 100000
# 2 CPUs (200% = 2 cores)
cpu_quota_micros: 200000
cpu_period_micros: 100000
# 0.5 CPU (50% of one core)
cpu_quota_micros: 50000
cpu_period_micros: 100000# 512 MB
memory_mb: 512
# 1 GB
memory_mb: 1024
# 2 GB
memory_mb: 2048# Allow up to 100 processes
pids_limit: 100
# Allow up to 500 processes
pids_limit: 500Control which Linux namespaces are enabled:
container:
namespaces:
pid: true # Process isolation
mount: true # Filesystem isolation
network: true # Network isolation
uts: true # Hostname isolation
ipc: true # IPC isolation
user: false # User namespace (requires special setup)Namespace Descriptions:
- pid: Isolates process IDs (container can't see host processes)
- mount: Isolates mount points (container has own filesystem view)
- network: Isolates network stack (container has own network)
- uts: Isolates hostname (container can have different hostname)
- ipc: Isolates inter-process communication
- user: Maps user/group IDs (advanced, usually disabled)
container:
enabled: true
mode: "native"
limits:
cpu_quota_micros: 50000 # 0.5 CPU
cpu_period_micros: 100000
memory_mb: 256 # 256 MB
pids_limit: 50
namespaces:
pid: true
mount: true
network: false # Disable for faster startup
uts: false
ipc: false
user: falsecontainer:
enabled: true
mode: "native"
limits:
cpu_quota_micros: 200000 # 2 CPUs
cpu_period_micros: 100000
memory_mb: 1024 # 1 GB
pids_limit: 200
namespaces:
pid: true # All enabled for maximum isolation
mount: true
network: true
uts: true
ipc: true
user: false # Still disabled (requires UID mapping)container:
enabled: true
mode: "native"
limits:
cpu_quota_micros: 400000 # 4 CPUs
cpu_period_micros: 100000
memory_mb: 2048 # 2 GB
pids_limit: 500
namespaces:
pid: true
mount: true
network: true
uts: true
ipc: true
user: falsecontainer:
enabled: false # Disable containerization entirely
# Falls back to simple process isolationFormula: CPUs = cpu_quota_micros / cpu_period_micros
Examples:
- 1 CPU:
100000 / 100000 = 1.0 - 2 CPUs:
200000 / 100000 = 2.0 - 0.5 CPU:
50000 / 100000 = 0.5
Direct conversion: memory_mb MB of RAM
Examples:
- 512 MB:
memory_mb: 512 - 1 GB:
memory_mb: 1024 - 4 GB:
memory_mb: 4096
Check resource usage:
# Via CLI
./bin/pasteboxctl status box-123
# Via API
curl http://localhost:8080/api/pastebox/box-123/status \
-H "Authorization: Bearer <token>"Issue: failed to create container
Solutions:
- Check if running on Linux (containers require Linux)
- Verify
/var/pastebox/containersexists and is writable - Check if cgroups v2 is enabled:
ls /sys/fs/cgroup/
Issue: Container killed by OOM
Solutions:
- Increase
memory_mbin config - Check application memory usage
- Monitor with:
./bin/pasteboxctl status box-123
Issue: Container running slowly
Solutions:
- Increase
cpu_quota_micros - Check CPU usage in stats
- Consider increasing to 2+ CPUs for heavy workloads
Issue: Cannot create namespaces
Solutions:
- Run as root (required for namespaces)
- Disable problematic namespaces (e.g.,
user: false) - Check kernel support:
ls /proc/self/ns/
- Start Conservative: Begin with default settings
- Monitor First: Check actual resource usage before adjusting
- Scale Gradually: Increase limits incrementally
- Test Changes: Verify in development before production
- Document Limits: Note why specific limits were chosen
- ✅ Full support for all features
- ✅ All namespaces available
- ✅ Cgroups v2 recommended
⚠️ Stubs only, no actual isolation⚠️ Config still validated⚠️ Use for development/testing only
- CONTAINER_VIRTUALIZATION.md - Technical details
- README.md - General documentation
- config.yaml - Example configuration