Skip to content

Instantly share code, notes, and snippets.

@garycrawford
Created July 9, 2015 13:00
Show Gist options
  • Save garycrawford/0a45f820e146917d231d to your computer and use it in GitHub Desktop.
Save garycrawford/0a45f820e146917d231d to your computer and use it in GitHub Desktop.
MongoDB Replica Set docker-compose.yml
primary:
image: mongo:3.0
volumes:
- ./p:/data
ports:
- "27017:27017"
# Our current version of docker-compose doesn't allow extra_hosts which would be the best way
# to add curcular dependency container links in this case. We cant upgrade docker-compose
# without upgrading docker to 1.7, and we can't do that without upgrading the kernel on our
# CentOS VM's. As such we are using the hostname hask below to allow primary and secondary
# MongoDB nodes to communicate with each other.
# extra_hosts:
# - secondary1
# - secondary2
hostname: "192.168.59.103"
command: mongod --smallfiles --replSet bigdaddy
secondary1:
image: mongo:3.0
volumes:
- ./s1:/data
ports:
- "27018:27017"
# See note above on extra_hosts
# extra_hosts:
# - primary
# - secondary2
hostname: "192.168.59.103"
command: mongod --smallfiles --replSet bigdaddy
secondary2:
image: mongo:3.0
volumes:
- ./s2:/data
ports:
- "27019:27017"
# See note above on extra_hosts
# extra_hosts:
# - primary
# - secondary1
hostname: "192.168.59.103"
command: mongod --smallfiles --replSet bigdaddy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment