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
Main Changes:
1. Added "Required Configuration" section - Shows the complete wrangler.json structure needed for local
development
2. Clarified required fields:
- name field in container config
- instance_type field (typically "standard")
- nodejs_compat compatibility flag
3. Added troubleshooting note - Explains that missing these fields causes "Connection refused" errors
4. Removed misleading phrase - Changed "without additional configuration" to just describing how to run the
commands
The updated documentation now accurately reflects what's actually needed to get containers working locally,
preventing the issues we encountered. This should help other developers avoid the debugging session we just
went through!
Copy file name to clipboardExpand all lines: src/content/docs/containers/local-dev.mdx
+31-1Lines changed: 31 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,11 +5,32 @@ sidebar:
5
5
order: 3
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 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
+
## Required Configuration
14
+
15
+
For local development, your `wrangler.json` or `wrangler.jsonc` file must include specific configuration fields:
16
+
17
+
```json
18
+
{
19
+
"containers": [{
20
+
"name": "your-container-name", // Required for local development
21
+
"class_name": "YourContainerClass", // Your Durable Object class name
22
+
"image": "./path/to/Dockerfile", // Path to your Dockerfile
23
+
"instance_type": "standard", // Required for proper runtime behavior
24
+
"max_instances": 2// Optional, not enforced locally
25
+
}],
26
+
"compatibility_flags": ["nodejs_compat"] // Required when using Container class from @cloudflare/containers
27
+
}
28
+
```
29
+
30
+
:::note
31
+
The `name` and `instance_type` fields are essential for local development. Without them, you may encounter "Connection refused: container port not found" errors even if your container is properly configured.
32
+
:::
33
+
13
34
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.
@@ -46,6 +67,15 @@ you are using in your container code.
46
67
47
68
## Troubleshooting
48
69
70
+
### Container Configuration Errors
71
+
72
+
If you encounter "Connection refused: container port not found" errors during local development, verify that:
73
+
74
+
1. Your container configuration includes a `name` field
75
+
2. Your container configuration includes an `instance_type` field (typically `"standard"`)
76
+
3. You have `nodejs_compat` in your `compatibility_flags` array if using the Container class from `@cloudflare/containers`
77
+
4. Your Dockerfile includes the necessary `EXPOSE` instructions (see below)
78
+
49
79
### Exposing Ports
50
80
51
81
In production, all of your container's ports will be accessible by your Worker, so you do not need to specifically expose ports using the [`EXPOSE` instruction](https://docs.docker.com/reference/dockerfile/#expose) in your Dockerfile.
0 commit comments