Skip to main content
InteractiveBox attaches your terminal directly to a shell running inside a VM — like SSH into a sandbox. Use it for interactive tools, REPLs, debugging sessions, or any workflow where you need a live terminal.

What you’ll build

A script that:
  1. Launches an InteractiveBox with a shell
  2. Runs interactive commands in a TTY session
  3. Connects to a Python REPL inside the VM

Prerequisites

Requires Python 3.10+.

Step 1: Start a shell session

Launch an InteractiveBox and drop into a shell. The session stays open until you type exit or the shell terminates.
shell.py
What’s happening:
  • InteractiveBox creates a VM with Alpine Linux and attaches your terminal to /bin/sh
  • Your keystrokes go directly into the VM’s shell, and output streams back in real-time
  • wait() blocks until the shell process exits (when you type exit or press Ctrl+D)

Step 2: Choose your shell

You can run any shell or REPL available in the image. Specify it with the shell parameter.
bash_session.py
python_repl.py
Make sure the shell you specify actually exists in the image. Alpine uses /bin/sh (busybox), not /bin/bash. Ubuntu has both.

Step 3: Choose the right TTY mode

The tty parameter controls how InteractiveBox handles terminal I/O. The right choice depends on how you’re using the box.
tty_modes.py
programmatic.py
InteractiveBox extends SimpleBox, so you always have access to exec() for running one-off commands. The tty parameter only controls whether the shell session itself gets I/O forwarding — exec() works regardless.

What’s next?

Run any language or tool

Use SimpleBox with custom images to run Node.js, Go, Rust, or any CLI tool.

Handle errors and debug

Catch exceptions, handle timeouts, and debug failures.

InteractiveBox API reference

Full API docs for InteractiveBox constructor options and methods.