Connecting to MongoDB from a Docker container
I am trying to connect to Mongo using mongodb://host.docker.internal:27017/database
Is Mongo running on port 27017 ?
If yes, what else may be the problem? I tried using 'localhost' as well, but the above connection string works on Windows locally.
Thanks,
David
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Feodor Fitsner on Jun 05, 2020 @ 11:53 PM
Hi David,
Mongo is not started by default. Start it with:
Support Staff 2 Posted by Feodor Fitsner on Jun 06, 2020 @ 12:45 AM
It's bound to
127.0.0.1:27017
, so it couldn't be accessed from a container unless configured to listen on all IPs: https://ci.appveyor.com/project/FeodorFitsner/simple-console#L21I'm changing the config and starting Mongo with this simple PS snippet:
3 Posted by david on Jun 06, 2020 @ 01:05 AM
still no luck for me, but I got mongo to work in docker which is even better because I can control the version of docker. Thanks for your help.