Add sandbox container labels option#798
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 8fa7584 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
commit: |
Contributor
🐳 Docker Images Published
Usage: FROM cloudflare/sandbox:0.0.0-pr-798-8fa75840Version: 📦 Standalone BinaryFor arbitrary Dockerfiles: COPY --from=cloudflare/sandbox:0.0.0-pr-798-8fa75840 /container-server/sandbox /sandbox
ENTRYPOINT ["/sandbox"]Download via GitHub CLI: gh run download 28597333793 -n sandbox-binaryExtract from Docker: docker run --rm cloudflare/sandbox:0.0.0-pr-798-8fa75840 cat /container-server/sandbox > sandbox && chmod +x sandbox |
ghostwriternr
approved these changes
Jul 2, 2026
Member
|
fixed some of the language around validation from the PR desc, rest looks great 🙌 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #790
Container instances created through the Sandbox SDK could not be tagged with custom metadata. The underlying Cloudflare Containers platform supports key-value labels that flow into the analytics pipeline, where they can be used to filter and group usage metrics by dimensions such as tenant, environment, or workload. The SDK exposed sleep and transport options through
SandboxOptionsbut offered no way to set labels, so callers had no first-class path to attribute container usage back to their own entities. This addresses the request in #790.This change adds a
labelsfield toSandboxOptions, letting callers attach labels at the same call site they already use to configure a sandbox. Labels are stored on the sandbox and applied when the container next starts, which keeps them consistent with how the platform consumes them. Changing labels while a container is already running is allowed, but the new values only take effect on the following start.Label validation remains owned by the underlying Cloudflare Containers runtime, keeping Sandbox aligned with the platform label contract.
You can verify the behavior locally by calling
getSandbox()with labels and confirming the container starts as normal. In local development the applied labels are visible on the underlying container throughdocker inspect.Unit tests cover option forwarding, cache deduplication for repeated label configurations, order-independent label comparison, clearing labels with an empty object, Durable Object persistence/restoration, and clone behavior so caller-side mutation does not affect stored labels.
The package README and the
SandboxOptionstype documentation now describe thelabelsoption and its start-time behavior.