- Run docker compose to start up all mongo nodes
- Connect to
db_1
node using mongo -p 37017
, got to have mongo client installed locally. You could also docker exec
.
- Run
mongo-replicaset-instruction.js
in the mongo shell, this configure the replica set.
- Run your docker supplying
--networks
arguments to join the above network
- Before running your application on docker on step 4, run
echo "1.1.1.1 db_backup" >> /etc/hosts
to point it to non existant destination.
- Run your app in the docker container you started on step 4.
- All goes well you should see these messages
23:23:31.799 [error] Mongo.Protocol (#PID<0.643.0>) failed to connect: ** (Mongo.Error) tcp connect: unknown POSIX error - :timeout
23:23:31.800 [error] GenServer #PID<0.643.0> terminating
** (stop) exited in: :gen_server.call(#PID<0.643.0>, {:checkout, #Reference<0.3803180105.3846438913.42441>, true, 5000}, 5000)
** (EXIT) time out
Last message: []
State: Mongo.Protocol
Did you solve this problem. I am facing the same issue.