This a repository example for the article How to deploy a MongoDB Replica Set using Docker is a walkthrough in how to set up a MongoDB replica set with authentication using docker.
- MongoDB 3.4.1
- Docker for Mac 1.12.5
How to deploy a MongoDB Replica Set using Docker
This a repository example for the article How to deploy a MongoDB Replica Set using Docker is a walkthrough in how to set up a MongoDB replica set with authentication using docker.
Steps for reproduce:
Result: script stack at the point "waiting for mongodb" after recreating mongoNode1 container.
log-file:
Environment:
macOS HighSierra 10.13.1
VirtualBox: Version 5.1.28 r117968 (Qt5.6.2)
Docker: Version 17.09.0-ce-mac35
Docker restart doesn't help.
Here is the error I am stuck with:
_docker exec mongoNode1 bash -c 'mongo < /data/admin/replica.js'
Error response from daemon: Container dcd43fd48802e8351b428933226e972f6f12f4fc1113fd542ef14e7069a15302 is not running_
I tried to start and attach the container but it does not seem to work for me:
docker start -a mongoNode1 2017-07-15T18:47:36.882+0000 I ACCESS [main] permissions on /data/keyfile/mongo-keyfile are too open
$ bash < create-replica-set.sh
···························
·· swtiching >>>> manager1 server ··
···························
Host does not exist: "manager1"
·· creating container >>>> mongoNode1 ··
·· configuring container >>>> mongoNode1 ··
mongo_storage
881e0d7644968562eed5cea3fd17967ef30449593b344e1d0a58008463b37f1c
·· copying files to container >>>> mongoNode1 ··
·· removing container >>>> mongoNode1 ··
mongoNode1
--add-host manager1:192.168.99.100 --add-host worker1:192.168.99.101 --add-host worker2:192.168.99.102
·· recreating container >>>> mongoNode1 ··
eb5d089344730622f749adea5b33d567315de98980eda3081d208e26e9eb895d
Host does not exist: "manager1"
IP == PORT == 27017
waiting for mongodb
<<<<< :27017 is available after 0 seconds
·······························
· CONTAINER manager1 CREATED ··
·······························
MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.2
{
"ok" : 0,
"errmsg" : "No host described in new configuration 1 for replica set rs1 maps to this node",
"code" : 93,
"codeName" : "InvalidReplicaSetConfig"
}
bye
MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.2
admin
2017-02-20T05:38:29.974+0000 E QUERY [thread1] Error: couldn't add user: not master :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1290:15
@(shell):1:1
Error: Authentication failed.
0
2017-02-20T05:38:29.992+0000 E QUERY [thread1] Error: couldn't add user: not master :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1290:15
@(shell):1:1
bye
MongoDB shell version v3.4.2
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.2
2017-02-20T05:38:32.135+0000 E QUERY [thread1] Error: Authentication failed. :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1459:20
@(auth):6:1
@(auth):1:2
exception: login failed
·······························
· REPLICA SET READY TO ADD NODES ··
·······························
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.