INTEGRITY Cloudflare Docs

Containers

Enhance your Workers with serverless containers

Available on Workers Paid plan

Run code written in any programming language, built for any runtime, as part of apps built on Workers.

Deploy your container image to Region:Earth without worrying about managing infrastructure - just define your Worker and wrangler deploy.

With Containers you can run:

Container instances are spun up on-demand and controlled by code you write in your Worker. Instead of chaining together API calls or writing Kubernetes operators, you just write JavaScript:

import { Container, getContainer } from "@cloudflare/containers";

export class MyContainer extends Container {
	defaultPort = 4000; // Port the container is listening on
	sleepAfter = "10m"; // Stop the instance if requests not sent for 10 minutes
}

export default {
	async fetch(request, env) {
		const { "session-id": sessionId } = await request.json();
		// Get the container instance for the given session ID
		const containerInstance = getContainer(env.MY_CONTAINER, sessionId);
		// Pass the request to the container instance on its default port
		return containerInstance.fetch(request);
	},
};
{
	"name": "container-starter",
	"main": "src/index.js",
	// Set this to today's date
	"compatibility_date": "2026-08-28",
	"containers": [
		{
			"class_name": "MyContainer",
			"image": "./Dockerfile",
			"max_instances": 5
		}
	],
	"durable_objects": {
		"bindings": [
			{
				"class_name": "MyContainer",
				"name": "MY_CONTAINER"
			}
		]
	},
	"migrations": [
		{
			"new_sqlite_classes": ["MyContainer"],
			"tag": "v1"
		}
	]
}
name = "container-starter"
main = "src/index.js"
# Set this to today's date
compatibility_date = "2026-08-28"

[[containers]]
class_name = "MyContainer"
image = "./Dockerfile"
max_instances = 5

[[durable_objects.bindings]]
class_name = "MyContainer"
name = "MY_CONTAINER"

[[migrations]]
new_sqlite_classes = [ "MyContainer" ]
tag = "v1"

Get started

Containers dashboard


Next steps

Get started

Build and push an image, call a Container from a Worker, and try scaling and routing.

Examples

Stateless and stateful routing, regional placement, Workflow and Queue integrations, AI-generated code execution, and short-lived workloads.

Local development

Run your Worker and container together with wrangler dev or vite dev before you deploy.

Deploy

Ship from your machine or Workers Builds, and confirm the deploy.


More resources

Rollouts

How container instances update after you deploy.

Limits

Instance counts, image size, and other platform limits.

Wrangler

CLI commands for images and containers.

SSH

Connect to running container instances with SSH through Wrangler.

Containers Discord

Ask questions, show what you are building, and talk with other Containers developers.