diff --git a/src/content/docs/containers/index.mdx b/src/content/docs/containers/index.mdx index d17bc8e176423aa..d44f19633e77418 100644 --- a/src/content/docs/containers/index.mdx +++ b/src/content/docs/containers/index.mdx @@ -46,65 +46,63 @@ With Containers you can run: - 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](/workers). Instead of chaining together API calls or writing Kubernetes operators, you just write JavaScript: + -```js -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); -} - -``` - - - - -```json -{ - "name": "container-starter", - "main": "src/index.js", - "containers": [ - { - "class_name": "MyContainer", - "image": "./Dockerfile", - "instances": 5, - } - ], - "durable_objects": { - "bindings": [ - { - "class_name": "MyContainer", - "name": "MY_CONTAINER" - } - ] - }, - "migrations": [ - { - "new_sqlite_classes": [ - "MyContainer" - ], - "tag": "v1" + ```js + 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); + }, + }; + ``` + + + + ```json + { + "name": "container-starter", + "main": "src/index.js", + "compatibility_date": "$today", + "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 +Get started Containers dashboard ---