DEV Community

Discussion on: Cross Container Communication And Networking In Docker

Collapse
rinkiyakedad profile image
Arsh Sharma Author

I think the example I used might have been a bit unclear. The service you'd be using would have a port for it on the localhost. For example let's say your backend is running at localhost:3000. Then you can use host.docker.internal:3000 in the code present in your container.

What I mean to say is that the serivce would be running at a port on localhost so you would have to necessarily specify the port while using host.docker.internal. The /serivce I used might be a bit confusing cause it is the service it self which is actually running on localhost:8000 and not on localhost:8000/service.

Collapse
clavinjune profile image
Clavin June • Edited

I understood, but what I meant is how can we get rid the port

Thread Thread
rinkiyakedad profile image
Arsh Sharma Author

The default port is 80. If you can get your service to run on that then you would simply be able to use host.docker.internal. Otherwise I don't think so you can get by without specifying the port since your service operates on a specific port itself.