1
Install the CLI
nsbx. There is no binary to download and no runtime to install — the container
engine already on your host is the runtime.Or skip the install entirely and prefix every command with npx nativesandbox instead:Under nvm, a global install lands in the current Node version’s directory, so switching
versions hides
nsbx until you install it there too.2
Run something
3
Check the host
setup prints each command, says whether it needs root, and waits for you to agree before
running it. Nothing happens to your machine that you have not seen first. See
the CLI for the full check list.4
Install the library
5
Create a sandbox and run a command
create() with the same name
returns the same sandbox while its shape still serves the request — see
sandboxes.memory is a branded type, so memory: 512 will not compile. Write the unit — MiB(512),
GiB(2) — and the ambiguity between megabytes, mebibytes and bytes cannot reach the engine.6
Move files in and out
box.workspaceDir is the directory on the host, and reading it is reading the sandbox.7
Clean up
What happens when you create a sandbox
- The image is pulled if it is not already cached — slow the first time, instant afterwards.
- A workspace directory is created on the host and bind-mounted at
/workspace. - A container starts with your memory, CPU and PID limits applied through cgroups, every Linux capability dropped, and no-new-privileges set.
- It idles on
sleep infinity, so every later command is an exec into the same sandbox and whatever the last command installed is still there. - If it goes quiet for five minutes it stops, keeping the workspace. After an hour it is retired and rebuilt fresh over the same warm workspace.
npm install in a sandbox is free.
A complete example
Next
Requirements
What the host needs, and how to prove it has it.
The CLI
doctor, setup, run, ls, exec, rm, sweep.
Isolation
What is taken away from every sandbox.
API reference
Every option and method.