Prerequisites
- Permission to create resources in your team.
- For the CLI procedures, the Baseten CLI, signed in.
Choose a built-in image
The image catalog lists built-in environments for languages, browsers, web applications, and desktops, plus the custom images built by teams you can access. Each image has an Image reference, such asbaseten/base-image:latest, that you use to
create a sandbox.
- UI
- CLI
To choose a built-in image:
- Sign in to your workspace at app.baseten.co and choose Sandboxes in the sidebar.
- Choose Create sandbox.
- To narrow the catalog, type a runtime or image name in Search images, or select a workload under Category. Clear category filters to include Base Image, which has no category.
- Choose an image card, then review its Image, Default memory, and Ports.
Create a custom image
A custom image packages the dependencies and starting files your tasks need. Build one from a Dockerfile with the CLI, use an SDK’sImageBuilder, or
import an image from a registry.
Base Image includes wget, but it doesn’t include curl. Install any
additional tools your task needs in a custom image.
To build a custom image:
-
Run the following commands to set a new image name and create a build directory:
-
Create a Dockerfile. A sandbox image must include the sandbox API server
and start it as the entrypoint, so copy it from the sandbox API image. This
example starts from the same base as Base Image (Alpine Linux with
Node.js, Python, Git, and Bash) and adds a package and a starting file.
Run the following commands to create the Dockerfile and starting file:
-
Keep credentials out of the build directory. Run the following command to
push the directory and wait for the image to build:
-
Run the following commands to create a sandbox from the image and check its
installed tools and starting file:
Build with an SDK
AnImageBuilder creates a Dockerfile and its build context. It adds the
sandbox API binary and entrypoint unless you supply them yourself.
Set up your SDK and API key before running the code.
- Python
- TypeScript
- Go
To build and check a custom image:Run the following code:
my-image:latest to the SDK. The catalog shows the same custom image
as sandbox/my-image:latest.
The push call waits until the image is BUILT. The command then prints
hello from the image, confirming that the sandbox contains the starting
file. The examples then delete the test sandbox and keep the image for future
sandboxes. If a request fails after creating image-check,
delete the sandbox before running the code
again. Delete my-image separately if you no
longer need it.
For repeatable builds, pin the sandbox API image to a tested tag or digest
instead of
ghcr.io/blaxel-ai/sandbox:latest. Set the reference in a
Dockerfile’s COPY --from, or use sandbox_api_image with Python’s
from_registry(), sandboxApiImage with TypeScript’s fromRegistry(),
or SandboxAPIImage with Go’s NewImageBuilderWithOptions().Import an image from a registry
To import an image from a registry:-
Set a new repository name and the source image’s full registry reference,
including the registry hostname. The source image must include and start
the sandbox API server, as the built-in images do. Run the following commands
to set the image name and registry reference:
-
Run the following command to import the image:
The CLI returns once the import is accepted. To wait for the import to finish, run the following command:To import from a private registry, run the following command with a Docker
config.jsoncontaining the registry credentials:
List images
Check a custom image’s build status before using it. The Images tab andbaseten sandbox image list list only your team’s custom images, not built-in
images.
- UI
- CLI
To list your team’s images:
- In Sandboxes, choose Images.
- For Find by image name or tag, type the image name.
- Review the matching row’s Latest size, Sandboxes, Updated, and Status values.
List versions
List an image’s version tags to choose which version a sandbox uses. Baseten assigns the tags; you can’t set or rename them.- UI
- CLI
To list an image’s versions:
- In Sandboxes > Images, choose the image.
- On Overview, review each version’s Tag, Size, Created, and Updated values in the tags table.
Add a version
Push changed source to an existing image name to add a version. Pushing identical source doesn’t create a version, and existing versions stay available. To add a version:- Run
baseten sandbox image pushagain with the sameIMAGE_NAME, following Create a custom image. - List the image’s versions and confirm a new tag appears.
Use an image in a sandbox
Create a sandbox in the team that owns the custom image. Choose the image in the dashboard, or run the following command:latest when you select a custom image. This tag tracks
the newest version and doesn’t appear in the version list.
To keep new sandboxes on one version, choose a tag from
List versions and replace latest in the image reference
with that tag, such as sandbox/<IMAGE_NAME>:<TAG_NAME>. Sandboxes already
using a specific tag keep their version.
Delete an image or a version
Deleting a sandbox leaves its image available. Delete the image or individual versions separately when you no longer need them.Deleting an image removes all its versions. Delete a single tag to remove
only that version.
- UI
- CLI
To delete a version:
- In Sandboxes > Images, choose the image.
- In the tags table, open the actions menu on the version’s row.
- Choose Delete tag, then choose Delete tag again to confirm.
- In Sandboxes > Images, open the actions menu on the image’s row.
- Choose Delete image.
- Type the image’s name, then choose Delete image.