First I pulled the mongoDb image
sudo docker pull mongo
And run the 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
Now I’m trying to connect to it via my docker app
sudo docker run -v ~/Desktop/Template/universal_skillskill -it --link 300b779a63a9:300b779a63a9 alexa
And…I received a message that the connection was 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 application works on the locally installed mongodb, but it cannot communicate with the docker mongoDb container: (What am I doing wrong? Can someone please help me 🙂
1>yamenk..:
You need to connect to, 300b779a63a9:27017
as this is the link name you specified for mongodb.
Like this in my container webapp mongoose.connect('mongodb://:300b779a63a9:27017');