You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/docs/containers/container-package.mdx
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ sidebar:
6
6
---
7
7
8
8
When writing code that interacts with a container instance, you can either use a
9
-
Durable Object directly or use the [`Container` module](https://github.com/cloudflare/containers)
9
+
[Durable Object directly](/containers/platform-details/durable-object-methods) or use the [`Container` module](https://github.com/cloudflare/containers)
10
10
importable from [`@cloudflare/containers`](https://www.npmjs.com/package/@cloudflare/containers).
Finally, you can also set build-time environment variables that are only available when building the container image via the `image_vars` field in the Wrangler configuration.
Copy file name to clipboardExpand all lines: src/content/docs/containers/get-started.mdx
+8-6Lines changed: 8 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ This example Worker should give you a sense for simple Container use, and provid
17
17
### Ensure Docker is running locally
18
18
19
19
In this guide, we will build and push a container image alongside your Worker code. By default, this process uses
20
-
[Docker](https://www.docker.com/) to do so. You must have Docker running locally when you run `wrangler deploy`. For most people, the best way to install Docker is to follow the [docs for installing Docker Desktop](https://docs.docker.com/desktop/).
20
+
[Docker](https://www.docker.com/) to do so. You must have Docker running locally when you run `wrangler deploy`. For most people, the best way to install Docker is to follow the [docs for installing Docker Desktop](https://docs.docker.com/desktop/). Other tools like [Colima](https://github.com/abiosoft/colima) may also work.
21
21
22
22
You can check that Docker is running properly by running the `docker info` command in your terminal. If Docker is running, the command will succeed. If Docker is not running,
23
23
the `docker info` command will hang or return an error including the message "Cannot connect to the Docker daemon".
@@ -29,9 +29,11 @@ the `docker info` command will hang or return an error including the message "Ca
29
29
30
30
Run the following command to create and deploy a new Worker with a container, from the starter template:
When you want to deploy a code change to either the Worker or Container code, you can run the following command using [Wrangler CLI](/workers/wrangler/):
37
39
@@ -40,7 +42,7 @@ When you want to deploy a code change to either the Worker or Container code, yo
40
42
When you run `wrangler deploy`, the following things happen:
41
43
42
44
- Wrangler builds your container image using Docker.
43
-
- Wrangler pushes your image to a [Container Image Registry](/containers/image-management/) that is automatically
45
+
- Wrangler pushes your image to a [Container Image Registry](/containers/platform-details/image-management/) that is automatically
44
46
integrated with your Cloudflare account.
45
47
- Wrangler deploys your Worker, and configures Cloudflare's network to be ready to spawn instances of your container
46
48
@@ -67,7 +69,7 @@ And see images deployed to the Cloudflare Registry with the following command:
67
69
68
70
Now, open the URL for your Worker. It should look something like `https://hello-containers.YOUR_ACCOUNT_NAME.workers.dev`.
69
71
70
-
If you make requests to the paths `/container/1` or `/container/2`, these requests are routed to specific containers.
72
+
If you make requests to the paths `/container/1` or `/container/2`, your Worker routes requests to specific containers.
71
73
Each different path after "/container/" routes to a unique container.
72
74
73
75
If you make requests to `/lb`, you will load balanace requests to one of 3 containers chosen at random.
Copy file name to clipboardExpand all lines: src/content/docs/containers/index.mdx
+48-39Lines changed: 48 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,66 +45,72 @@ With Containers you can run:
45
45
- Applications and libraries that require a full filesystem, specific runtime, or Linux-like environment
46
46
- Existing applications and tools that have been distributed as container images
47
47
48
-
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:
48
+
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:
Copy file name to clipboardExpand all lines: src/content/docs/containers/local-dev.mdx
+10-5Lines changed: 10 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,30 +5,35 @@ sidebar:
5
5
order: 6
6
6
---
7
7
8
-
You can run both your container and your Worker locally, without additional configuration, by running [`npx wrangler dev`](/workers/wrangler/commands/#dev) (or `vite dev` for Vite projects using the [Cloudflare Vite plugin](/workers/vite-plugin/)) in your project's directory.
8
+
You can run both your container and your Worker locally by simply running [`npx wrangler dev`](/workers/wrangler/commands/#dev) (or `vite dev` for Vite projects using the [Cloudflare Vite plugin](/workers/vite-plugin/)) in your project's directory.
9
9
10
10
To develop Container-enabled Workers locally, you will need to first ensure that a
11
11
Docker compatible CLI tool and Engine are installed. For instance, you could use [Docker Desktop](https://docs.docker.com/desktop/) or [Colima](https://github.com/abiosoft/colima).
12
12
13
13
When you start a dev session, your container image will be built or downloaded. If your
the `image` attribute to a local path, the image will be built using the local Dockerfile.
16
-
If the `image` attribute is set to a URL, the image will be pulled from the associated registry.
16
+
If the `image` attribute is set to a URL, the image will be pulled from the Cloudflare registry.
17
+
18
+
:::note
19
+
Currently, the Cloudflare Vite-plugin does not support registry links in local development, unlike `wrangler dev`.
20
+
As a workaround, you can create a minimal Dockerfile that uses `FROM <registry-link>`. Make sure to `EXPOSE` a port for local dev as well.
21
+
:::
17
22
18
23
Container instances will be launched locally when your Worker code calls to create
19
-
a new container. This may happen when calling `.get()` on a `Container` instance or
20
-
by calling `start()` if `manualStart` is set to `true`. Requests will then automatically be routed to the correct locally-running container.
24
+
a new container. Requests will then automatically be routed to the correct locally-running container.
21
25
22
26
When the dev session ends, all associated container instances should be stopped, but
23
27
local images are not removed, so that they can be reused in subsequent builds.
24
28
25
29
:::note
26
30
If your Worker app creates many container instances, your local machine may not be able to run as many containers concurrently as is possible when you deploy to Cloudflare.
27
31
32
+
Also, `max_instances` configuration option does not apply during local development.
33
+
28
34
Additionally, if you regularly rebuild containers locally, you may want to clear
29
35
out old container images (using `docker image prune` or similar) to reduce disk used.
30
36
31
-
Also note that the `max_instances` configuration option is only enforced when running in production on Cloudflare's network. This limit does not apply during local development, so you may run more instances than specified.
0 commit comments