When running Containers locally on macOS
When running Containers locally on macOS,
fetch()
ing to the Container throws a Container port not found
error even after a while the Container has this.ctx.container!.start()
ed, which is causing startAndWaitForPorts()
to time out.
Is it just me or are there any workaround, or is it a known bug?
I'm using the latest template from Cloudflare.6 Replies
Hrm.... anything abnormal about your docker setup locally?
Also, you're positive that port is being passed in correctly? And does it work in Prod?
And, just to clarify, using this one? - https://github.com/cloudflare/templates/tree/main/containers-template
GitHub
templates/containers-template at main · cloudflare/templates
Templates for Cloudflare Workers. Contribute to cloudflare/templates development by creating an account on GitHub.
(CC @Darrin Deal so we can consolidate feedback)
@Mike Nomitch I was trying to run a frankenphp server with a simple PHP file. It would give me that it couldn’t connect to port 8080. When I build the docker container itself it works fine. I do have the port exposed in the dockerfile.
Also, you're positive that port is being passed in correctly? And does it work in Prod?I've tried the unmodified one from that template, and also tried using
getTcpPort(8080)
then fetch()
on that with a same Dockerfile, which throws the same error. and yes, It does work when rolled out from wrangler deploy
.
Hrm.... anything abnormal about your docker setup locally?I'm using Docker Desktop. I also remember running into issues with container connectivity in the past, so while I don’t fully understand how locally connecting to Container works, it's possible this is just misrouted to somewhere so the container itself can be never reached.
And, just to clarify, using this one? - https://github.com/cloudflare/templates/tree/main/containers-templateYes. I'm using that on
pnpm create cloudflare --template
.
I remember that more logs were coming from Workerd and the Container class, so I will upload once I came back on the home.
If I remind correctly, former was saying warnings about like Durable Objects alarm, and later was saying that port checking has failed.GitHub
templates/containers-template at main · cloudflare/templates
Templates for Cloudflare Workers. Contribute to cloudflare/templates development by creating an account on GitHub.
hmm could you run
docker context list
and share the output of that?
Reinstalling Docker Desktop seems to have resolved the issues for me. It looks like some of the workarounds I applied earlier to fix other problems with Docker Desktop for Mac may have caused this. I can also confirm that Docker @ Colima is working as well.
I was experiencing some issues (
Network connection lost
) also on DevContainer with Docker-outside-of-Docker enabled but seems Workerd hardcodes localhost
as the hostname for connect()
ing within docker ports; making them available through localhost
solved this issue (or use Docker-in-Docker).
Also, running docker ps
and viewing the ports column of the table helped me a lot, optionally with a reverse proxy to docker.sock
.
Thanks for the support!