I have this docker-compose file:
version: "3"
services:
mongo:
image: bitnami/mongodb:4.4
restart: always
ports:
- 27017:27017
volumes:
- ./db:/bitnami/mongodb
environment:
- MONGODB_REPLICA_SET_MODE=primary
- ALLOW_EMPTY_PASSWORD=yes
which should expose the MongoDB replica set to the outer host via mongodb://localhost:27017
. However I am getting this error message:
Server selection timeout: None of the available servers suitable for criteria Predicate. Topology: { Type: ReplicaSetNoPrimary, Servers: [ { Address: mongo:27017, Type: RsGhost, Average RTT: 10.349064ms, Last Update Time: DateTime(OffsetDateTime { utc_datetime: PrimitiveDateTime { date: Date { year: 2022, ordinal: 197 }, time: Time { hour: 21, minute: 14, second: 38, nanosecond: 986000000 } }, offset: UtcOffset { hours: 0, minutes: 0, seconds: 0 } }), Max Wire Version: 9, Min Wire Version: 0 }, ] }
How do I expose the replica set to the outer host? I've tried adding 127.0.0.1 mongo
to my /etc/hosts
with no luck. I am on macOS 12.4 and Docker Desktop 4.10.1.