I have a flask application which is running as docker container. Flask application uses local mongodb. This docker container is not able to connect to local mongodb.
I have tried following option :
set --network="host"
in docker run ...
command
set MONGO_URI = "mongodb://host-ip-address:27017/model-service-sample"
,
set MONGO_URI = "mongodb://container-gateway-ip-address:27017/model-service-sample"
None of the above options worked.
Can anyone please suggest a way to accomplish this?
For MacOS you should use:
host.docker.internal
or gateway.docker.internal
for connecting from a container to a service on the host.
refer : https://docs.docker.com/docker-for-mac/networking/#/known-limitations-use-cases-and-workarounds
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.