-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't connect to Mongo instance after initialization of replica set #249
Comments
Output:
|
This will never get to the #!/bin/bash
# untested, very hacky
# set this script as your "entrypoint" and then command: ["--replSet", "rs0"]
set -e
# Sleep for 30 and then create the replica set
{ sleep 30 && mongo admin --eval 'rs.initiate();' } &
exec docker-entrypoint.sh "$@" The less hacky is to use another process that uses service discovery so that you can ensure that you only initiate on the first server and then to join other nodes to the replica set. In the future, it'd be better to post questions like this in the Docker Community Forums, the Docker Community Slack, or Stack Overflow. |
I tried that but it is not working: even after substituting the curly brackets with the round ones (otherwise reporting a syntax error), after the 30 seconds, I get prompted |
I use
mongo:latest
image. Mydocker-compose.yml
looks like this:In this case, java-app is able to connect to mongo container. But I need to run mongo with --replSet argument to get mongo-connector working, so I've added this argument using
command
option:After that my application is still able to connect to the instance, but mongo-connector doesn't work since replica set is not initiated. To initiate replica set, I've changed
command
:I see the following message in output:
Despite that, the java-app throws an exception because it can't connect to the instance. Also, I can't connect to the mongo from the terminal.
Could you please advise, what's wrong?
The text was updated successfully, but these errors were encountered: