microsandbox machine provider reaches a running
microsandbox microVM, by name, and
runs the programs it captures in it. You create and start the sandbox; Mirage runs programs in
it through the msb CLI. Python SDK and Node.
Installation
Installmsb 0.7.14 or newer on the host and put it on PATH. Create a
sandbox from an image with sh, your programs, and the tools needed for
connecting the workspace:
Usage
captures defaults to @external.
Add @python to run Python programs in the guest too.
- Python
- TypeScript
- YAML
Connecting the workspace
Pick amount_type. With ssh, install mirage-ai[ssh] on a Python
host or ssh2 on a Node host; the guest needs sshfs and access to
/dev/fuse; with mirage, mirage-fuse and the same access. With own, copy sandbox.yaml in and start Mirage in the
guest:
Pausing the sandbox
To pause the sandbox when the workspace pauses, seton_pause: pause on the
machine:
workspace.pause() closes the workspace, then runs msb pause: the sandbox
is suspended and its memory stays on the host. The next line resumes it with
msb resume. Without on_pause, workspace.pause() leaves the sandbox
running unless the call names the machine. See
Pause.
Notes
- Keep the sandbox running while Mirage uses it. Each line runs its own
msb exec, so a restart needs no reconnect. Withownorboth, start the sandbox’s Mirage again after a restart, or from its image’s entrypoint; until then lines exit 126. - Stopping or closing the workspace leaves the sandbox running.
- A timeout cancels the CLI call and stops that run’s processes in the sandbox.
- A program’s output reaches Mirage as it prints, except when Mirage pipes input into the program: then the output arrives when the program ends.
- Commands share the sandbox’s files and processes. Use one sandbox per tenant.
- Environment values are passed as CLI arguments. Avoid secrets on hosts shared with untrusted users.