Skip to content

Volumes

The files of a sandbox go when the sandbox goes. A volume is storage that stays. Mount it at a path in any sandbox.

Terminal window
boxfork mkvolume data
boxfork create --volume data:/data # read and write
boxfork create --volume data:/data:ro # read only
boxfork rmvolume data # refused while a sandbox has it mounted
from boxfork import Sandbox, Volume
data = Volume.create("data")
with Sandbox.create(volumes=[data.at("/data")]) as sbx:
sbx.run("echo kept > /data/note")
with Sandbox.create(volumes=["data:/data:ro"]) as sbx:
print(sbx.run("cat /data/note").stdout) # kept
  • Sandboxes that mount the same volume share it. The volume is one directory, not one copy for each sandbox.
  • The copies of a fork mount the same volumes as the original.
  • A snapshot does not contain the data of a volume.

boxfork serve --volume models:/models:ro mounts one volume read-only in each new sandbox. Thus you download the model weights one time for the machine, and not one time for each sandbox. To fill the cache, create one sandbox that mounts the same volume without :ro.

  • A volume has no size limit (#34).
  • A model that uses the tools cannot create or mount a volume (#35). The person or the program that creates the sandbox sets up the volumes.
  • The daemon does not delete a volume when you kill sandboxes. Delete it yourself.