How to bridge docker container and localhost service?
My service inside docker container cant talk with mongidb server, running on host machine
How to bridge docker container and localhost service?
My service inside docker container cant talk with mongidb server, running on host machine
I too faced this situation. You can use your localhost services in docker.
Steps:
1. In your MongoDb (or any service) conf file, bind that service with machine's ip ( not localhost or 127.0.0.1, it might look like 192.168.x.x) and restart it.
2. In your docker, access service via given machine's ip.
Hope it helps.
As @David Maze pointed out, this is answered here for Mac and Windows machines, and this Github issue contains a pending Linux feature that will make the solution work for Linux too. That answer says use host.docker.internal
instead of localhost
to access your host machine's IP from within your containers.