Container Echo
Echo a message via Cloudflare Containers backed by a Durable Object
Echo a message through Cloudflare Containers. A Durable Object subclass (EchoContainer) extends @cloudflare/containers's Container and proxies requests to a Node HTTP server running in the container image.
API Reference
POST /echo
Send text/plain or JSON ({ "message": "..." } or { "echo": "..." }).
Body must be non-empty and at most 10,000 characters.
Example Request
curl -X POST "https://your-worker.workers.dev/echo" \
-H "Content-Type: application/json" \
-d '{"message":"hello"}'Success Response
{
"echo": "hello",
"port": 8080
}Error Codes
400- Invalid or empty body (INVALID_BODY)502- Container or proxy failure (ECHO_ERROR)
Use Cases
- Learn Containers + Durable Object lifecycle with a minimal API
- Prototype Worker-to-container request forwarding
- Validate Dockerfile-backed images on Cloudflare
- Compare Containers vs pure Workers for Node-style servers
Limitations
- Docker must be available for
wrangler dev/ deploy image builds - Message body capped at 10,000 characters
- Demo exposes a single echo path; not a general proxy
- Container instances are limited (
max_instances: 2in wrangler)
Deployment
Deploy
Wrangler builds ./Dockerfile, registers the EchoContainer Durable Object, and binds it as ECHO.
Test your deployment
curl -X POST "https://your-worker.workers.dev/echo" \
-H "Content-Type: text/plain" \
-d "hello"Local Development
Docker must be running for container image builds.
cd apps/experiments/container-echo
npm install
npm run devcurl -X POST "http://localhost:8787/echo" \
-H "Content-Type: application/json" \
-d '{"message":"hello"}'Unit tests mock the Durable Object binding so Docker is not required for npm run test.
Configuration
wrangler.json declares:
- Container
EchoContainerfrom./Dockerfile(port 8080) - Durable Object binding
ECHO→EchoContainer - Migration
v1withnew_sqlite_classes: ["EchoContainer"]
Cloudflare Features Used
- Workers - Edge compute runtime
- Containers - Dockerfile-backed runtime on Cloudflare
- Durable Objects - Container lifecycle via
@cloudflare/containers