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.
Use a volume
Section titled “Use a volume”boxfork mkvolume databoxfork create --volume data:/data # read and writeboxfork create --volume data:/data:ro # read onlyboxfork rmvolume data # refused while a sandbox has it mountedfrom 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.
One model cache for every sandbox
Section titled “One model cache for every sandbox”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.
Limits
Section titled “Limits”- 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.