Reading Files
Read a file written inside the sandbox back to the host process.
read-file
Demonstrates sb.readFile() — reading a file written inside the sandbox back to the host process.
Setup
bunx alineo-cli init # starts OpenSandbox in Docker (one-time setup)Run
bun install
bun startWhat it does
- Creates a
node:20-slimsandbox - Runs a Node.js one-liner that writes the Node version to
/tmp/version.txt - Reads the file back using
sb.readFile() - Writes a JSON report to the sandbox using
sb.writeFile()and reads it back - Prints both captured values to the console