Skip to content

Instantly share code, notes, and snippets.

@luksrn
Last active May 7, 2019 19:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luksrn/882a2da8ed23f0997bfcaf2882722ae5 to your computer and use it in GitHub Desktop.
Save luksrn/882a2da8ed23f0997bfcaf2882722ae5 to your computer and use it in GitHub Desktop.
version: '3'
services:
rabbitmq:
image: rabbitmq:management
container_name: rabbitmq
networks:
- desenv-local
ports:
- "5672:5672"
- "15672:15672"
redis:
image: redis
container_name: redis
ports:
- "6379:6379"
networks:
- desenv-local
mongodb:
hostname: mongodb1
image: mongo
container_name: mongodb1
networks:
- desenv-local
ports:
- "27017:27017"
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
mongodb2:
hostname: mongodb2
image: mongo
container_name: mongodb2
networks:
- desenv-local
ports:
- "27018:27017"
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
mongodb3:
hostname: mongodb3
image: mongo
container_name: mongodb3
networks:
- desenv-local
ports:
- "27019:27017"
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
dns-proxy:
image: defreitas/dns-proxy-server
hostname: dns.magedo
ports:
- 5380:5380
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "/etc/resolv.conf:/etc/resolv.conf"
environment:
MG_LOG_LEVEL: ERROR
networks:
desenv-local:
driver: bridge
@luksrn
Copy link
Author

luksrn commented Dec 12, 2018

Initialize the replica set:
sudo docker exec -it mongodb1 mongo
And run:

config = {
	"_id" : "rs0",
	"members" : [
		{
			"_id" : 0,
			"host" : "mongodb1:27017"
		},
		{
			"_id" : 1,
			"host" : "mongodb2:27017"
		},
		{
			"_id" : 2,
			"host" : "mongodb3:27017"
		}
	]
};


rs.initiate(config);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment