DEV Community

Discussion on: Cross Container Communication And Networking In Docker

Collapse
 
clavinjune profile image
Clavin June

How can I get rid of the port, so I can call the service like this

host.docker.internal/service

instead of this host.docker.internal:8000/service

Collapse
 
rinkiyakedad profile image
Arsh Sharma

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

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.