A minimal Worker whose Durable Objects start namespace-backed containers on demand.
- Node.js, pnpm, and Docker
- A Cloudflare account with Workers, Containers, and the new runtime enabled.
Install dependencies:
pnpm installUse the preview Wrangler build from workers-sdk PR #15480 until it is upstream.
Authenticate, then deploy with the Wrangler PR build:
npx --yes https://pkg.pr.new/wrangler@15480 whoami
npx --yes https://pkg.pr.new/wrangler@15480 deployWrangler builds and pushes the image, prepares it to run on Cloudflare, uploads the Worker, and creates the namespace-backed application.
Use the Worker URL printed by Wrangler:
curl "https://<worker-url>/?instance=first"
curl "https://<worker-url>/_status?instance=first"
curl "https://<worker-url>/_destroy?instance=first"Each instance value selects a different Durable Object and container.
- The top-level
containers[]entry attaches a Durable Object-managed application to theSandboxnamespace. scheduling_policy: "durable_object"makes each Durable Object own its container lifecycle.- The named
images.appconfiguration tells Wrangler to build, push, and prepare the image. - Wrangler exposes prepared images through the class-scoped
env.EXPERIMENTAL_CLOUDFLARE_CONTAINER_IMAGESmap.