Firstly I pulled mongoDb image
sudo docker pull mongo
and run docker mongodb container:
sudo docker run --name database -d -p 27017:27017 mongo --noauth --bind_ip=0.0.0.0
I see that my docker container works:
300b779a63a9 mongo "docker-entrypoint..." 30 minutes ago Up 30 minutes
and now Im trying to connect to it with my docker app
sudo docker run -v ~/Desktop/Template/universal_skillskill -it --link 300b779a63a9:300b779a63a9 alexa
and... Im getting a message that the connection is refused :(
Uncaught exception: MongoError: failed to connect to server [0.0.0:27017] on first connect [MongoError: connect ECONNREFUSED 0.0.0.0:27017]
MongoError: failed to connect to server [0.0.0:27017] on first connect [MongoError: connect ECONNREFUSED 0.0.0.0:27017]
I checked and my app works with mongodb installed locally but it doesnt communicate with docker mongoDb container :( What am I doing wrong? Could somebody smart help me please :)
You need to connect to 300b779a63a9:27017
as this is the linked name that you gave for the mongodb.
try to connect with the name of your container database
and not with IP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With