0

I tried to set up a replica set with podman rootful containers but MongoDB does not accept my members because it does not recognize itself.

The podman host address is 10.88.0.1, and MongoDB instances are accessible through this address.

I have exposed each MongoDB instance on separate ports 27017, 27027, 27037.

MongoDB starts with mongod --replSet rs0 --auth --config /etc/mongod.conf.

I then try to configure my replica set from the instance listening on port 27017:

rs.initiate({
    "_id" : "rs0",
    "members" : [
        {
            "_id" : 0,
            "host" : "10.88.0.1:27017"
        },
        {
            "_id" : 1,
            "host" : "10.88.0.1:27027"
        },
        {
            "_id" : 2,
            "host" : "10.88.0.1:27037"
        }
    ]
})

Doing this, I get this error:

{
    "ok" : 0,
    "errmsg" : "No host described in new configuration 1 for replica set rs0 maps to this node",
    "code" : 93,
    "codeName" : "InvalidReplicaSetConfig"
}

I was using a mongod.conf that would bind to all IP addresses:

net:
    port: 27017
    bindIpAll: true

I also tried using bindIp: 0.0.0.0 but that didn't change the outcome.

Then I tried to explicitly use the host address which I can use to access my MongoDB instance from outside:

net:
    port: 27017
    bindIp: 10.88.0.1

However, this fails with the error:

Failed to set up listener: SocketException: Cannot assign requested address

How do I set up MongoDB so that my instances can connect to each other and advertise member addresses that clients can use as well?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.