I've been searching for an answer to this using this question here as the basis since last night, however I get this error that I can't solve:
Step 4/4 : RUN mongorestore /trapsdump/ --host mongo:27017
---> Running in be3d84e526ab2018-05-18T10:52:50.575+0000 Failed: error connecting to db server: no reachable servers
I'm using Docker-compose for this. I've used Docker a few times before building containers, but am no expert, however I think everything is correctly configured. I'm using this to seed the database as we have a 'demo' collection stored on mLab.
This is my Dockerfile:
FROM node:9.11.1
RUN mkdir /src
RUN npm install nodemon -g
WORKDIR /src
ADD ./package.json /src/package.json
RUN npm install
COPY . .
EXPOSE 3000
CMD npm start
This is the docker-compose.yml:
version: "2"
services:
mongo:
container_name: mongo
image: mongo
volumes:
- ./data:/data/db
ports:
- "27017:27017"
- "11990:11990"
mongo-seed:
build: ./mongo-seed
links:
- mongo
app:
container_name: traps
restart: always
build: .
ports:
- "3000:3000"
links:
- mongo
And this is the mongo-seed/Dockerfile:
FROM mongo
RUN mongodump --uri=mongodb://xxxxxxxxxxxxx@xxxxxxxxxxxx:xxxxx/xxxxxx -o trapsdump
RUN mongorestore /trapsdump/ --host mongo:27017
If pulls down the collection from mLab and dumps it locally.
So if anyone can point out where i'm going wrong, that would be excellent.