Skip to content

Commit d2321e2

Browse files
committed
Initial contianer docs setup
1 parent 518e8f8 commit d2321e2

File tree

11 files changed

+368
-0
lines changed

11 files changed

+368
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
pcx_content_type: navigation
3+
title: Containers API Reference
4+
external_link: /api/resources/containers
5+
sidebar:
6+
order: 8
7+
---
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
type: overview
3+
hideChildren: false
4+
pcx_content_type: navigation
5+
title: Examples
6+
sidebar:
7+
order: 10
8+
group:
9+
hideIndex: true
10+
---
11+
12+
import { GlossaryTooltip, ListExamples } from "~/components";
13+
14+
Explore the following <GlossaryTooltip term="code example">examples</GlossaryTooltip> for Containers.
15+
16+
<ListExamples directory="containers/examples/" />
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
---
2+
pcx_content_type: get-started
3+
title: Getting started
4+
sidebar:
5+
order: 2
6+
---
7+
8+
In this guide, you will get started with Cloudflare Images and make your first API request.
9+
10+
## Prerequisites
11+
12+
Before you make your first API request, ensure that you have a Cloudflare Account ID and an API token.
13+
14+
Refer to [Find zone and account IDs](/fundamentals/setup/find-account-and-zone-ids/) for help locating your Account ID and [Create an API token](/fundamentals/api/get-started/create-token/) to learn how to create an access your API token.
15+
16+
## Make your first API request
17+
18+
```bash
19+
curl --request POST \
20+
--url https://api.cloudflare.com/client/v4/accounts/<ACCOUNT_ID>/images/v1 \
21+
--header 'Authorization: Bearer <API_TOKEN>' \
22+
--header 'Content-Type: multipart/form-data' \
23+
--form file=@./<YOUR_IMAGE.IMG>
24+
```
25+
26+
## Enable transformations on your zone
27+
28+
You can dynamically optimize images that are stored outside of Cloudflare Images and deliver them using [transformation URLs](/images/transform-images/transform-via-url/).
29+
30+
Cloudflare will automatically cache every transformed image on our global network so that you store only the original image at your origin.
31+
32+
To enable transformations on your zone:
33+
34+
1. Log in to the [Cloudflare dashboard](https://dash.cloudflare.com/login) and select your account.
35+
2. Go to **Images** > **Transformations**.
36+
3. Go to the specific zone where you want to enable transformations.
37+
4. Select **Enable for zone**. This will allow you to optimize and deliver remote images.
38+
39+
:::note
40+
41+
With **Resize images from any origin** unchecked, only the initial URL passed will be checked. Any redirect returned will be followed, including if it leaves the zone, and the resulting image will be transformed.
42+
43+
:::
44+
45+
:::note
46+
47+
If you are using transformations in a Worker, you need to include the appropriate logic in your Worker code to prevent resizing images from any origin. Unchecking this option in the dash does not apply to transformation requests coming from Cloudflare Workers.
48+
49+
:::
Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
---
2+
title: Containers
3+
order: 0
4+
type: overview
5+
pcx_content_type: overview
6+
sidebar:
7+
order: 1
8+
head:
9+
- tag: title
10+
content: Overview
11+
---
12+
13+
import {
14+
CardGrid,
15+
Description,
16+
Feature,
17+
LinkTitleCard,
18+
Plan,
19+
RelatedProduct,
20+
TabItem,
21+
Tabs,
22+
} from "~/components";
23+
24+
<Description>
25+
26+
Enhance your Workers with serverless containerized applications
27+
28+
</Description>
29+
30+
<Plan type="workers-paid" />
31+
32+
With Containers, you can build applications that integrate Workers with a serverless container runtime.
33+
Deploy your image to Region:Earth without worrying about managing infrastructure, just define your
34+
Worker and `wrangler deploy`.
35+
36+
This lets you run:
37+
38+
- Resouce-intensive applications that use more memory, CPU, or disk than Workers allow
39+
- Applications and libraries that require a specific runtime or Linux-like environment
40+
- Existing applications or tools that are distributed as images
41+
42+
<Tabs>
43+
<TabItem label="Container Code">
44+
```js
45+
// get a container-enabled durable object and call a method on in
46+
async fetch(request, env) {
47+
const { "session-id": sessionId } = await request.json();
48+
const id = env.CODE_EXECUTOR.idFromName(sessionId);
49+
return env.CODE_EXECUTOR.get(id).fetch(request);
50+
}
51+
52+
// define a durable object to run alongside your container
53+
54+
export class CodeExecutor extends DurableObject {
55+
// boot the container with the DO
56+
constructor(ctx, env) {
57+
super(ctx, env);
58+
ctx.blockConcurrencyWhile(
59+
startAndWaitForPort(ctx.container, CONTAINER_PORT)
60+
);
61+
}
62+
63+
// proxy requests to the container
64+
async fetch(request) {
65+
return await proxyFetch(this.ctx.container, request, CONTAINER_PORT);
66+
}
67+
68+
}
69+
70+
````
71+
72+
</TabItem>
73+
<TabItem label="Container Config">
74+
75+
```json
76+
{
77+
"name": "my-container-worker",
78+
"main": "src/index.js",
79+
"compatibility_date": "2025-03-20",
80+
"containers": [
81+
{
82+
"image": "./Dockerfile",
83+
"sleep_after": "30s",
84+
"instance_type": "basic",
85+
"binding": "CODE_EXECUTOR",
86+
"class_name": "CodeExecutor"
87+
}
88+
]
89+
}
90+
````
91+
92+
</TabItem>
93+
94+
</Tabs>
95+
96+
See the [getting started guide](/containers/get-started/guide/) to start building with Containers.
97+
98+
---
99+
100+
## Next Steps
101+
102+
<Feature header="Deploy your first Container" href="/containers/get-started/" cta="Deploy a Container">
103+
104+
Build and push an image, call the Container from your Worker, understand scaling and routing.
105+
106+
</Feature>
107+
108+
<Feature header="Container Examples" href="/containers/build/rules-of-workflows/" cta="See Examples">
109+
110+
See examples of how to use a Container with a Worker, including statelss and stateful routing,
111+
regional placement, Workflow and Queue integrations, AI-generated code execution, and short-lived workloads.
112+
113+
</Feature>
114+
115+
---
116+
117+
## More resources
118+
119+
<CardGrid>
120+
121+
<LinkTitleCard
122+
title="Pricing"
123+
href="/containers/platform/pricing/"
124+
icon="seti:shell"
125+
>
126+
Learn about Containers pricing and how to estimate your usage.
127+
</LinkTitleCard>
128+
129+
<LinkTitleCard
130+
title="Limits"
131+
href="/containers/platform/limits/"
132+
icon="document"
133+
>
134+
Learn about what limits Containers have and how to work within them.
135+
</LinkTitleCard>
136+
137+
{/* TODO: better icon/link */}
138+
139+
<LinkTitleCard
140+
title="Wrangler"
141+
href="/workers/wrangler/commands/#containers"
142+
icon="document"
143+
>
144+
Learn more about the commands to develop, build and push images, and deploy
145+
containers with Wrangler.
146+
</LinkTitleCard>
147+
148+
<LinkTitleCard
149+
title="Closed Beta Discord"
150+
href="https://discord.cloudflare.com"
151+
icon="discord"
152+
>
153+
Connect with other users in the closed beta on Discord. Ask questions, show
154+
what you are building, and discuss the platform with other developers.
155+
</LinkTitleCard>
156+
157+
</CardGrid>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
pcx_content_type: navigation
3+
title: Platform
4+
sidebar:
5+
order: 8
6+
group:
7+
hideIndex: true
8+
---
9+
10+
import { DirectoryListing } from "~/components";
11+
12+
<DirectoryListing />
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
pcx_content_type: concept
3+
title: Limits
4+
sidebar:
5+
order: 4
6+
---
7+
8+
import { Render } from "~/components";
9+
10+
Containers limits are detailed below.
11+
12+
| Feature | Workers Paid |
13+
| -------------------------------------- | ------------ |
14+
| Container Count | 10 [^1] |
15+
| Max Concurrent Instances per Container | 20 [^1] |
16+
| Max Concurrent Instances per Account | 100 |
17+
| Images in Registry | X |
18+
| Image Size | X |
19+
20+
[^1]: This limit will be raised as we continue the private beta.
21+
22+
<Render file="limits_increase" product="workers" />
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
---
2+
pcx_content_type: reference
3+
title: Pricing
4+
sidebar:
5+
order: 6
6+
---
7+
8+
By default, all users are on the Images Free plan. The Free plan includes access to the transformations feature, which lets you optimize images stored outside of Images, like in R2.
9+
10+
The Paid plan allows transformations, as well as access to storage in Images.
11+
12+
Pricing is dependent on which features you use. The table below shows which metrics are used for each use case.
13+
14+
| Use case | Metrics | Availability |
15+
| ----------------------------------------------------- | ------------------------------- | ------------------- |
16+
| Optimize images stored outside of Images | Images Transformed | Free and Paid plans |
17+
| Optimized images that are stored in Cloudflare Images | Images Stored, Images Delivered | Only Paid plans |
18+
19+
## Images Free
20+
21+
On the Free plan, you can request up to 5,000 unique transformations each month for free.
22+
23+
Once you exceed 5,000 unique transformations:
24+
25+
- Existing transformations in cache will continue to be served as expected.
26+
- New transformations will return a `9422` error. If your source image is from the same domain where the transformation is served, then you can use the [`onerror` parameter](/images/transform-images/transform-via-url/#onerror) to redirect to the original image.
27+
- You will not be charged for exceeding the limits in the Free plan.
28+
29+
To request more than 5,000 unique transformations each month, you can purchase an Images Paid plan.
30+
31+
## Images Paid
32+
33+
When you purchase an Images Paid plan, you can choose your own storage or add storage in Images.
34+
35+
| Metric | Pricing |
36+
| ------------------ | ------------------------------------------------------------------------------------------ |
37+
| Images Transformed | First 5,000 unique transformations included + $0.50 / 1,000 unique transformations / month |
38+
| Images Stored | $5 / 100,000 images stored / month |
39+
| Images Delivered | $1 / 100,000 images delivered / month |
40+
41+
If you optimize an image stored outside of Images, then you will be billed only for Images Transformed.
42+
43+
Alternatively, Images Stored and Images Delivered apply only to images that are stored in your Images bucket. When you optimize an image that is stored in Images, then this counts toward Images Delivered — not Images Transformed.
44+
45+
## Metrics
46+
47+
### Images Transformed
48+
49+
A unique transformation is a request to transform an original image based on a set of [supported parameters](/images/transform-images/transform-via-url/#options). This metric is used only when optimizing images that are stored outside of Images.
50+
51+
For example, if you transform `thumbnail.jpg` as 100x100, then this counts as 1 unique transformation. If you transform the same `thumbnail.jpg` as 200x200, then this counts as a separate unique transformation.
52+
53+
You are billed for the number of unique transformations that are counted during each billing period.
54+
55+
Unique transformations are counted over a 30-day sliding window. For example, if you request `width=100/thumbnail.jpg` on June 30, then this counts once for that billing period. If you request the same transformation on July 1, then this will not count as a billable request, since the same transformation was already requested within the last 30 days.
56+
57+
The `format` parameter counts as only 1 billable transformation, even if multiple copies of an image are served. In other words, if `width=100,format=auto/thumbnail.jpg` is served to some users as AVIF and to others as WebP, then this counts as 1 unique transformation instead of 2.
58+
59+
#### Example
60+
61+
A retail website has 1,000 original product images that get served in 5 different sizes each month. This results in 5,000 unique transformations — or a cost of $2.50 per month.
62+
63+
### Images Stored
64+
65+
Storage in Images is available only with an Images Paid plan. You can purchase storage in increments of $5 for every 100,000 images stored per month.
66+
67+
You can create predefined variants to specify how an image should be resized, such as `thumbnail` as 100x100 and `hero` as 1600x500.
68+
69+
Only uploaded images count toward Images Stored; defining variants will not impact your storage limit.
70+
71+
### Images Delivered
72+
73+
For images that are stored in Images, you will incur $1 for every 100,000 images delivered per month. This metric does not include transformed images that are stored in remote sources.
74+
75+
Every image requested by the browser counts as 1 billable request.
76+
77+
#### Example
78+
79+
A retail website has a product page that uses Images to serve 10 images. If the page was visited 10,000 times this month, then this results in 100,000 images delivered — or $1.00 in billable usage.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
pcx_content_type: navigation
3+
title: Wrangler commands
4+
external_link: /workers/wrangler/commands/#containers
5+
sidebar:
6+
order: 80
7+
---
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Containers
2+
3+
product:
4+
title: Containers
5+
url: /containers/
6+
group: Developer platform
7+
8+
meta:
9+
title: Containers docs
10+
description: Enhance your Workers with serverless containerized applications
11+
author: "@cloudflare"
12+
13+
resources:
14+
community: https://community.cloudflare.com/c/developers/containers
15+
dashboard_link: https://dash.cloudflare.com/?to=/:account/workers/containers
16+
# learning_center: https://www.cloudflare.com/learning/...
17+
# discord: https://discord.com/channels/...

src/icons/containers.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)