Skip to content

Commit

Permalink
fix replica set init for mongodb 6,7
Browse files Browse the repository at this point in the history
  • Loading branch information
morris committed Feb 11, 2024
1 parent d7f084b commit d7b60d7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
14 changes: 4 additions & 10 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@ version: "3"
services:
mongo:
image: mongo:${MONGO_VERSION:-5}
# Override command to start as a single-node replica set;
# required for change streams and transactions.
command:
- /bin/bash
- -c
- |
mongod --port 27017 --bind_ip_all --replSet rs0 &
sleep 3
mongo mongodb://localhost:27017 --eval 'rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "localhost:27017" }] })'
wait $$!
# Start a single-node replica set (required for change streams and transactions)
volumes:
- ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js
command: mongod --replSet rs0
ports:
- "27017:27017"
1 change: 1 addition & 0 deletions mongo-init.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rs.initiate({ _id: "rs0", members: [{ _id: 0, host: "localhost:27017" }] });

0 comments on commit d7b60d7

Please sign in to comment.