Last active
November 28, 2019 16:43
-
-
Save timjonesdev/7a34a2aa92fc64d145d12fa0d8d596d4 to your computer and use it in GitHub Desktop.
A MongoDB Dockerfile which enables a single-node replicaset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM mongo:4.0 | |
# files used to initialize the database | |
COPY ./init-db.d/ /docker-entrypoint-initdb.d | |
# add this command to a js file in the init directory | |
# formatted on newlines for better readability | |
RUN echo "rs.initiate( | |
{ | |
_id: 'rs0', | |
members: [ | |
{ | |
_id: 0, | |
host: 'localhost:27017' | |
} | |
] | |
}); | |
rs.slaveOk();" > /docker-entrypoint-initdb.d/replica-init.js | |
# the important bits are calling out the replicaset, | |
# binding the IP to 0.0.0.0, | |
# and setting the oplogSize to something manageable | |
# these settings are for local development only, | |
# and would likely be significantly different in a production deployment | |
CMD ["--replSet", "rs0", "--bind_ip", "0.0.0.0", "--oplogSize", "100"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment