- OS: Any Linux with kernel 5.15+ (Debian, Ubuntu, etc.)
- Kernel features: namespaces, cgroup v2, overlayfs, squashfs
- Runtime: iproute2, iptables, util-linux, squashfs-tools
# Install Rust toolchain
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup target add x86_64-unknown-linux-musl
# Build
git clone https://github.com/hivebox/hivebox.git
cd hivebox
cargo build --release --target x86_64-unknown-linux-musl
# Install
sudo cp target/x86_64-unknown-linux-musl/release/hivebox /usr/bin/docker run --privileged --cgroupns=host -p 7070:7070 \
-e HIVEBOX_API_KEY=your-secret-key \
-e HIVEBOX_PACKAGES="python3 nodejs git" \
ghcr.io/tetiai/hivebox:latestdocker build -t hivebox .
docker run --privileged --cgroupns=host -p 7070:7070 \
-e HIVEBOX_API_KEY=your-secret-key \
hiveboxcurl -fsSL https://raw.githubusercontent.com/TetiAI/hivebox/main/scripts/setup.sh | \
HIVEBOX_API_KEY=your-key \
HIVEBOX_PACKAGES="python3 nodejs git" \
sudo -E bashHIVEBOX_API_KEY=your-secret-key docker compose up -dsudo mkdir -p /var/lib/hivebox/{images,sandboxes,network}
sudo mkdir -p /etc/hiveboxsudo bash scripts/build-images.shThis creates the base squashfs image in /var/lib/hivebox/images/:
base.squashfs— Debian minimal (~30 MB)
To pre-install packages in all sandboxes, add them to the Dockerfile or the base image build script (images/base.sh). For per-sandbox packages, use hivebox exec <sandbox> -- apt-get install <package>.
sudo cp config/hivebox.toml /etc/hivebox/hivebox.toml
# Edit as needed
sudo vim /etc/hivebox/hivebox.tomlecho 'HIVEBOX_API_KEY=your-secret-key-here' | sudo tee /etc/hivebox/env
sudo chmod 600 /etc/hivebox/envManual:
hivebox daemon --port 7070OpenRC:
sudo cp config/hivebox.openrc /etc/init.d/hivebox
sudo chmod +x /etc/init.d/hivebox
sudo rc-update add hivebox default
sudo rc-service hivebox startsystemd:
# /etc/systemd/system/hivebox.service
[Unit]
Description=HiveBox Sandbox Daemon
After=network.target
[Service]
Type=simple
EnvironmentFile=/etc/hivebox/env
ExecStart=/usr/bin/hivebox daemon --port 7070
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.targetsudo systemctl enable --now hivebox- Set a strong API key (
--api-keyorHIVEBOX_API_KEY) - Build the base squashfs image (
scripts/build-images.sh) - Configure firewall to only expose port 7070 to trusted networks
- Set up log rotation for
/var/log/hivebox.log - Monitor disk space at
/var/lib/hivebox/ - Consider running behind a reverse proxy (nginx/caddy) with TLS
- Set appropriate sandbox timeout limits in config
- Verify cgroup v2 is mounted:
mount | grep cgroup2
For isolated/shared network modes, ensure:
# Enable IP forwarding
echo 1 > /proc/sys/net/ipv4/ip_forward
# Load iptables modules
modprobe iptable_nat
modprobe iptable_filterHiveBox automatically configures bridges and NAT rules, but the kernel modules must be available.
# Check if user namespaces are enabled
sysctl kernel.unprivileged_userns_clone
# Should be 1. If not:
sudo sysctl -w kernel.unprivileged_userns_clone=1Ensure the squashfs image exists:
ls /var/lib/hivebox/images/base.squashfsIf not, build images first: sudo bash scripts/build-images.sh
Ensure cgroup v2 is mounted:
mount | grep cgroup2
# Should show: cgroup2 on /sys/fs/cgroup type cgroup2Force cleanup:
# Find the init process
ps aux | grep "sleep infinity"
# Kill it
sudo kill -9 <PID>
# Remove leftover directory
sudo rm -rf /var/lib/hivebox/sandboxes/hb-*