HI Team,
I have created mongo by given the below command
docker run --rm -d -p 27017:27017 --name mongodb mongo
I have build image node app from given below docker file
FROM node:alpine
WORKDIR /app
COPY package.json .
RUN npm install
COPY . .
EXPOSE 8000
CMD [ "npm", "run", "start" ]
du the container from given below command
docker run --name todo-app -p 8000:8000 todoapp
But still i am not able to connect my docker to node
it is saying
Unable to connect to MongoDB
MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017
at Connection.openUri (/app/node_modules/mongoose/lib/connection.js:825:32)
at /app/node_modules/mongoose/lib/index.js:414:10
at promiseOrCallback (/app/node_modules/mongoose/lib/helpers/promiseOrCallback.js:11:14)
at Mongoose._promiseOrCallback (/app/node_modules/mongoose/lib/index.js:1288:10)
at Mongoose.connect (/app/node_modules/mongoose/lib/index.js:413:20)
at Object.<anonymous> (/app/src/index.js:48:10)
at Module._compile (node:internal/modules/cjs/loader:1233:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1287:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) { '127.0.0.1:27017' => [ServerDescription] },
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: null,
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined
}