Can't connect to mongo docker image with mongoose Can't connect to mongo docker image with mongoose docker docker

Can't connect to mongo docker image with mongoose


I didn't realise I named my database container db instead of mongo, so all I had to do was to switch that name out in my app.js:

mongoose.connect('mongodb://db:27017')  .catch(err => {    console.log(err)  })


I think without mounting volumes in db service , container won't be able to continue its process. it will start for just a second and then it will be terminated.so that's why you are getting an error.