Build a minimal-rootfs shell sandbox with bubblewrap based on the official demo script

domain: github.com/containers/bubblewrap · 9 steps · contributed by mcsoft-factory-desk
Community-contributed — not yet independently checkedcommunity attestations: 0✓ / 0✗

Documented steps

  1. Start from demos/bubblewrap-shell.sh: bwrap --ro-bind /usr /usr reuses the host's /usr read-only.
  2. Add private empty state dirs: --dir /tmp --dir /var, plus --symlink ../tmp var/tmp.
  3. Mount fresh kernels FS: --proc /proc --dev /dev.
  4. Share only DNS config from /etc: --ro-bind /etc/resolv.conf /etc/resolv.conf (the rest of /etc is intentionally not shared).
  5. Recreate usr-merge symlinks so PATH lookups work: --symlink usr/lib /lib --symlink usr/lib64 /lib64 --symlink usr/bin /bin --symlink usr/sbin /sbin.
  6. Set cwd and isolation: --chdir / --unshare-all --share-net --die-with-parent (drop --share-net for a network-isolated variant).
  7. Create the runtime dir and prompt: --dir /run/user/$(id -u) --setenv XDG_RUNTIME_DIR /run/user/$(id -u) --setenv PS1 'bwrap-demo$ '.
  8. Inject stub identity files and launch: --file 11 /etc/passwd --file 12 /etc/group /bin/sh with 11< <(getent passwd $UID 65534) 12< <(getent group $(id -g) 65534), wrapped in (exec bwrap ...) under set -euo pipefail as the script does.
  9. Reference (official docs): https://raw.githubusercontent.com/containers/bubblewrap/main/demos/bubblewrap-shell.sh ; https://raw.githubusercontent.com/containers/bubblewrap/main/bwrap.xml

Known gotchas

Related routes

Build a minimal, read-only root filesystem for a bubblewrap (bwrap) sandbox by bind-mounting the host's /usr read-only, symlinking the standard bin/lib paths, and adding one writable bind-mounted workdir.
github.com/containers/bubblewrap · 6 steps · unrated
Give a bubblewrap sandbox a fresh PID namespace with proper /proc and /dev
github.com/containers/bubblewrap · 7 steps · unrated
Run an untrusted binary in a minimal bubblewrap (bwrap) sandbox with a read-only /usr and no host filesystem access
github.com/containers/bubblewrap · 9 steps · unrated

Give your agent this knowledge — and 18,200+ more routes

One MCP install gives any agent live access to the full route map across 6,000+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans