> ## Documentation Index
> Fetch the complete documentation index at: https://docs.styne.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Container images

> [//]: # (smoke: not executed, an image starts only on a node that holds a prepared build of it, and an image nobody prepared answers 404)

A sandbox can start from a public container image instead of a Styne template. Pass the image in the create call:

```bash theme={"theme":"css-variables"}
curl -sS https://api.styne.ai/sandboxes \
  -H "Authorization: Bearer $STYNE_API_KEY" \
  -H "content-type: application/json" \
  -d '{"image": "python:3.12-slim"}'
```

The sandbox is a full VM whose root disk is that image, so what the image ships is what runs: `python3 --version` prints
3.12 in the example. The answer is the usual create answer plus an `image` block:

```json theme={"theme":"css-variables"}
{"sandboxID": "...", "image": {"ref": "docker.io/library/python:3.12-slim", "digest": "sha256:...", "workdir": "/", "user": "", "entrypoint": [], "cmd": ["python3"]}}
```

## What an image sets

| Image field | In the sandbox |
| - | - |
| `ENV` | The sandbox environment. `envVars` of the create override it. |
| `WORKDIR` | The directory of a command that names no `cwd`. |
| `USER` | The user of a command that names no `user` (a name, a uid, `name:group` or `uid:gid`). |
| `ENTRYPOINT`, `CMD` | Returned in the `image` block. A sandbox does not run them: start what you need with a command. |

An image with no shell gets a minimal one at `/bin/sh`, so `sh -c` commands work.

## Which images

References as Docker writes them: `alpine`, `python:3.12-slim`, `grafana/grafana:11`, `ghcr.io/org/app:v1`,
`quay.io/org/app@sha256:...`. Public images on Docker Hub (`docker.io`), `ghcr.io` and `quay.io` work; any other registry
answers `422 image_registry_not_allowed`. Images are `linux/amd64`, at most 10 GiB unpacked. A tag is resolved when an
image is first prepared; use `@sha256:...` to pin a digest.

`alpine:3.20`, `python:3.12-slim`, `node:22`, `node:24` and `ubuntu:24.04` are always ready. Any other image is prepared the
first time somebody asks for it.

## The first create of a new image

A create of an image that is not prepared yet starts its preparation (pull, unpack, first boot, snapshot: about 20 to 60
seconds) and waits for it. When the image is ready the answer is the normal `201`. When it is not ready yet, the answer is
`202` with `error_code: image_building` and a `Retry-After`: repeat the same create and it joins the build.

```json theme={"theme":"css-variables"}
{"code": 202, "error_code": "image_building", "message": "image docker.io/library/redis:7-alpine is being prepared; repeat this create in a few seconds", "image": {"ref": "docker.io/library/redis:7-alpine", "status": "queued"}}
```

Wait for longer inside the call with `"imageOptions": {"waitSeconds": 25}` (the default is 15, the most 25). A prepared
image starts like any template: tens of milliseconds on the machine, plus your network round trip.

## Errors

| Status | `error_code` | Meaning |
| - | - | - |
| 202 | `image_building` | The image is being prepared. Repeat the create. |
| 400 | `invalid_image_ref` | The reference does not parse. |
| 404 | `image_not_found` | The registry has no such repository, tag or digest. |
| 401 | `image_auth_required` | The image is private. Private images are not served. |
| 413 | `image_too_large` | More than 10 GiB unpacked, or too many files. |
| 422 | `image_registry_not_allowed` | The registry is not `docker.io`, `ghcr.io` or `quay.io`. |
| 422 | `image_and_template` | `image` is given together with `templateID` or `snapshot`. Name only one. |
| 422 | `image_platform_unsupported` | No `linux/amd64` image. |
| 422 | `image_layer_unsupported` | A layer type that cannot be unpacked. |
| 429 | `image_build_rate_limited` | An account may ask for 20 new images per hour and 16 images wait at most. Retry later. |
| 502 | `image_registry_unavailable` | The registry did not answer or limited the pull. |
| 500 | `image_build_failed` | The image could not be prepared. A new create tries again after 10 minutes. |

## Read an image

`GET /images/{digest}` answers the registered image: its references, its config and the machines that hold a ready build.

| Method | Path | What it does |
| - | - | - |
| `GET` | `/images/{digest}` | The registered image: its references, its config and the machines that hold a ready build |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.