Learn about the Containers Beta and upcoming features.
Containers (Beta)
Enhance your Workers with serverless containers
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:
- Resource-intensive applications that require CPU cores running in parallel, large amounts of memory or disk space
- Applications and libraries that require a full filesystem, specific runtime, or Linux-like environment
- Existing applications and tools that have been distributed as container images
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}
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", "containers": [ { "class_name": "MyContainer", "image": "./Dockerfile", "instances": 5, "name": "hello-containers-go" } ], "durable_objects": { "bindings": [ { "class_name": "MyContainer", "name": "MY_CONTAINER" } ] } "migrations": [ { "new_sqlite_classes": [ "MyContainer" ], "tag": "v1" } ],}
name = "container-starter"main = "src/index.js"
[[containers]]class_name = "MyContainer"image = "./Dockerfile"instances = 5name = "hello-containers-go"
[[durable_objects.bindings]]class_name = "MyContainer"name = "MY_CONTAINER"
[[migrations]]new_sqlite_classes = [ "MyContainer" ]tag = "v1"
Deploy your first Container
Build and push an image, call a Container from a Worker, and understand scaling and routing.
Container Examples
See examples of how to use a Container with a Worker, including statelss and stateful routing, regional placement, Workflow and Queue integrations, AI-generated code execution, and short-lived workloads.
Learn more about the commands to develop, build and push images, and deploy containers with Wrangler.
Learn about what limits Containers have and how to work within them.
Connect with other users of Containers on Discord. Ask questions, show what you are building, and discuss the platform with other developers.
Was this helpful?
- Resources
- API
- New to Cloudflare?
- Products
- Sponsorships
- Open Source
- Support
- Help Center
- System Status
- Compliance
- GDPR
- Company
- cloudflare.com
- Our team
- Careers
- 2025 Cloudflare, Inc.
- Privacy Policy
- Terms of Use
- Report Security Issues
- Trademark
-