Skip to main content

What You’ll Learn

  • Creating a tar.gz from a local directory
  • Uploading it with Volumes.create()
  • Attaching it to a new sandbox via Sandbox.create(volumes=[...])
  • Confirming the files materialize at the mount path before the first command runs

Prerequisites

Code Walkthrough

Build a tarball in memory and upload it, then attach to a sandbox.
mount_path / mountPath must be an absolute directory inside the sandbox and cannot be a system directory (/, /etc, /usr, /proc, /sys, /dev, /bin, /sbin, /lib, /lib64, /var, /run, /boot). The tarball’s regular-file entries are materialized there. Expected output:
Clean up when you’re done. The blob + metadata row are removed; the volume is no longer attachable.

Full Example

Runnable versions live in the repo:
  • Python: cookbook/examples/volumes-quickstart/main.py
  • TypeScript: cookbook-ts/volumes_quickstart.ts
Both upload a sample tarball, spin up two sandboxes with the same volume attached, and confirm both see identical contents.

Limitations

  • Body must be application/gzip (a tar archive gzipped).
  • 4 GiB upload cap.
  • Files materialize once, at sandbox boot. Sandbox writes to files under mount_path stay private to that sandbox — they do not flow back to the volume.