---
title: Easily connect Containers and Sandboxes to Workers
description: Use outbound Workers to give containers access to KV, R2, and other Workers bindings.
image: https://edgetunnel-b2h.pages.dev/changelog-preview.png
---

> Documentation Index  
> Fetch the complete documentation index at: https://edgetunnel-b2h.pages.dev/changelog/llms.txt  
> Use this file to discover all available pages before exploring further. 

[Skip to content](#%5Ftop) 

# Changelog

New updates and improvements at Cloudflare.

[ Subscribe to RSS ](https://edgetunnel-b2h.pages.dev/changelog/rss/index.xml) [ View RSS feeds ](https://edgetunnel-b2h.pages.dev/fundamentals/new-features/available-rss-feeds/) 

![hero image](https://edgetunnel-b2h.pages.dev/_astro/hero.CVYJHPAd_26AMqX.svg) 

[ ← Back to all posts ](https://edgetunnel-b2h.pages.dev/changelog/) 

## Easily connect Containers and Sandboxes to Workers

Mar 26, 2026 

[ Containers ](https://edgetunnel-b2h.pages.dev/containers/) 

[Containers](https://edgetunnel-b2h.pages.dev/containers/) and [Sandboxes](https://edgetunnel-b2h.pages.dev/sandbox/) now support connecting directly to Workers over HTTP. This allows you to call Workers functions and [bindings](https://edgetunnel-b2h.pages.dev/workers/runtime-apis/bindings/), like [KV](https://edgetunnel-b2h.pages.dev/kv) or [R2](https://edgetunnel-b2h.pages.dev/r2/), from within the container at specific hostnames.

#### Run Worker code

Define an `outbound` handler to capture any HTTP request or use `outboundByHost` to capture requests to individual hostnames and IPs.

**JavaScript**

```js
export class MyApp extends Sandbox {}


MyApp.outbound = async (request, env, ctx) => {
  // you can run arbitrary functions defined in your Worker on any HTTP request
  return await someWorkersFunction(request.body);
};


MyApp.outboundByHost = {
  "my.worker": async (request, env, ctx) => {
    return await anotherFunction(request.body);
  },
};
```

In this example, requests from the container to `http://my.worker` will run the function defined within `outboundByHost`, and any other HTTP requests will run the `outbound` handler. These handlers run entirely inside the Workers runtime, outside of the container sandbox.

#### Access Workers bindings

Each handler has access to `env`, so it can call any binding set in [Wrangler config](https://edgetunnel-b2h.pages.dev/workers/wrangler/configuration/#bindings). Code inside the container makes a standard HTTP request to that hostname and the outbound Worker translates it into a binding call.

**JavaScript**

```js
export class MyApp extends Sandbox {}


MyApp.outboundByHost = {
  "my.kv": async (request, env, ctx) => {
    const key = new URL(request.url).pathname.slice(1);
    const value = await env.KV.get(key);
    return new Response(value ?? "", { status: value ? 200 : 404 });
  },
  "my.r2": async (request, env, ctx) => {
    const key = new URL(request.url).pathname.slice(1);
    const object = await env.BUCKET.get(key);
    return new Response(object?.body ?? "", { status: object ? 200 : 404 });
  },
};
```

Now, from inside the container sandbox, `curl http://my.kv/some-key` will access [Workers KV](https://edgetunnel-b2h.pages.dev/kv) and `curl http://my.r2/some-object` will access [R2](https://edgetunnel-b2h.pages.dev/r2/).

#### Access Durable Object state

Use `ctx.containerId` to reference the container's automatically provisioned [Durable Object](https://edgetunnel-b2h.pages.dev/durable-objects).

**JavaScript**

```js
export class MyContainer extends Container {}


MyContainer.outboundByHost = {
  "get-state.do": async (request, env, ctx) => {
    const id = env.MY_CONTAINER.idFromString(ctx.containerId);
    const stub = env.MY_CONTAINER.get(id);
    return stub.getStateForKey(request.body);
  },
};
```

This provides an easy way to associate state with any container instance, and includes a [built-in SQLite database](https://edgetunnel-b2h.pages.dev/durable-objects/get-started/#2-write-a-durable-object-class-using-sql-api).

#### Get Started Today

Upgrade to `@cloudflare/containers` version 0.2.0 or later, or `@cloudflare/sandbox` version 0.8.0 or later to use outbound Workers.

Refer to [Containers outbound traffic](https://edgetunnel-b2h.pages.dev/containers/platform-details/outbound-traffic/) and [Sandboxes outbound traffic](https://edgetunnel-b2h.pages.dev/sandbox/guides/outbound-traffic/) for more details and examples.

```json
{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://edgetunnel-b2h.pages.dev/changelog/post/2026-03-26-outbound-workers/#page","headline":"Easily connect Containers and Sandboxes to Workers · Changelog","description":"Use outbound Workers to give containers access to KV, R2, and other Workers bindings.","url":"https://edgetunnel-b2h.pages.dev/changelog/post/2026-03-26-outbound-workers/","inLanguage":"en","image":"https://edgetunnel-b2h.pages.dev/changelog-preview.png","dateModified":"2026-03-26","datePublished":"2026-03-26","publisher":{"@type":"Organization","name":"Cloudflare","url":"https://www.cloudflare.com/"},"isPartOf":{"@type":"WebSite","@id":"https://edgetunnel-b2h.pages.dev/#website","name":"Cloudflare Docs","url":"https://edgetunnel-b2h.pages.dev/"}}
```
