Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/chaitu426/minibox/llms.txt

Use this file to discover all available pages before exploring further.

MiniBox runs containers as isolated Linux processes using PID, UTS, mount, and network namespaces combined with cgroups v2 resource controls. This page covers every stage of the container lifecycle — from launching your first container with minibox run all the way through inspecting it with stats and cleaning up with rm.

Prerequisites

The daemon must be running before you issue any container commands:
sudo -E miniboxd
minibox ping   # should print: Daemon is running

minibox run flags

-d
flag
Detached mode. The container starts in the background and its 8-hex-character ID is printed to stdout.
-m
integer
Memory limit in megabytes. Written to memory.max in the container’s cgroup v2 slice under /sys/fs/cgroup/minibox/<id>/.
-c
integer
CPU limit as a percentage of one core (1–100). MiniBox converts this to the cgroup v2 cpu.max format: <quota> 100000, where quota = value × 100000 / 100.
-p
string
Port mapping in host:container format (e.g. -p 8080:80). Repeat the flag for multiple mappings. MiniBox programs an iptables DNAT rule and a kernel-bypass TCP proxy listener for each pair.
Full usage:
minibox run [-d] [-m <memoryMB>] [-c <cpuPercent>] [-p <host:container>] <image> [command...]
If you omit command, MiniBox uses the image’s default CMD from its OCI metadata.

Container lifecycle

1

Build an image

minibox build -t myapp .
2

Run the container

# Foreground — output streams to your terminal
minibox run myapp

# Detached — prints the container ID and returns immediately
minibox run -d myapp
3

Inspect running containers

minibox ps        # running containers only
minibox ps -a     # include stopped / exited
ps shows ID, IMAGE, STATUS, HEALTH, EXIT, and PORTS columns.
4

Read logs

minibox logs a1b2c3d4
Logs are persisted to DataRoot/containers/<id>/container.log on the host.
5

Stop or force-kill

minibox stop a1b2c3d4   # sends SIGTERM
minibox kill a1b2c3d4   # sends SIGKILL
6

Remove the container record

minibox rm a1b2c3d4

Namespace isolation

Every container is launched with four Linux namespace clone flags set simultaneously:
NamespaceClone flagWhat it isolates
PIDCLONE_NEWPIDProcess tree — container processes can only see each other
UTSCLONE_NEWUTSHostname (set to the container ID by default)
MountCLONE_NEWNSFilesystem tree — overlayfs rootfs is private to the container
NetworkCLONE_NEWNETNetwork interfaces, routing table, iptables rules
The parent daemon also sets CLONE_NEWIPC to isolate System V IPC resources (shared memory segments, semaphores) from the host.
After the child process enters its namespaces it chroots into the container rootfs, then mounts /proc (with hidepid=2 to prevent cross-process info leaks), a read-only /sys, and a minimal /dev tmpfs.

Cgroups v2 resource controls

MiniBox creates a cgroup slice at /sys/fs/cgroup/minibox/<containerID>/ and writes resource knobs before the workload starts. The parent slice’s cgroup.subtree_control is set to +cpu +memory +io so all three controllers are actually enforced.
cgroup fileCLI flagNotes
memory.max-m <MB>Hard memory ceiling in bytes (MB × 1 048 576)
cpu.max-c <percent><quota> 100000 — e.g. -c 50 writes 50000 100000
cpuset.cpusContainerOptions.CPUSetPinned CPU set (API only, no CLI flag yet)
io.weightContainerOptions.IOWeight1–1000; db run sets this to 800
/proc/self/oom_score_adjContainerOptions.OOMScoreAdjAdjusts OOM-killer priority; db run sets -900
To cap a container to half a CPU core and 256 MB of RAM:
minibox run -c 50 -m 256 myapp

Security hardening

MiniBox applies several layers of defence-in-depth inside the child process before executing the workload:

Capability Drop

All Linux capabilities are cleared from the ambient set (PR_CAP_AMBIENT_CLEAR_ALL) and dropped from the bounding set (PR_CAPBSET_DROP) via prctl after chroot. Containers cannot re-acquire dropped capabilities thanks to PR_SET_NO_NEW_PRIVS.

Seccomp Deny-List

A seccomp BPF filter blocks a curated deny-list of dangerous syscalls (implemented in seccomp_linux.go). The filter is installed after PR_SET_NO_NEW_PRIVS.

rlimits

Resource limits (RLIMIT_*) are applied via setrlimit to bound file descriptor counts, process counts, and core dump sizes.

hidepid=2 on /proc

/proc is mounted with hidepid=2, so container processes cannot read /proc/<pid>/ entries of other PIDs — a common info-leak vector.
MiniBox runs a root daemon. The seccomp and capability model is designed for learning and testing workloads, not untrusted multi-tenant environments. Always test in a VM before deploying to shared infrastructure.

Tiny PID 1 init / reaper

After all security controls are applied, the container does not exec the workload directly. Instead it execs a tiny init shim — /proc/self/exe init -- <cmd...> — that becomes PID 1 inside the container’s PID namespace. The init shim (RunInit() in internal/runtime/init.go) does three things:
  1. Starts the target command as a child process.
  2. Forwards signals received by PID 1 to the child’s process group, so SIGTERM from minibox stop propagates correctly.
  3. Reaps zombies with wait4(-1, ...) so forked grandchildren that exit never accumulate as zombie entries.
Without this shim, any workload that forks sub-processes would leave zombie entries in the PID namespace because there would be nothing to wait on them.

Container ID format

Container IDs are exactly 8 hexadecimal characters (e.g. a1b2c3d4). The ID is printed when you run in detached mode or when you list containers with ps. Use it with every subsequent command:
minibox logs   a1b2c3d4
minibox stats  a1b2c3d4
minibox exec   a1b2c3d4 /bin/sh
minibox stop   a1b2c3d4
minibox rm     a1b2c3d4

Running interactive shells with exec

minibox exec enters a running container’s namespaces (using nsenter from util-linux) and runs an arbitrary command:
# Non-interactive command
minibox exec a1b2c3d4 ls -la /

# Interactive shell — requires nsenter on the host
minibox exec -it a1b2c3d4 /bin/sh
The -it flag allocates a PTY, attaches stdin/stdout/stderr to your terminal, and sets up a session leader so the shell behaves correctly. nsenter enters all six namespaces (-m -u -n -i -p plus the mount namespace).
exec runs nsenter from the host side via the daemon. It requires nsenter (part of util-linux) to be installed on the host system.

Live resource metrics with stats

minibox stats reads cgroup v2 metrics and host veth counters for a single container and refreshes them every second:
minibox stats a1b2c3d4
Press Ctrl+C to stop. The output shows memory usage, CPU usage, PID count, I/O bytes, and network bytes in/out.

Container states

StateMeaning
createdContainer record registered but process not yet confirmed running
runningChild process is alive (verified by kill -0 <pid>)
exitedProcess has exited; EXIT column shows the numeric exit code
State is persisted in DataRoot/state.json and survives daemon restarts. On each ps call, MiniBox performs a live kill -0 check and transitions any running container whose PID is gone to exited.

Examples

# Run an interactive shell in the alpine image
minibox run alpine /bin/sh

# Run a one-shot command
minibox run alpine ls -la /

Build docs developers (and LLMs) love