Skip to content

Commit bdf44d6

Browse files
dario-piotrowiczemily-shenkodster28
authored andcommitted
Add troubleshooting section with exposing-ports sub-section to containers local-dev docs (#23495)
* Add troubleshooting section with exposing-ports sub-section to containers local-dev docs --------- Co-authored-by: emily-shen <[email protected]> Co-authored-by: Kody Jackson <[email protected]>
1 parent 08fdb57 commit bdf44d6

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/content/docs/containers/local-dev.mdx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,27 @@ You may prefer to set up your own code watchers and reloading mechanisms, or mou
4444
into the local container images to sync code changes. This can be done, but there is no built-in
4545
mechanism for doing so in Wrangler, and best-practices will depend on the languages and frameworks
4646
you are using in your container code.
47+
48+
## Troubleshooting
49+
50+
### Exposing Ports
51+
52+
In production, all of your container's ports will be accessible by your Worker,
53+
so you do not need to specifically expose ports using the [`EXPOSE` instruction](https://docs.docker.com/reference/dockerfile/#expose) in your Dockerfile.
54+
55+
But for local development you will need to declare any ports you need to access in your Dockerfile with the EXPOSE instruction; for example: `EXPOSE 4000`, if you will be accessing port 4000.
56+
57+
If you have not exposed any ports, you will see the following error in local development:
58+
59+
```txt
60+
The container "MyContainer" does not expose any ports. In your Dockerfile, please expose any ports you intend to connect to.
61+
```
62+
63+
And if you try to connect to any port that you have not exposed in your `Dockerfile` you will see the following error:
64+
65+
```txt
66+
connect(): Connection refused: container port not found. Make sure you exposed the port in your container definition.
67+
```
68+
69+
You may also see this while the container is starting up and no ports are available yet. You should retry until the ports become available.
70+
This retry logic should be handled for you if you are using the [containers package](https://github.com/cloudflare/containers/tree/main/src).

0 commit comments

Comments
 (0)