I have a docker-compose file with two services
- React frontend, connects to backend via a localhost address (easy enough)
- ASP.NET CORE backend that connects to a local mongo instance via the docker network bridge
I need this to be able to restart and work every time my Windows PC restarts. The trouble is the gateway address for the docker bridge gateway changes every time my PC restarts. I get the same result every time if I run "docker network inspect bridge", but the address to bind to mongo seems to be a random address from that subnet (vEthernet when running ipconfig). I hope this makes sense, essentially I just need my backend to be able to connect to a local mongo instance without needing additional configuration each time. Is there a way I can configure this in my compose file? This is my current file
version: "3.9"
services:
taxifrontend:
image: tstaxibooker:1.3.3
ports:
- "4012:80"
restart: always
taxibackend:
image: taxibookerbackend:1.1
network_mode: bridge
ports:
- "8000:80"
restart: always
extra_hosts:
- "mongoservice:172.18.240.1"
The address I need to bind to mongoservice seems to constantly change.