From 696c4c8d92c8fba405ca3e1651a7775f7bb7d62f Mon Sep 17 00:00:00 2001 From: brahimafa Date: Fri, 20 Feb 2026 12:50:22 +0000 Subject: [PATCH] fix: use MONGODB_PORT_NUMBER only for host port mapping, hardcode internal port to 27017 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MONGODB_PORT_NUMBER was used for both the host port and the container port in the MongoDB port mapping, healthcheck, and replica set init. When set to a non-default value, mongod still starts on 27017 (no --port flag), but the healthcheck, replica set init, and port mapping all reference the custom port — causing replica set initialization to fail with "No host described in new configuration maps to this node" and Rocket.Chat to crash with MongoTopologyClosedError / ReplicaSetNoPrimary. Hardcode the internal container port to 27017 (matching mongod's default) and keep MONGODB_PORT_NUMBER for the host mapping only, consistent with how NATS_PORT_NUMBER already works. --- compose.database.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/compose.database.yml b/compose.database.yml index f2073a1..a97136f 100644 --- a/compose.database.yml +++ b/compose.database.yml @@ -57,7 +57,7 @@ services: user: "0" environment: MONGODB_REPLICA_SET_NAME: ${MONGODB_REPLICA_SET_NAME:-rs0} - MONGODB_PORT_NUMBER: ${MONGODB_PORT_NUMBER:-27017} + MONGODB_PORT_NUMBER: "27017" MONGODB_URI: ${MONGODB_URI:-mongodb://mongodb:27017/?directConnection=true} MONGODB_ADVERTISED_HOSTNAME: ${MONGODB_ADVERTISED_HOSTNAME:-mongodb} volumes: @@ -117,7 +117,7 @@ services: test: - CMD - mongosh - - "mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:${MONGODB_PORT_NUMBER:-27017}/?directConnection=true" + - "mongodb://${MONGODB_ADVERTISED_HOSTNAME:-mongodb}:27017/?directConnection=true" - --eval - '"db.adminCommand(''ping'')"' interval: 30s @@ -125,7 +125,7 @@ services: retries: 10 start_period: 30s ports: - - "${MONGODB_BIND_IP:-127.0.0.1}:${MONGODB_PORT_NUMBER:-27017}:${MONGODB_PORT_NUMBER:-27017}" + - "${MONGODB_BIND_IP:-127.0.0.1}:${MONGODB_PORT_NUMBER:-27017}:27017" mongodb-exporter: image: docker.io/percona/mongodb_exporter:${MONGODB_EXPORTER_VERSION:-0.44.0}