Docker Community Forums

Share and learn in the Docker community.

MongoDB in Docker Swarm


(Mconstant) #1

Right now we are not in production for docker. I am only testing on a three host proxmox environment with a synology. But I want to start implementing correctly for when we move to production. I used the directions at

and came up with the following way below to deploy the service. We had a horrible storm over the weekend that shutdown power at work. No matter what I could not bring up the service completely. On mongo3 it complained of corrupted data. Then once I just redeployed the service I noticed that since every node went down there were no servers to pass the master role to. Is there a way that if all 3 hosts containing my docker services went down at once that it could bring the replica back up in a normal state? Is there anything I could change in my service lines to make it more resilient? Or is this strictly a mongodb issue where all 3 nodes can’t go down a the same time. No matter what I couldn’t get replication up and going again until I fully redeployed.

docker service create --replicas 1 --detach=false --network mongo_rep --mount type=volume,source=mongodata1_rep,target=/data/db --mount type=volume,source=mongoconfig1_rep,target=/data/configdb --constraint ‘node.hostname == docker01-poc’ --name mongo1 --publish mode=host,target=27017,published=27017 mongo:3.4 mongod --replSet mongorep

docker service create --replicas 1 --detach=false --network mongo_rep --mount type=volume,source=mongodata2_rep,target=/data/db --mount type=volume,source=mongoconfig2_rep,target=/data/configdb --constraint ‘node.hostname == docker02-poc’ --name mongo2 --publish mode=host,target=27017,published=27017 mongo:3.4 mongod --replSet mongorep

docker service create --replicas 1 --detach=false --network mongo_rep --mount type=volume,source=mongodata3_rep,target=/data/db --mount type=volume,source=mongoconfig3_rep,target=/data/configdb --constraint ‘node.hostname == docker03-poc’ --name mongo3 --publish mode=host,target=27017,published=27017 mongo:3.4 mongod --replSet mongorep


(Junius) #2

This looks like a MongoDB issue. MongoDB would support all 3 nodes go down at the same time. Is this reproducible? If this is reproducible, could post the mongodb logs to ask mongodb expertise.