# Replica Set with Percona MongoDB on Docker

**URL:** <https://forums.percona.com/t/replica-set-with-percona-mongodb-on-docker/7237>\
**Category:** Percona Server for MongoDB\
**Created:** [October 14, 2019, 2:06am UTC](https://forums.percona.com/t/replica-set-with-percona-mongodb-on-docker/7237 "2019-10-14T02:06:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpedrero](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@rpedrero](https://forums.percona.com/u/rpedrero)\
**Post date:** [October 14, 2019, 2:06am UTC](https://forums.percona.com/t/replica-set-with-percona-mongodb-on-docker/7237/1 "2019-10-14T02:06:59Z")

</div>

Hi all!

It’s possible to run a cluster of mongodb in replica set with docker edition?

If yes, can anyone help me?

Many thanks

---

<div class="post-metadata">

**Author:** ![Akira\_Kurogane](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/akira_kurogane/32/1280_2.png) [@Akira\_Kurogane](https://forums.percona.com/u/Akira_Kurogane)\
**Post date:** [October 14, 2019, 6:20am UTC](https://forums.percona.com/t/replica-set-with-percona-mongodb-on-docker/7237/2 "2019-10-14T06:20:28Z")

</div>

Hi. There isn’t any docker solution for a whole cluster from MongoDB (or Percona). There are single-container images, but those are stand-alones.

This next part is conjecture, but I think the crowd that liked Docker moved on Kubernetes instead over the last couple of years, so I wouldn’t expect there to be any movement with Docker + MongoDB coming in the future.

Kubernetes on the other hand is adjusting towards having the operators that will work for distributed databases.

Percona’s Kubernetes Operator for MongoDB already supports a (non-sharded) replicaset of 3+ nodes. MongoDB currently support a Kubernetes image that installs Ops Manager agents, but that is Ops Manager (paid product) that controls the mongod nodes, not Kubernetes.

Sharded cluster topology support in Percona’s Kubernetes Operator for MongoDB is coming. [URL][[K8SPSMDB-121] Add support for multiple shards - Percona JIRA](https://jira.percona.com/browse/CLOUD-329%5B/URL%5D)

---

<div class="post-metadata">

**Author:** ![rpedrero](https://avatars.discourse-cdn.com/v4/letter/r/57b2e6/32.png) [@rpedrero](https://forums.percona.com/u/rpedrero)\
**Post date:** [October 14, 2019, 9:37am UTC](https://forums.percona.com/t/replica-set-with-percona-mongodb-on-docker/7237/3 "2019-10-14T09:37:19Z")

</div>

I’m trying to execute mongodb with this config:

services:  
mongo:  
image: percona/percona-server-mongodb  
command: --dbpath=/data/db -profile=2 -slowms=200 -rateLimit=100 --keyFile /data/keyfile --replSet rs0 --bind\_ip localhost,10.1.0.15

restart: always  
ports:

- “27017:27017”  
environment:  
MONGO\_INITDB\_ROOT\_USERNAME: xxxx  
MONGO\_INITDB\_ROOT\_PASSWORD: xxxx  
volumes:
- ./mongodb/:/data/db
- ./security.keyfile:/data/keyfile

keyfile with correct permissions, etc.

When I try to start only with bindip = localhost, mongodb starts correctly.

But when I add another node, I have the next error:

mongo\_1 | + exec mongod --dbpath=/data/db -profile=2 -slowms=200 -rateLimit=100 --keyFile /data/keyfile --replSet rs0 --bind\_ip localhost,10.1.0.14 --auth --sslMode disabled  
mongo\_1 | 2019-10-14T15:06:59.603+0000 I STORAGE [main] Max cache overflow file size custom option: 0  
mongo\_1 | 2019-10-14T15:06:59.606+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’  
mongo\_1 | 2019-10-14T15:06:59.622+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=mongodb-2  
mongo\_1 | 2019-10-14T15:06:59.623+0000 I CONTROL [initandlisten] db version v4.0.12-6  
mongo\_1 | 2019-10-14T15:06:59.623+0000 I CONTROL [initandlisten] git version: da989eba899f9163ee9e3591bda7084d5217d4ed  
mongo\_1 | 2019-10-14T15:06:59.624+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017  
mongo\_1 | 2019-10-14T15:06:59.624+0000 I CONTROL [initandlisten] allocator: tcmalloc  
mongo\_1 | 2019-10-14T15:06:59.625+0000 I CONTROL [initandlisten] modules: none  
mongo\_1 | 2019-10-14T15:06:59.625+0000 I CONTROL [initandlisten] build environment:  
mongo\_1 | 2019-10-14T15:06:59.625+0000 I CONTROL [initandlisten] distarch: x86\_64  
mongo\_1 | 2019-10-14T15:06:59.625+0000 I CONTROL [initandlisten] target\_arch: x86\_64  
mongo\_1 | 2019-10-14T15:06:59.625+0000 I CONTROL [initandlisten] options: { net: { bindIp: “localhost,10.1.0.14”, ssl: { mode: “disabled” } }, operationProfiling: { mode: “all”, rateLimit: 100, slowOpThresholdMs: 200 }, replication: { replSet: “rs0” }, security: { authorization: “enabled”, keyFile: “/data/keyfile” }, storage: { dbPath: “/data/db” } }  
mongo\_1 | 2019-10-14T15:06:59.626+0000 E STORAGE [initandlisten] Failed to set up listener: SocketException: Cannot assign requested address  
mongo\_1 | 2019-10-14T15:06:59.626+0000 I CONTROL [initandlisten] now exiting  
mongo\_1 | 2019-10-14T15:06:59.626+0000 I CONTROL [initandlisten] shutting down with code:48
