Images and build contexts
A sandbox starts from an image. You have two choices:
- A registry image: name it in
imageon the sandbox create. Nothing to set up. - A built image: send Meadow a Dockerfile once, get an
image_id, and use it for every sandbox.
Next step: if a public image has what you need, use image and skip this page. Build an image when you need your own packages or files in every sandbox.
Registry images
The provider pulls the image, so it must be one the provider can reach. Both providers pulled Docker Hub images in our runs.
A name the provider cannot pull fails the create with a general message. See Attempts and failure reasons.
On Modal the sandbox ends if the image’s default command exits. See Fields.
Private registries
Add registry_auth with a user name and a password or token for the registry:
Only Modal supports this. Daytona is skipped, and with Daytona alone the create fails:
registry_auth also works on an image build, for a private base image, with the same Daytona limit. It cannot be combined with image_id on a sandbox create.
We have not pulled a private image through Meadow on the hosted beta. The Daytona rejection above is from a real run. The Modal path is not.
Build an image from a Dockerfile
dockerfile is the Dockerfile text, at most 512 KiB. An image is built once on each provider, and each build has its own status: building, ready, or failed.
Without wait, the response comes back at once with builds in building. Poll GET /v1/images/{image_id}.
The status code is 202 when a build started and 200 when the image already existed. A waited call returns 202 even when every build has finished or failed. Read each build’s status.
The builds on this page took 15 to 25 seconds on each provider.
Use the image
- A provider whose build is
readystarts the sandbox at once. - A provider with no build yet builds first. That time counts toward
create_timeout_seconds. The image above was built on Modal only, and a first sandbox on Daytona took 30 seconds while Daytona built it. - A provider whose build
failedis skipped.
A sandbox from a built image gets the size it asks for on both providers. On Daytona the first sandbox of a new size waits while a snapshot of that size is made. See Resources.
The same input gives the same image
The image id comes from the Dockerfile text and the build context. Sending the same two again returns the existing image with 200 and builds nothing. An Idempotency-Key header works here too: a retry with the same value and body returned the first answer with Idempotent-Replayed: true, and the same value with another body returned 409 idempotency_key_reused.
So a script can call POST /v1/images before every run and pay for the build once.
Build with local files
A Dockerfile that uses COPY or ADD on local files needs a build context: a gzipped tar of the directory those lines read from.
Pass the id as build_context_id:
The response is 202 with both builds in building. About 25 seconds later:
A sandbox from this image, on either provider, starts in /app with the file in place:
Build context rules:
There is no call to delete a build context. It expires by itself. A project cannot be deleted while it holds one that has not expired.
Large inputs such as datasets and model weights do not belong in a build context. Download them in a RUN line.
When a build fails
Meadow does not return the build log. error is a general message. To find the cause:
- Check for a
COPYof local files without abuild_context_id. It fails with exactly these messages. - Build the Dockerfile locally with
docker build. - Look up
provider_image_refin the provider’s own console, which has the build log.
Fix the Dockerfile and create again. A different Dockerfile is a different image, so the failed one stays until you delete it.
Other errors:
Rebuild
Send the same request with "rebuild": true to build again, for example to pick up a newer base image. The id stays the same and each provider gets a new provider_image_ref.
The previous provider image is removed, unless a sandbox created from this image_id is still live. In that case it is removed when you delete the image.
List, get, and delete
Delete an image
Delete removes the image at every provider. Running sandboxes are not affected. It took up to 10 seconds in our runs. The call has three answers, by the same rule as a sandbox delete:
In our runs on the hosted beta every delete returned 204, after 9 to 12 seconds. The 202 and 200 answers have not been seen there.
Meadow deletes the provider image with your current provider key for that provider, whatever key built the image. If that key is gone, or the provider keeps refusing, Meadow tries at most 10 times over at most 24 hours, then finishes the delete on its side and stops. From then on the image reads deleted with vendor_copies_may_remain, and both delete and get return it with 200. The same happens at once when you changed the provider key and the provider reports no such image under the new key.
Once an image is gone, a second delete returns 404, and so does a get. This differs from sandboxes, where the record stays.
What each provider keeps
Meadow builds in your own provider account, so the results are yours and count against your provider plan.
Neither provider has a call to delete uploaded build context bytes, so Meadow cannot remove them. Keep secrets out of build contexts. Pass them at run time in env.
Meadow’s own copy of a build context is deleted when it expires.
More in Known limits.
API reference
Operations on this page: createImage, getImage, listImages, deleteImage, createBuildContext, createSandbox.