Skip to content

Instantly share code, notes, and snippets.

@AlaeddineMessadi
Created March 3, 2022 18:22
Show Gist options
  • Save AlaeddineMessadi/9317c235925b574a50cf40da94fe706c to your computer and use it in GitHub Desktop.
Save AlaeddineMessadi/9317c235925b574a50cf40da94fe706c to your computer and use it in GitHub Desktop.
mongodb replication set
version: "3"
services:
mongo1:
hostname: mongo1
container_name: localmongo1
image: mongo:4.0-xenial
expose:
- 27017
ports:
- 27011:27017
restart: always
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
mongo2:
hostname: mongo2
container_name: localmongo2
image: mongo:4.0-xenial
expose:
- 27017
ports:
- 27012:27017
restart: always
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
mongo3:
hostname: mongo3
container_name: localmongo3
image: mongo:4.0-xenial
expose:
- 27017
ports:
- 27013:27017
restart: always
entrypoint: [ "/usr/bin/mongod", "--bind_ip_all", "--replSet", "rs0" ]
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: root
@AlaeddineMessadi
Copy link
Author

AlaeddineMessadi commented Mar 3, 2022

# Create a keyFile
$ openssl rand -base64 756 > ./keyFile
$ chmod 400 ./keyFile

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