Skip to content

mongorc.js not working in docker #462

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

Closed
yangzhaofeng opened this issue Mar 23, 2021 · 2 comments
Closed

mongorc.js not working in docker #462

yangzhaofeng opened this issue Mar 23, 2021 · 2 comments

Comments

@yangzhaofeng
Copy link

I need the following mongorc.js when starting mongodb

rs.initiate()
rs.secondaryOk()

However, it does not work when I mount it to /etc/mongorc.js or /home/mongodb/.mongorc.js or in /docker-entrypoint-initdb.d/

Where should I mount it? If mongorc.js is disabled, is there any substitution?

@wglambert
Copy link

What do the docker logs show?

Seems like #339 (comment)
The docker-entrypoint-initdb.d scripts run during an initialization period (and only if the database is empty), during which the container is only listening on localhost so trying to initiate a cluster during that period isn't possible as it won't resolve it's own container hostname.

@yangzhaofeng
Copy link
Author

@wglambert Thanks! I put the script in /docker-entrypoint-initdb.d and cleared the databases. Now it works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants