In the docker compose file i added api server as a service and mongodb is installed in my local pc. But when the api run in docker container it could not connect with 127.0.0.1:27017.
Here is the docker-compose file.
networks:
test_network:
name: test_network
driver: bridge
services:
api:
container_name: api
build: ./api
ports:
- "3031:3031"
networks:
- test_network
Why this problem is happening and how i can resolve this problem ?
It happens because the IP address 127.0.0.1:27107 refers to the container itself.
You have to address the above port, but the host ip as I explained here.