An open-source, faster Devin alternative
TypeScript
Use Ubuntu generic kernel with full modules for Docker networking (#108)
Mohamed Habib5c56c13ced10
diff --git a/deploy/azure/deploy-azure-dev.sh b/deploy/azure/deploy-azure-dev.shindex b0b958d9..6e9ee903 100755--- a/deploy/azure/deploy-azure-dev.sh+++ b/deploy/azure/deploy-azure-dev.sh@@ -194,39 +194,30 @@ elseecho "Rootfs image already exists."fi-# Patch rootfs with guest kernel modules (vsock, overlay) and insmod symlink-GUEST_MODDIR="/opt/opensandbox/guest-modules"-if [ -d "$GUEST_MODDIR" ] && [ -f /data/firecracker/images/default.ext4 ]; then- echo "Patching rootfs with guest kernel modules..."- MNTDIR=$(mktemp -d)- sudo mount -o loop /data/firecracker/images/default.ext4 "$MNTDIR"-- # Copy modules- sudo mkdir -p "$MNTDIR/lib/modules/vsock"- sudo cp "$GUEST_MODDIR"/*.ko "$MNTDIR/lib/modules/vsock/" 2>/dev/null || true-- # Create insmod symlink (busybox applet)- if [ -f "$MNTDIR/bin/busybox" ] && [ ! -e "$MNTDIR/sbin/insmod" ]; then- sudo ln -sf /bin/busybox "$MNTDIR/sbin/insmod"+# Patch rootfs with full guest kernel modules — handled by build-rootfs-docker.sh+# but kept as fallback for manually-built images.+if [ -f /data/firecracker/images/default.ext4 ]; then+ GUEST_KVER_FILE="/opt/opensandbox/guest-kernel-version"+ if [ -f "$GUEST_KVER_FILE" ]; then+ GUEST_KVER=$(cat "$GUEST_KVER_FILE")+ elif ls -d /lib/modules/*-generic >/dev/null 2>&1; then+ GUEST_KVER=$(ls -d /lib/modules/*-generic | sort -V | tail -1 | xargs basename)fi- # Update init script: load modules early (before overlay mount)- if ! grep -q 'lib/modules/vsock' "$MNTDIR/sbin/init" 2>/dev/null; then- # Insert module loading after the first "mount -t devtmpfs" line- sudo sed -i '/^mount -t devtmpfs devtmpfs \/dev$/a\-\-# Load kernel modules (needed for QEMU with modular kernel)\-if [ -d /lib/modules/vsock ]; then\- for mod in /lib/modules/vsock/overlay.ko /lib/modules/vsock/vsock.ko /lib/modules/vsock/vmw_vsock_virtio_transport_common.ko /lib/modules/vsock/vmw_vsock_virtio_transport.ko; do\- [ -f "$mod" ] \&\& insmod "$mod" 2>/dev/null || true\- done\- echo "init: kernel modules loaded"\-fi' "$MNTDIR/sbin/init"+ if [ -n "${GUEST_KVER:-}" ] && [ -d "/lib/modules/$GUEST_KVER" ]; then+ echo "Patching rootfs with full kernel modules for $GUEST_KVER..."+ MNTDIR=$(mktemp -d)+ sudo mount -o loop /data/firecracker/images/default.ext4 "$MNTDIR"+ sudo rm -rf "$MNTDIR/lib/modules"/*+ sudo cp -a "/lib/modules/$GUEST_KVER" "$MNTDIR/lib/modules/"+ sudo depmod -b "$MNTDIR" "$GUEST_KVER" 2>/dev/null || true+ if [ -f "$MNTDIR/bin/busybox" ] && [ ! -e "$MNTDIR/sbin/insmod" ]; then+ sudo ln -sf /bin/busybox "$MNTDIR/sbin/insmod"+ fi+ sudo umount "$MNTDIR"+ rmdir "$MNTDIR"+ echo "Rootfs patched with modules for $GUEST_KVER"fi-- sudo umount "$MNTDIR"- rmdir "$MNTDIR"- echo "Rootfs patched."fiROOTFSdiff --git a/deploy/azure/setup-azure-host.sh b/deploy/azure/setup-azure-host.shindex e52e5439..d71a55c2 100755--- a/deploy/azure/setup-azure-host.sh+++ b/deploy/azure/setup-azure-host.sh@@ -62,34 +62,25 @@ if [ -n "$GENERIC_VMLINUZ" ]; thenGENERIC_KVER=$(basename "$GENERIC_VMLINUZ" | sed 's/vmlinuz-//')echo "Guest kernel: $GENERIC_VMLINUZ ($GENERIC_KVER)"- # Extract vsock, overlay, and virtio_mem modules for the guest rootfs+ # Install full kernel modules for the guest rootfs.+ # The guest needs modules for Docker networking (bridge, veth, netfilter),+ # vsock, overlay, and virtio_mem. Instead of cherry-picking individual .ko+ # files, install the matching linux-modules package so all dependencies+ # are satisfied and depmod works correctly inside the guest.+ echo "Installing guest kernel modules ($GENERIC_KVER)..."+ apt-get install -y -qq "linux-modules-$GENERIC_KVER" "linux-modules-extra-$GENERIC_KVER" 2>/dev/null || \+ apt-get install -y -qq "linux-modules-$GENERIC_KVER" 2>/dev/null || true++ # Store kernel version for the rootfs build to use+ echo "$GENERIC_KVER" > "$KERNEL_DIR/guest-kernel-version"++ # Validate critical modules existMODDIR="/lib/modules/$GENERIC_KVER"- GUEST_MODDIR="$KERNEL_DIR/guest-modules"- mkdir -p "$GUEST_MODDIR"- for mod in \- "$MODDIR/kernel/fs/overlayfs/overlay.ko"* \- "$MODDIR/kernel/net/vmw_vsock/vsock.ko"* \- "$MODDIR/kernel/net/vmw_vsock/vmw_vsock_virtio_transport_common.ko"* \- "$MODDIR/kernel/net/vmw_vsock/vmw_vsock_virtio_transport.ko"* \- "$MODDIR/kernel/drivers/virtio/virtio_mem.ko"*; do- [ -f "$mod" ] || continue- base=$(basename "$mod")- if [[ "$base" == *.zst ]]; then- zstd -d "$mod" -o "$GUEST_MODDIR/${base%.zst}" 2>/dev/null- else- cp "$mod" "$GUEST_MODDIR/"+ for mod in virtio_mem bridge veth; do+ if ! find "$MODDIR" -name "${mod}.ko*" | grep -q .; then+ echo "WARNING: ${mod}.ko not found for kernel $GENERIC_KVER"fidone- echo "Guest modules extracted to $GUEST_MODDIR:"- ls "$GUEST_MODDIR/"-- # Validate virtio_mem.ko was extracted — fail fast if missing- if ! ls "$GUEST_MODDIR"/virtio_mem.ko* >/dev/null 2>&1; then- echo "FATAL: virtio_mem.ko not found for kernel $GENERIC_KVER"- echo " Looked in: $MODDIR/kernel/drivers/virtio/virtio_mem.ko*"- echo " Memory scaling will not work. Check that linux-image-generic includes virtio_mem."- exit 1- fielseecho "WARNING: No generic kernel found. Guest VMs may not boot correctly."fidiff --git a/deploy/ec2/build-rootfs-docker.sh b/deploy/ec2/build-rootfs-docker.shindex 0c9af154..40758cd5 100755--- a/deploy/ec2/build-rootfs-docker.sh+++ b/deploy/ec2/build-rootfs-docker.sh@@ -243,26 +243,26 @@ for dir in proc sys dev dev/pts dev/shm tmp run; domkdir -p "$MNT_DIR/$dir"done-# Inject host kernel modules (virtio_mem, vsock, overlay) into rootfs.-# The Docker image has modules for the container kernel, but the guest runs-# the host kernel — so we need the host's matching .ko files.-GUEST_MODDIR="/opt/opensandbox/guest-modules"-if [ -d "$GUEST_MODDIR" ] && ls "$GUEST_MODDIR"/*.ko >/dev/null 2>&1; then- # Detect guest kernel version from the kernel binary- GUEST_KVER=$(ls -d /lib/modules/*-generic 2>/dev/null | head -1 | xargs basename)- if [ -n "$GUEST_KVER" ]; then- DEST="$MNT_DIR/lib/modules/$GUEST_KVER/kernel/extra"- mkdir -p "$DEST"- cp "$GUEST_MODDIR"/*.ko "$DEST/"- # Run depmod so modprobe works inside the guest- depmod -b "$MNT_DIR" "$GUEST_KVER" 2>/dev/null || log "depmod failed (non-fatal)"- log "Injected guest modules into rootfs for kernel $GUEST_KVER:"- ls "$DEST/"- else- log "WARNING: Could not detect guest kernel version — guest modules not injected"- fi+# Inject guest kernel modules into rootfs.+# Copy the full /lib/modules/<kver> tree so all modules (Docker networking,+# vsock, overlay, virtio_mem, etc.) are available with correct dependencies.+GUEST_KVER_FILE="/opt/opensandbox/guest-kernel-version"+if [ -f "$GUEST_KVER_FILE" ]; then+ GUEST_KVER=$(cat "$GUEST_KVER_FILE")+elif ls -d /lib/modules/*-generic >/dev/null 2>&1; then+ GUEST_KVER=$(ls -d /lib/modules/*-generic | sort -V | tail -1 | xargs basename)+fi++if [ -n "${GUEST_KVER:-}" ] && [ -d "/lib/modules/$GUEST_KVER" ]; then+ log "Injecting kernel modules for $GUEST_KVER..."+ rm -rf "$MNT_DIR/lib/modules"/*+ mkdir -p "$MNT_DIR/lib/modules"+ cp -a "/lib/modules/$GUEST_KVER" "$MNT_DIR/lib/modules/"+ depmod -b "$MNT_DIR" "$GUEST_KVER" 2>/dev/null || log "depmod failed (non-fatal)"+ MOD_COUNT=$(find "$MNT_DIR/lib/modules/$GUEST_KVER" -name "*.ko*" | wc -l)+ log "Injected $MOD_COUNT modules for kernel $GUEST_KVER"else- log "WARNING: No guest modules at $GUEST_MODDIR — virtio_mem may not load"+ log "WARNING: No guest kernel modules found — Docker networking and virtio_mem will not work"fisyncdiff --git a/deploy/ec2/deploy-qemu-dev.sh b/deploy/ec2/deploy-qemu-dev.shindex 7a65bba8..a1d19f42 100755--- a/deploy/ec2/deploy-qemu-dev.sh+++ b/deploy/ec2/deploy-qemu-dev.sh@@ -288,42 +288,37 @@ elseecho "Rootfs image already exists (delete /data/firecracker/images/default.ext4 to rebuild)."fi-# Patch rootfs with guest kernel modules (vsock, virtio_mem) and insmod symlink+# Patch rootfs with guest kernel modules — full /lib/modules/<kver> tree.+# This is now handled by build-rootfs-docker.sh during the rootfs build,+# but we keep this as a fallback for manually-built rootfs images.if [ -f /data/firecracker/images/default.ext4 ]; then- echo "Patching rootfs with guest kernel modules..."- MNTDIR=$(mktemp -d)- sudo mount -o loop /data/firecracker/images/default.ext4 "$MNTDIR"-- # Detect guest kernel version from the vmlinux binary- GUEST_KVER=$(grep -aoP '\d+\.\d+\.\d+-\d+-generic' /opt/opensandbox/vmlinux | head -1)- echo "Guest kernel version: $GUEST_KVER"-- # Copy vsock modules from host- GUEST_MODDIR="/opt/opensandbox/guest-modules"- sudo mkdir -p "$MNTDIR/lib/modules/vsock"- if [ -d "$GUEST_MODDIR" ]; then- sudo cp "$GUEST_MODDIR"/*.ko "$MNTDIR/lib/modules/vsock/" 2>/dev/null || true- fi-- # Copy virtio_mem module from host kernel modules, decompress for busybox insmod- HOST_VIRTIO_MEM="/lib/modules/${GUEST_KVER}/kernel/drivers/virtio/virtio_mem.ko.zst"- if [ -f "$HOST_VIRTIO_MEM" ]; then- sudo zstd -d "$HOST_VIRTIO_MEM" -o "$MNTDIR/lib/modules/${GUEST_KVER}/kernel/drivers/virtio/virtio_mem.ko" --force- sudo mkdir -p "$MNTDIR/lib/modules/${GUEST_KVER}/kernel/drivers/virtio"- sudo mv "$MNTDIR/lib/modules/${GUEST_KVER}/kernel/drivers/virtio/virtio_mem.ko" "$MNTDIR/lib/modules/${GUEST_KVER}/kernel/drivers/virtio/virtio_mem.ko" 2>/dev/null || true- echo "Copied virtio_mem.ko for guest kernel $GUEST_KVER"+ GUEST_KVER_FILE="/opt/opensandbox/guest-kernel-version"+ if [ -f "$GUEST_KVER_FILE" ]; then+ GUEST_KVER=$(cat "$GUEST_KVER_FILE")else- echo "Warning: virtio_mem.ko.zst not found at $HOST_VIRTIO_MEM"+ GUEST_KVER=$(grep -aoP '\d+\.\d+\.\d+-\d+-generic' /opt/opensandbox/vmlinux | head -1)fi- # Create insmod symlink (busybox applet)- if [ -f "$MNTDIR/bin/busybox" ] && [ ! -e "$MNTDIR/sbin/insmod" ]; then- sudo ln -sf /bin/busybox "$MNTDIR/sbin/insmod"- fi+ if [ -n "$GUEST_KVER" ] && [ -d "/lib/modules/$GUEST_KVER" ]; then+ echo "Patching rootfs with full kernel modules for $GUEST_KVER..."+ MNTDIR=$(mktemp -d)+ sudo mount -o loop /data/firecracker/images/default.ext4 "$MNTDIR"+ sudo rm -rf "$MNTDIR/lib/modules"/*+ sudo cp -a "/lib/modules/$GUEST_KVER" "$MNTDIR/lib/modules/"+ sudo depmod -b "$MNTDIR" "$GUEST_KVER" 2>/dev/null || true++ # Create insmod symlink (busybox applet)+ if [ -f "$MNTDIR/bin/busybox" ] && [ ! -e "$MNTDIR/sbin/insmod" ]; then+ sudo ln -sf /bin/busybox "$MNTDIR/sbin/insmod"+ fi- sudo umount "$MNTDIR"- rmdir "$MNTDIR"- echo "Rootfs patched with kernel modules."+ sudo umount "$MNTDIR"+ rmdir "$MNTDIR"+ MOD_COUNT=$(find "/lib/modules/$GUEST_KVER" -name "*.ko*" | wc -l)+ echo "Rootfs patched with $MOD_COUNT modules for $GUEST_KVER"+ else+ echo "Warning: Guest kernel modules not found for $GUEST_KVER"+ fifiROOTFSdiff --git a/deploy/ec2/setup-single-host.sh b/deploy/ec2/setup-single-host.shindex 4327a13f..d78c9124 100755--- a/deploy/ec2/setup-single-host.sh+++ b/deploy/ec2/setup-single-host.sh@@ -103,23 +103,40 @@ fisudo chmod 666 /dev/kvm 2>/dev/null || true###############################################################################-# 5. Firecracker kernel+# 5. Guest kernel — Ubuntu generic kernel with full module support###############################################################################-echo "==> Downloading Firecracker kernel..."+echo "==> Setting up guest kernel..."sudo mkdir -p /opt/opensandbox-if [ ! -f /opt/opensandbox/vmlinux ]; then- # Use the 5.10 "docker" kernel which includes vsock, overlayfs, and other- # features needed for sandbox VMs. The plain vmlinux.bin is a minimal 4.14- # kernel that lacks CONFIG_VIRTIO_VSOCKETS.- case "$ARCH" in- x86_64) KERNEL_URL="https://s3.amazonaws.com/spec.ccfc.min/img/quickstart_guide/x86_64/kernels/vmlinux-docker-5.10.bin" ;;- aarch64) KERNEL_URL="https://s3.amazonaws.com/spec.ccfc.min/img/quickstart_guide/aarch64/kernels/vmlinux-docker-5.10.bin" ;;- esac- sudo curl -fSL -o /opt/opensandbox/vmlinux "$KERNEL_URL"++# Install Ubuntu generic kernel (has virtio built-in, full module ecosystem).+# This gives us a kernel + matching modules that support Docker networking+# (bridge, veth, netfilter), vsock, overlay, virtio_mem, etc.+sudo apt-get install -y -qq linux-image-generic++GENERIC_VMLINUZ=$(ls -t /boot/vmlinuz-*-generic 2>/dev/null | head -1)+if [ -n "$GENERIC_VMLINUZ" ]; then+ sudo cp "$GENERIC_VMLINUZ" /opt/opensandbox/vmlinuxsudo chmod 644 /opt/opensandbox/vmlinux- echo " Kernel downloaded: $(ls -lh /opt/opensandbox/vmlinux)"+ GENERIC_KVER=$(basename "$GENERIC_VMLINUZ" | sed 's/vmlinuz-//')+ echo " Guest kernel: $GENERIC_VMLINUZ ($GENERIC_KVER)"++ # Install full kernel modules for the guest+ sudo apt-get install -y -qq "linux-modules-$GENERIC_KVER" 2>/dev/null || true+ sudo apt-get install -y -qq "linux-modules-extra-$GENERIC_KVER" 2>/dev/null || true++ # Store kernel version for the rootfs build+ echo "$GENERIC_KVER" | sudo tee /opt/opensandbox/guest-kernel-version >/dev/null+ echo " Modules installed for $GENERIC_KVER"else- echo " Kernel already exists, skipping"+ echo " WARNING: No generic kernel found, falling back to Firecracker kernel"+ if [ ! -f /opt/opensandbox/vmlinux ]; then+ case "$ARCH" in+ x86_64) KERNEL_URL="https://s3.amazonaws.com/spec.ccfc.min/img/quickstart_guide/x86_64/kernels/vmlinux-docker-5.10.bin" ;;+ aarch64) KERNEL_URL="https://s3.amazonaws.com/spec.ccfc.min/img/quickstart_guide/aarch64/kernels/vmlinux-docker-5.10.bin" ;;+ esac+ sudo curl -fSL -o /opt/opensandbox/vmlinux "$KERNEL_URL"+ sudo chmod 644 /opt/opensandbox/vmlinux+ fifi###############################################################################diff --git a/deploy/firecracker/rootfs/Dockerfile.default b/deploy/firecracker/rootfs/Dockerfile.defaultindex e69d52e8..a739e87c 100644--- a/deploy/firecracker/rootfs/Dockerfile.default+++ b/deploy/firecracker/rootfs/Dockerfile.default@@ -91,7 +91,7 @@ RUN cd /tmp/claude-agent-wrapper \# ── Docker config: store images/containers on the data disk ──────────────────RUN mkdir -p /etc/docker && \- echo '{"data-root": "/home/sandbox/.docker", "bridge": "none", "iptables": false, "storage-driver": "vfs"}' > /etc/docker/daemon.json+ echo '{"data-root": "/home/sandbox/.docker", "storage-driver": "vfs"}' > /etc/docker/daemon.json# ── Locale ───────────────────────────────────────────────────────────────────RUN locale-gen en_US.UTF-8diff --git a/sdks/typescript/examples/test-docker-networking.ts b/sdks/typescript/examples/test-docker-networking.tsnew file mode 100644index 00000000..63e03812--- /dev/null+++ b/sdks/typescript/examples/test-docker-networking.ts@@ -0,0 +1,187 @@+/**+ * Docker Networking Test+ *+ * Tests Docker bridge networking inside a sandbox VM:+ * 1. Kernel module loading (bridge, veth, netfilter)+ * 2. Docker daemon startup with bridge networking+ * 3. Container → internet connectivity (ping + DNS)+ * 4. Host → container latency+ * 5. Container ↔ container latency+ * 6. Container → internet throughput+ * 7. Docker images land on data disk (/home/sandbox/.docker)+ *+ * Usage:+ * npx tsx examples/test-docker-networking.ts+ */++import { Sandbox } from "../src/index";++function green(msg: string) { console.log(`\x1b[32m✓ ${msg}\x1b[0m`); }+function red(msg: string) { console.log(`\x1b[31m✗ ${msg}\x1b[0m`); }+function bold(msg: string) { console.log(`\x1b[1m${msg}\x1b[0m`); }+function dim(msg: string) { console.log(`\x1b[2m ${msg}\x1b[0m`); }++let passed = 0;+let failed = 0;++function check(desc: string, condition: boolean, detail?: string) {+ if (condition) {+ green(desc);+ passed++;+ } else {+ red(`${desc}${detail ? ` — ${detail}` : ""}`);+ failed++;+ }+}++/** Run a command as root with a timeout, return stdout */+async function run(sandbox: Sandbox, cmd: string, timeout = 30): Promise<{ stdout: string; stderr: string; exitCode: number }> {+ const result = await sandbox.commands.run(`sudo bash -c '${cmd.replace(/'/g, "'\\''")}'`, { timeout });+ return result;+}++async function main() {+ bold("\n╔══════════════════════════════════════════════════╗");+ bold("║ Docker Networking Test ║");+ bold("╚══════════════════════════════════════════════════╝\n");++ let sandbox: Sandbox | null = null;++ try {+ sandbox = await Sandbox.create({ timeout: 300 });+ green(`Created sandbox: ${sandbox.sandboxId}`);+ console.log();++ // ── Test 1: Kernel modules ───────────────────────────────────────+ bold("━━━ Test 1: Kernel module loading ━━━\n");++ const modules = ["bridge", "veth", "br_netfilter", "ip_tables", "nf_nat", "nf_conntrack"];+ for (const mod of modules) {+ const result = await run(sandbox, `modprobe ${mod} 2>&1 && echo OK`);+ check(`modprobe ${mod}`, result.stdout.includes("OK"), result.stdout.trim());+ }+ console.log();++ // ── Test 2: Install Docker ───────────────────────────────────────+ bold("━━━ Test 2: Install Docker ━━━\n");++ dim("Installing docker.io (this takes ~30s)...");+ const install = await run(sandbox, "apt-get update -qq 2>/dev/null && apt-get install -y -qq docker.io 2>&1 | tail -1", 180);+ check("Docker installed", install.exitCode === 0, install.stderr);++ const daemonJson = await run(sandbox, "cat /etc/docker/daemon.json");+ check("daemon.json has data-root on data disk", daemonJson.stdout.includes("/home/sandbox/.docker"));+ check("daemon.json does not disable bridge", !daemonJson.stdout.includes('"bridge": "none"'));+ dim(`daemon.json: ${daemonJson.stdout.trim()}`);+ console.log();++ // ── Test 3: Start Docker daemon ──────────────────────────────────+ bold("━━━ Test 3: Docker daemon with bridge networking ━━━\n");++ await run(sandbox, "echo 1 > /proc/sys/net/ipv4/ip_forward");+ await run(sandbox, "/usr/bin/dockerd </dev/null >/tmp/dockerd.log 2>&1 & sleep 1");++ // Wait for dockerd to be ready+ dim("Waiting for dockerd...");+ let dockerReady = false;+ for (let i = 0; i < 20; i++) {+ const ver = await run(sandbox, "/usr/bin/docker version --format '{{.Server.Version}}' 2>/dev/null");+ if (ver.exitCode === 0 && ver.stdout.trim()) {+ dockerReady = true;+ dim(`Docker version: ${ver.stdout.trim()}`);+ break;+ }+ await new Promise(r => setTimeout(r, 1000));+ }+ check("Docker daemon started with bridge networking", dockerReady);++ if (!dockerReady) {+ const log = await run(sandbox, "tail -10 /tmp/dockerd.log");+ dim(`dockerd log: ${log.stdout}`);+ throw new Error("Docker daemon failed to start");+ }++ const info = await run(sandbox, "/usr/bin/docker info --format '{{.Driver}} / {{json .Plugins.Network}}' 2>/dev/null");+ check("Bridge network driver available", info.stdout.includes("bridge"));+ dim(`Docker info: ${info.stdout.trim()}`);+ console.log();++ // ── Test 4: Container → Internet ─────────────────────────────────+ bold("━━━ Test 4: Container → Internet ━━━\n");++ const ping = await run(sandbox, "/usr/bin/docker run --rm alpine:3.19 ping -c5 -W3 8.8.8.8 2>&1", 60);+ check("Container can ping 8.8.8.8", ping.stdout.includes("0% packet loss"));+ const avgMatch = ping.stdout.match(/min\/avg\/max = [\d.]+\/([\d.]+)/);+ if (avgMatch) dim(`Avg latency to 8.8.8.8: ${avgMatch[1]}ms`);++ const dns = await run(sandbox, "/usr/bin/docker run --rm alpine:3.19 ping -c3 -W3 google.com 2>&1", 30);+ check("Container DNS resolution works", dns.stdout.includes("0% packet loss"));+ const dnsMatch = dns.stdout.match(/min\/avg\/max = [\d.]+\/([\d.]+)/);+ if (dnsMatch) dim(`Avg latency to google.com: ${dnsMatch[1]}ms`);++ const dl = await run(sandbox, "/usr/bin/docker run --rm alpine:3.19 wget -O /dev/null http://speedtest.tele2.net/10MB.zip 2>&1", 60);+ check("Container can download from internet", dl.stdout.includes("saved") || dl.exitCode === 0);+ console.log();++ // ── Test 5: Host → Container latency ─────────────────────────────+ bold("━━━ Test 5: Host ↔ Container latency ━━━\n");++ await run(sandbox, "/usr/bin/docker run -d --name ping-target alpine:3.19 sleep 60 2>/dev/null");+ const cip = await run(sandbox, "/usr/bin/docker inspect -f '{{.NetworkSettings.IPAddress}}' ping-target 2>/dev/null");+ const containerIP = cip.stdout.trim();+ check("Container got bridge IP", containerIP.startsWith("172.17."));+ dim(`Container IP: ${containerIP}`);++ const hostPing = await run(sandbox, `ping -c10 -W3 ${containerIP} 2>&1`);+ check("Host can ping container", hostPing.stdout.includes("0% packet loss"));+ const hostMatch = hostPing.stdout.match(/min\/avg\/max(?:\/mdev)? = [\d.]+\/([\d.]+)/);+ if (hostMatch) dim(`Host → container avg latency: ${hostMatch[1]}ms`);++ await run(sandbox, "/usr/bin/docker rm -f ping-target 2>/dev/null");+ console.log();++ // ── Test 6: Container ↔ Container ────────────────────────────────+ bold("━━━ Test 6: Container ↔ Container ━━━\n");++ await run(sandbox, "/usr/bin/docker network create bench-net 2>/dev/null");+ await run(sandbox, "/usr/bin/docker run -d --name ctr-a --network bench-net alpine:3.19 sleep 60 2>/dev/null");++ const c2c = await run(sandbox, "/usr/bin/docker run --rm --network bench-net alpine:3.19 ping -c10 ctr-a 2>&1", 30);+ check("Container ↔ container ping works", c2c.stdout.includes("0% packet loss"));+ const c2cMatch = c2c.stdout.match(/min\/avg\/max = [\d.]+\/([\d.]+)/);+ if (c2cMatch) dim(`Container ↔ container avg latency: ${c2cMatch[1]}ms`);++ await run(sandbox, "/usr/bin/docker rm -f ctr-a 2>/dev/null");+ await run(sandbox, "/usr/bin/docker network rm bench-net 2>/dev/null");+ console.log();++ // ── Test 7: Docker images on data disk ───────────────────────────+ bold("━━━ Test 7: Docker data on data disk ━━━\n");++ const dockerDir = await run(sandbox, "du -sh /home/sandbox/.docker 2>/dev/null");+ check("Docker data stored on data disk", dockerDir.stdout.includes("/home/sandbox/.docker"));+ dim(`Docker data size: ${dockerDir.stdout.trim()}`);++ const disk = await run(sandbox, "df -h / /home/sandbox");+ dim(`Disk usage:\n${disk.stdout}`);+ console.log();++ } catch (err) {+ red(`Error: ${err}`);+ failed++;+ } finally {+ if (sandbox) {+ await sandbox.kill();+ dim(`Sandbox ${sandbox.sandboxId} destroyed`);+ }+ }++ // ── Summary ──────────────────────────────────────────────────────+ bold("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━");+ bold(`Results: ${passed} passed, ${failed} failed`);+ if (failed > 0) {+ process.exit(1);+ }+}++main();