image to use the default environment, which includes Python 3.12 and Node.js 22
with 2 vCPU and 1 GiB of memory. For reproducible environments, use a specific image
version or digest and include frequently used dependencies in your image.
Wait for an image
The first use of an image and configuration may require preparation. The SDK waits by default. Large images can take several minutes; increasingwarm_timeout gives
the SDK more time to wait:
create() in a shorter
timeout when preparing a new image.
If a wait expires, preparation may still be in progress. Check the template’s
status and status_detail, or continue waiting with box.templates.wait().
If the create request itself loses its connection, check box.sandboxes.list()
before creating another sandbox.
Prepare a reusable template
Create a named template and wait until it is ready:box.templates.list() shows available templates. Shared templates are marked
shared=True and are read-only. Use box.templates.delete(template.id) to remove
a template you own when you no longer need it.
Use a private registry
Store registry credentials for your organization before creating from a private image. Read secrets from your environment rather than putting them in code:box.registries.list() lists configured registries without returning their secrets.
Use box.registries.delete("ghcr.io") to remove a stored credential.
For AWS ECR, role-based access avoids storing any long-lived secret. Register
the registry host with kind="ecr-assume-role", an IAM role_arn in your AWS
account, and an external_id you choose:
ecr:GetAuthorizationToken, plus ecr:BatchGetImage and layer-download
actions on the repositories you use), and a trust policy that allows the
LithosBox platform’s AWS account — provided during onboarding — to assume the
role, conditioned on your external_id. Request and response fields are in
Registries.
Choose a runtime
The defaultruntime="container" runs the image’s application. Use runtime="vm"
for workloads that need Docker or services such as systemd inside the sandbox:
Image requirements and networking
Use compatible Linux images. GPU workloads are not yet supported. Each sandbox has a writable disk (16 GiB by default; 32 GiB withwritable_size_bytes, and 64 GiB on upgraded plans).
The disk size is part of an image’s prepared configuration, like CPU and memory:
the first create of an image at a non-default size prepares that configuration
once, as described in Wait for an image.
Outbound connections use IPv4. Give package downloads a finite timeout and retry
transient failures. For example, apt-get -o Acquire::Retries=3 update retries
failed package-index downloads. Preinstall large dependencies in your image when
possible so each task does not need to download them again.
Set disable_internet=True at creation to disable outbound internet access, or
allow_egress=[...] to allow only listed hosts (see
Limit outbound network access). That setting also applies to
snapshots restored from the sandbox and to its forks.
Environment variables are set through a command or session,
or included in the image; create() does not accept an environment-variable map.
When finished with the final example: