Last active
August 29, 2015 14:07
-
-
Save bamthomas/dd7e109e488d56e04142 to your computer and use it in GitHub Desktop.
docker replicaset node
This file contains hidden or 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 ubuntu:latest | |
RUN locale-gen fr_FR.UTF-8 | |
ENV LANG fr_FR.UTF-8 | |
ENV LANGUAGE fr:en | |
ENV LC_ALL fr_FR.UTF-8 | |
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 | |
RUN echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | tee /etc/apt/sources.list.d/10gen.list | |
RUN apt-get update && apt-get install -y mongodb | |
RUN mkdir -p /var/lib/mongodb | |
EXPOSE 27017 | |
ENTRYPOINT usr/bin/mongod --dbpath /var/lib/mongodb |
This file contains hidden or 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
docker run -p 27017:27017 --name mongo1 -d mongo --replSet my_rs | |
docker run -p 27018:27017 --name mongo2 -d mongo --replSet my_rs | |
docker run -p 27019:27017 --name mongoa -d mongo --replSet my_rs --journal=false | |
IP1=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' mongo1) | |
IP2=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' mongo2) | |
IPa=$(docker inspect -f '{{ .NetworkSettings.IPAddress }}' mongoa) | |
mongo --eval "printjson( | |
rs.initiate({ | |
_id : 'my_rs', | |
members : [ | |
{ _id : 0, host : '$IP1:27017' }, | |
{ _id : 1, host : '$IP2:27017' }, | |
{ _id : 2, host : '$IPa:27017', arbiterOnly: true} | |
] | |
}))" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment