---
title: Create a sandbox from a custom image
description: Create a Databricks Sandbox from your own container image stored in Artifact Registry, so every sandbox starts with your packages and configuration already installed.
canonical_url: https://docs.databricks.com/aws/en/compute/serverless/sandbox-custom-image
---

# Create a sandbox from a custom image

> [!NOTE]
> **Beta**
>
> This feature is in [Beta](https://docs.databricks.com/aws/en/release-notes/release-types.md). To enable this feature preview in the workspace, opt into the **Databricks Sandbox** setting in the workspace Previews page. See [Manage Databricks previews](https://docs.databricks.com/aws/en/admin/workspace-settings/manage-previews.md).

You can create a sandbox from your own container image stored in [Artifact Registry](https://docs.databricks.com/aws/en/artifact-registry/index.md). Artifact Registry stores container images as governed assets in Unity Catalog, so you control access to them with Unity Catalog privileges. The sandbox starts with the image's packages, tools, and configuration already installed, so you don't need to install dependencies each time you create a sandbox.

For an overview of Databricks Sandbox, see [Databricks Sandbox](https://docs.databricks.com/aws/en/compute/serverless/sandbox.md).

## Requirements

* Your workspace meets the Databricks Sandbox prerequisites. See [Prerequisites](https://docs.databricks.com/aws/en/compute/serverless/sandbox.md#prerequisites).
* Your workspace meets the Artifact Registry requirements. See [Requirements](https://docs.databricks.com/aws/en/artifact-registry/get-started.md#requirements).
* You have the `USE CATALOG`, `USE SCHEMA`, and `READ VOLUME` privileges on the catalog and schema that contain the image. See [Grant permissions](https://docs.databricks.com/aws/en/artifact-registry/get-started.md#artifact-registry-permissions).
* The image uses glibc 2.25 and above. If the image uses an Ubuntu base, use Ubuntu 18.04 and above. Images that use musl instead of glibc, such as Alpine Linux and images built on it (for example, `python:<version>-alpine` or `node:<version>-alpine`), are not supported.

## Push an image and create a sandbox

1. Build the image with Docker and push it to Artifact Registry. See [Push an image](https://docs.databricks.com/aws/en/artifact-registry/get-started.md#push-an-image).
2. Wait until the image's acceleration status is `SUCCESS`. Image acceleration runs automatically after you push and can take 15 minutes or more. See [Check image acceleration status](https://docs.databricks.com/aws/en/artifact-registry/get-started.md#image-acceleration-status).
3. Create the sandbox and set `image_uri` to the image's Unity Catalog name, in the format `catalog.schema.artifact:tag`. To pin an exact version, use a digest instead of a tag: `catalog.schema.artifact@sha256:<digest>`.

   For example, to create a sandbox from the `main.agents.agent-base:v1` image, run the following:

   ```python
   from databricks.sdk import WorkspaceClient
   from databricks.sdk.service.sandbox import EnvironmentSpec, Sandbox, SandboxSpec

   w = WorkspaceClient()

   created = w.sandbox.create_sandbox(
       sandbox=Sandbox(
           spec=SandboxSpec(
               environment=EnvironmentSpec(image_uri="main.agents.agent-base:v1"),
           ),
       ),
       sandbox_id="my-custom-sandbox",
   )
   print(created.name)   # "sandboxes/my-custom-sandbox"
   ```

A sandbox created from a custom image keeps the same persistent home directory and stop and start behavior as any other sandbox.

## Troubleshooting

If the create request fails, check the error message:

* `Image <uri> is not ready for use`: Image acceleration has not finished. Check the image's acceleration status and retry after it reaches `SUCCESS`.
* `Not authorized to access image <uri>`: You don't have the required privileges on the image. Ask the catalog or schema owner to grant them.

## Limitations

* Custom images must be stored in Artifact Registry. You cannot create a sandbox from an image in an external registry, and Databricks does not build images for you.
* Sandboxes created from a custom image can take longer to start than sandboxes that use the default environment.

## Additional resources

* [Databricks Sandbox](https://docs.databricks.com/aws/en/compute/serverless/sandbox.md)
* [Create and manage sandboxes with the SDK](https://docs.databricks.com/aws/en/compute/serverless/sandbox-usage-guide.md)
* [Get started with Artifact Registry](https://docs.databricks.com/aws/en/artifact-registry/get-started.md)
