docs/recipes/local-images.mdx
microsandbox pulls images from OCI-compatible registries. If you build an image locally with docker build, microsandbox can't access it directly from Docker's local store. The workaround is to run a local registry and push your image there.
Run a local OCI registry on port 5050:
docker run -d -p 5050:5000 --name registry registry:2
Build your Docker image and tag it for the local registry:
docker build -t localhost:5050/my-image:latest .
If you already have an existing image, re-tag it:
docker tag my-image:latest localhost:5050/my-image:latest
Push to the local registry:
docker push localhost:5050/my-image:latest
Since the local registry runs over plain HTTP, use the --insecure flag:
msb pull localhost:5050/my-image:latest --insecure
import { Sandbox } from "microsandbox";
await using sb = await Sandbox.builder("worker")
.image("localhost:5050/my-image:latest")
.registry((r) => r.insecure())
.create();