volumeMounts / volume_mounts object are the mount paths inside the sandbox.
import { Volume, Sandbox } from 'e2b'
const volume = await Volume.create('my-volume')
// You can pass a Volume object
const sandbox = await Sandbox.create({
volumeMounts: {
'/mnt/my-data': volume,
},
})
// Or pass the volume name directly
const sandbox = await Sandbox.create({
volumeMounts: {
'/mnt/my-data': 'my-volume',
},
})
// Files written to /mnt/my-data inside the sandbox are persisted in the volume
await sandbox.files.write('/mnt/my-data/hello.txt', 'Hello, world!')
from e2b import Volume, Sandbox
volume = Volume.create('my-volume')
# You can pass a Volume object
sandbox = Sandbox.create(
volume_mounts={
'/mnt/my-data': volume,
},
)
# Or pass the volume name directly
sandbox = Sandbox.create(
volume_mounts={
'/mnt/my-data': 'my-volume',
},
)
# Files written to /mnt/my-data inside the sandbox are persisted in the volume
sandbox.files.write('/mnt/my-data/hello.txt', 'Hello, world!')