0

To make a service running in a container interact with another one running locally at let's say localhost:3000, we can use host.docker.internal:3000 in the container code to make the required connection. But is there a way I can get rid of the port while using host.docker.internal so that it automatically routes to localhost:3000? That is, I just use host.docker.internal in my code instead of host.docker.internal:3000?

Clarification: I am not asing how to connect to localhost from inside the container. What I am asking is how to route host.docker.internal to the correct port without specifying it explicitly like: host.docker.internal:3000.

Arsh Sharma
  • 1,129
  • 1
  • 7
  • 10
  • 1
    The default HTTP port is 80, and you'll need some sort of router or proxy if you need port 80 to forward to port 3000. Using environment variables to configure external service locations is probably a good practice; it shouldn't make a difference whether or not there's a port number. – David Maze Dec 29 '20 at 13:23
  • How can I route the port using environment variables? – Arsh Sharma Dec 30 '20 at 08:48

0 Answers0