Created
February 25, 2023 19:13
-
-
Save LeonFedotov/0992dd67f7faaffa7c8b105e6a1e7f95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker network create mongoCluster | |
docker run -d --rm -p 27017:27017 --name mongo1 --network mongoCluster mongo:latest mongod --replSet myReplicaSet --bind_ip localhost,mongo1 | |
docker run -d --rm -p 27018:27017 --name mongo2 --network mongoCluster mongo:latest mongod --replSet myReplicaSet --bind_ip localhost,mongo2 | |
docker run -d --rm -p 27019:27017 --name mongo3 --network mongoCluster mongo:latest mongod --replSet myReplicaSet --bind_ip localhost,mongo3 | |
docker exec -it mongo1 mongosh --eval "rs.initiate({ | |
_id: \"myReplicaSet\", | |
members: [ | |
{_id: 0, host: \"mongo1\"}, | |
{_id: 1, host: \"mongo2\"}, | |
{_id: 2, host: \"mongo3\"} | |
] | |
})" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment