sntnupl / devcontainers-mongodb-replica-set-with-docker

Docker based development container template to run a MongoDB replica set cluster in local machine.
https://sntnupl.com/mongodb-replicaset-for-development-using-docker
58 stars 43 forks source link

Couldn't connect to server mongo1:30001 #2

Open manhvd161 opened 3 years ago

manhvd161 commented 3 years ago

I followed the instructions but I always get the result like this. Please help me fix this.

docker-compose up

Creating network "devcontainers-mongodb-replica-set-with-docker_netApplication" with the default driver Creating mongo1 ... done Creating mongo3 ... done Creating mongo2 ... done Creating mongo-setup ... done Attaching to mongo1, mongo3, mongo2, mongo-setup mongo-setup | ** mongo1 mongo-setup | Waiting for startup.. mongo3 exited with code 1 mongo2 exited with code 1 mongo1 exited with code 1 mongo2 exited with code 1 mongo1 exited with code 1 mongo3 exited with code 1 mongo2 exited with code 1 mongo-setup | done mongo-setup | SETUP.sh time now: 15:31:39 mongo-setup | MongoDB shell version v4.2.15 mongo-setup | connecting to: mongodb://mongo1:30001/?compressors=disabled&gssapiServiceName=mongodb mongo-setup | 2021-08-02T15:31:40.675+0000 E QUERY [js] Error: couldn't connect to server mongo1:30001, connection attempt failed: SocketException: Error connecting to mongo1:30001 (172.18.0.2:30001) :: caused by :: Connection refused : mongo-setup | connect@src/mongo/shell/mongo.js:353:17 mongo-setup | @(connect):2:6 mongo-setup | 2021-08-02T15:31:40.677+0000 F - [main] exception: connect failed mongo-setup | 2021-08-02T15:31:40.677+0000 E - [main] exiting with code 1 mongo1 exited with code 1 mongo3 exited with code 1 mongo2 exited with code 1

FabioReact commented 3 years ago

@manhvd161 Same here. Did you find the error? If not, can you provide any help @sntnupl ?

Thank you :)

federicoarcangeli commented 2 years ago

Hi, same issue. Did you manage to resolve ? @sntnupl

Shamanga commented 2 years ago

Hello,

The connection problem here indicates that your mongo container is not up and running. An exit code 1 from a docker container indicates an application error or an incorrect reference to a file that is not present in the container. In my experience, make sure that the volume mounts in the docker-compose file are all correct, and everything should work. I would recommend also checking for instance if your "file.key" is valid, meaning that it's actually a file. As an example, if the file.key is for some reason a "folder" and not a file, then the container would exit because it can't read it.

Hope this helps!