Skip to content

feat(wrangler): add container support to worker previews#13781

Draft
maxwellpeterson wants to merge 1 commit into
cloudflare:mainfrom
maxwellpeterson:mpeterson/preview-containers
Draft

feat(wrangler): add container support to worker previews#13781
maxwellpeterson wants to merge 1 commit into
cloudflare:mainfrom
maxwellpeterson:mpeterson/preview-containers

Conversation

@maxwellpeterson
Copy link
Copy Markdown
Member

@maxwellpeterson maxwellpeterson commented May 2, 2026

wrangler preview now supports containers via a new previews.containers configuration block.

Container configuration is non-inheritable: declare containers explicitly in the previews block to enable them for previews, mirroring how previews.durable_objects works today. Preview container application names are auto-generated by wrangler in the form {worker_name}_{preview_slug}_{class_name} and are not user-configurable — the config validator rejects entries that set a name field. Container applications bound to Durable Object classes implemented by another Worker (via script_name) are intentionally skipped, since the implementing Worker owns its own container application.

Container applications are created on wrangler preview and removed on wrangler preview delete. Cleanup matches applications by their auto-generated name prefix ({worker_name}_{preview_slug}_), so deletions are scoped to the specific preview being torn down. Failures on individual application deletes are logged as warnings but do not block the preview deletion itself.

This was originally part of #13712 and has been split out for easier review.

// wrangler.json
{
  "previews": {
    "durable_objects": {
      "bindings": [{ "name": "MY_CONTAINER", "class_name": "MyContainer" }]
    },
    "containers": [
      {
        "class_name": "MyContainer",
        "image": "registry.cloudflare.com/example:latest"
      }
    ]
  }
}

  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because:

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 2, 2026

🦋 Changeset detected

Latest commit: aafe866

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 2, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13781

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@13781

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13781

miniflare

npm i https://pkg.pr.new/miniflare@13781

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13781

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13781

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13781

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13781

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13781

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@13781

wrangler

npm i https://pkg.pr.new/wrangler@13781

commit: aafe866

@maxwellpeterson maxwellpeterson force-pushed the mpeterson/preview-containers branch from 248f2f4 to 28b0ab1 Compare May 5, 2026 16:41
@maxwellpeterson maxwellpeterson force-pushed the mpeterson/preview-containers branch from 28b0ab1 to 80b4aeb Compare May 15, 2026 02:34
Worker previews now support containers via a new `previews.containers`
configuration block. Container configuration is non-inheritable: declare
containers explicitly in the `previews` block to enable them for
previews, mirroring how `previews.durable_objects` works today. Preview
container application names are auto-generated by wrangler in the form
`{worker_name}_{preview_slug}_{class_name}` and are not user
configurable -- the config validator rejects entries that set a `name`
field. Container applications bound to Durable Object classes
implemented by another Worker (via `script_name`) are intentionally
skipped, since the implementing Worker owns its own container
application.

Container applications are created on `wrangler preview` and removed on
`wrangler preview delete`. Cleanup matches applications by their
auto-generated name prefix (`{worker_name}_{preview_slug}_`), so
deletions are scoped to the specific preview being torn down. Failures
on individual application deletes are logged as warnings but do not
block the preview deletion itself.
@maxwellpeterson maxwellpeterson force-pushed the mpeterson/preview-containers branch from 80b4aeb to aafe866 Compare May 27, 2026 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants