A Cloudflare Container runs your container image in a full Linux environment on Cloudflare's network, alongside a Worker. The Worker handles incoming HTTP requests and can handle raw TCP connections in public beta. The Container provides the runtime, binaries, and languages your application needs. Together, they let you run Linux workloads without managing the underlying infrastructure.
Run Linux workloads alongside your Worker.
A Worker runs code in an isolated JavaScript environment. A Container runs your image in a full Linux environment, so you can bring custom runtimes and binaries when your application needs them. Each Container instance runs inside its own virtual machine, which isolates it from other workloads. The Worker receives inbound HTTP requests and routes them to the Container, so the Container is not exposed directly to end users.
A request reaches the Worker, which routes it to a Container running inside its own virtual machine. The Worker remains in front of the Container while the Container serves the request.
For more information, refer to Lifecycle of a Container.
For TCP applications, Spectrum can invoke a Worker's connect() handler. The Worker can then forward the raw socket to a process in the Container. This supports protocols such as bidirectional gRPC. Refer to Bidirectional gRPC with Workers and Containers.
Route every request through your Worker.
The request begins at your Worker, which uses the Durable Object layer to identify and reach a Container. This layer coordinates routing and lifecycle behavior, allowing the Container to continue serving requests while it runs. A Container can start when it receives its first request, so the first request may take longer to complete.
A request flows from the client to the Worker and then to a Container. The Worker and Durable Object layer coordinate routing and lifecycle behavior before the Container serves the request. If the Container is not already running, it starts as part of that process.
For more information, refer to Lifecycle of a Container.
Start on demand, then stop when idle.
A Container starts when your application needs it, so the first request can take longer while its environment starts. Once running, it serves requests until it becomes inactive; after an inactivity period, it can stop and release its running resources. When another request arrives, the Container can start again.
The lifecycle begins with a stopped Container and a request that starts it. The Container then serves requests, becomes inactive, and stops again until another request arrives.
For more information, refer to Lifecycle of a Container and Pricing.
Choose resources for your workload.
Container instance sizes let you match resources to your workload. You can choose a predefined size or configure a custom one, with larger sizes providing more CPU, memory, and disk. When choosing a size, consider the resources your application needs and refer to Limits and instance types for the available options and constraints.
For more information, refer to Pricing.
Start instances in eligible locations.
When a Durable Object starts a Container, Cloudflare selects a suitable location based on request routing, available capacity, and image availability. The Container and its Durable Object may run in different locations.
With the durable_object scheduling policy, the Durable Object's jurisdiction determines eligible Container locations. Your application can start multiple Container instances when it needs more capacity.
For more information, refer to Placement.
Keep durable data outside the local disk.
Treat a Container's local disk as temporary working space, because data on it can be lost when the Container stops or restarts. For data that must persist, use Durable Object storage or Cloudflare storage bindings such as KV, R2, and D1. Configured outbound handlers let the Container access these bindings and external services without requiring an SDK inside the Container.
A Container can reach Cloudflare storage and external services through configured connections. Its local disk is temporary, while data in durable storage persists beyond the Container's lifecycle.
For more information, refer to Connect to Workers and bindings and Outbound traffic.
When you are ready to build, start with a deployed Container or explore the available guides.
Get started
Guides
Bidirectional gRPC
- Lifecycle of a Container: the deep dive on deployment, routing, and shutdown.
- Placement: where instances run and how Durable Object jurisdiction affects placement.
- Connect to Workers and bindings: reaching Cloudflare resources from a container.
- Bidirectional gRPC with Workers and Containers: routing raw TCP streams to a containerized gRPC server.
- Limits and instance types and Pricing: sizes, account limits, and billing.
- Rollouts: how new versions roll out across instances.