On first run, BoxRun automatically starts its server in the background and pulls the image:
Copy
Server not running. Starting boxrun serve in background...Pulling ubuntu:24.04...root@box_a1b2c3:~#
You’re now inside a full Ubuntu VM. Try uname -a, install packages, run scripts — it’s a real Linux environment with its own kernel. Exit with Ctrl-D or type exit.
2
Create a named box
Copy
boxrun create ubuntu --name dev
Copy
Box created: box_d4e5f6 (dev)
The box is now running and ready to accept commands.
3
Run commands
Copy
boxrun exec dev -- uname -a
Copy
Linux box_d4e5f6 6.1.0 #1 SMP PREEMPT aarch64 GNU/Linux
Copy
boxrun exec dev -- cat /etc/os-release | head -2
Copy
PRETTY_NAME="Ubuntu 24.04 LTS"NAME="Ubuntu"
4
Transfer files
Copy
# Upload a file into the boxboxrun cp ./data.csv dev:/root/data.csv# Download a file from the boxboxrun cp dev:/root/results.csv ./results.csv
5
List your boxes
Copy
boxrun ls
Copy
ID NAME STATUS IMAGE CPU MEM DISK CREATEDbox_d4e5f6 dev running ubuntu:24.04 2 1024MB 8G 2025-01-15T10:30:00
6
Manage the lifecycle
Copy
boxrun stop dev # preserves diskboxrun start dev # restart with disk intactboxrun rm dev # destroy permanently
The server starts automatically on your first command — no need to run boxrun serve manually.
import asynciofrom boxrun_sdk import BoxRunClientasync def main(): async with BoxRunClient() as client: # Create a sandbox box = await client.create("ubuntu", name="dev") # Run a command result = await box.exec(["echo", "hello from BoxRun"]) print(f"Exit code: {result.exit_code}") # Stream output in real time async for event in box.exec_stream(["apt-get", "update"]): if event.type == "log": print(event.data, end="") # Upload and download files await box.upload("./script.py", "/root/script.py") await box.download("/root/output.json", "./output.json") await box.remove()asyncio.run(main())
For one-shot tasks, use client.run() — it creates a box, runs the command, returns output, and destroys the box:
Copy
result = await client.run("python", ["python3", "-c", "print(42)"])print(result.stdout) # "42\n"