modal
    Preparing search index...

    Class Sandbox

    Sandboxes are secure, isolated containers in Modal that boot in seconds.

    Index

    Properties

    sandboxId: string

    Accessors

    Methods

    • Disconnect from the Sandbox, cleaning up local resources. The Sandbox continues running on Modal's infrastructure. After calling detach(), most operations on this Sandbox object will throw.

      Returns void

    • Get tags (key-value pairs) currently attached to this Sandbox from the server.

      Returns Promise<Record<string, string>>

    • Mount an Image at a path in the Sandbox filesystem.

      Parameters

      • path: string

        The path where the directory should be mounted

      • Optionalimage: Image

        Optional Image to mount. If undefined, mounts an empty directory.

      Returns Promise<void>

    • Check if the Sandbox has finished running.

      Returns null if the Sandbox is still running, else returns the exit code.

      Returns Promise<null | number>

    • Set tags (key-value pairs) on the Sandbox. Tags can be used to filter results in Sandbox.list.

      Parameters

      • tags: Record<string, string>

      Returns Promise<void>

    • Snapshots and creates a new Image from a directory in the running sandbox.

      Parameters

      • path: string

        The path of the directory to snapshot

      Returns Promise<Image>

      Promise that resolves to an Image

    • Snapshot the filesystem of the Sandbox.

      Returns an Image object which can be used to spawn a new Sandbox with the same filesystem.

      Parameters

      • timeoutMs: number = 55000

        Timeout for the snapshot operation in milliseconds

      Returns Promise<Image>

      Promise that resolves to an Image

    • Returns Promise<void>

    • Parameters

      • params: { wait: true }

      Returns Promise<number>

    • Get Tunnel metadata for the Sandbox.

      Raises SandboxTimeoutError if the tunnels are not available after the timeout.

      Parameters

      • timeoutMs: number = 50000

      Returns Promise<Record<number, Tunnel>>

      A dictionary of Tunnel objects which are keyed by the container port.