Skip to main content
Use snapshots when expensive setup should become a durable starting point for many later sandboxes. Each Sandbox.create(snapshot_id=...) call starts a fresh independent sandbox from the same snapshot, and the snapshot remains available until deleted.

Create a reusable snapshot

from nullspace import Sandbox

sandbox = Sandbox.create(template="base")
sandbox.files.write("/workspace/state.txt", "baseline\n")

snapshot = sandbox.create_snapshot()
print(snapshot.id)
print(sandbox.files.read("/workspace/state.txt"))

Spawn from the snapshot

from nullspace import Sandbox

first = Sandbox.create(snapshot_id=snapshot.id)
second = Sandbox.create(snapshot_id=snapshot.id)

try:
    first.files.write("/workspace/state.txt", "first child\n")
    second.files.write("/workspace/state.txt", "second child\n")

    print(first.files.read("/workspace/state.txt"))
    print(second.files.read("/workspace/state.txt"))
finally:
    first.kill()
    second.kill()

Manage reusable snapshots

from nullspace import Snapshot

snapshot = Snapshot.get("snap_...")
print(snapshot.id, snapshot.sandbox_id, snapshot.created_at)

for item in Snapshot.list(sandbox_id=snapshot.sandbox_id):
    print(item.id, item.metadata)

Snapshot.delete(snapshot.id)

Pause, snapshot, or fork

PrimitiveSource sandboxReuse modelRestore call
Hibernate / pauseStops the source VM1-to-1 persistenceSandbox.resume(snapshot_id) or Sandbox.connect(original_id)
Reusable snapshotBriefly pauses, then keeps source running1-to-many durable templateSandbox.create(snapshot_id=snapshot_id)
ForkKeeps source running1 live child per requestsandbox.fork()

Behavior

  • Snapshots include VM memory and mutable rootfs state.
  • Shared volumes remain external durable storage and are remounted on compatible restore; they are not copied into the snapshot.
  • Restore requires compatible runtime hosts, kernels, and snapshot artifacts. A paused sandbox alias can resume only from its own latest snapshot lineage; reusable snapshots are restored with Sandbox.create(snapshot_id=...) and do not mutate the source sandbox.
  • Delete removes reusable snapshot metadata and makes its artifact eligible for cleanup when no active reusable snapshot references it.