mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
This adds Linux-only container support to Bun.spawn allowing process isolation
through cgroupv2, user namespaces, PID namespaces, network namespaces, and
optional overlayfs.
Features:
- Ephemeral cgroupv2 creation with memory and CPU limits
- Rootless user namespace support with UID/GID mapping
- PID namespace isolation
- Network namespace isolation with loopback setup
- Optional overlayfs filesystem isolation
- Proper cleanup and resource management
- Comprehensive error handling
- Linux-only conditional compilation
JavaScript API:
```js
spawn({
cmd: ["echo", "hello"],
container: {
cgroup: true,
userNamespace: true,
pidNamespace: true,
networkNamespace: true,
memoryLimit: 128 * 1024 * 1024,
cpuLimit: 50,
overlayfs: { ... }
}
})
```
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>