A minimal example that deploys a Cloudflare Container exposing one API to run a Docker image by reference and return its output.
- POST
/run- Body:
{ "image": "<image-ref>" }(e.g.hello-world,alpine:3.20) - Runs:
docker run --rm <image-ref>inside the container - Response JSON:
exit_code— process exit codestdout— container stdoutstderr— container stderrimage— the provided image reference
- Body:
Example:
curl -s https://<your-app-domain>/run \
-H "Content-Type: application/json" \
-d '{"image":"hello-world"}' | jq .- Worker entry:
src/index.ts - Container app:
container_src/app.py(Flask on port8080) - Dockerfile:
Dockerfile
npx wrangler deploy- This runs arbitrary images. For production, consider authentication, allowlists, or network controls.
- The container listens on port
8080and exposesPOST /run.