fix: decouple MONGODB_PORT_NUMBER from internal container port#25
Open
BrahimAfa wants to merge 1 commit intoRocketChat:mainfrom
Open
fix: decouple MONGODB_PORT_NUMBER from internal container port#25BrahimAfa wants to merge 1 commit intoRocketChat:mainfrom
BrahimAfa wants to merge 1 commit intoRocketChat:mainfrom
Conversation
…ernal port to 27017 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.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Setting
MONGODB_PORT_NUMBERto a non-default value (e.g.49335) in.envbreaks MongoDB replica set initialization and causes Rocket.Chat to crash on startup.Root cause:
MONGODB_PORT_NUMBERis used for both the host port and the container port in three places:${MONGODB_PORT_NUMBER}:${MONGODB_PORT_NUMBER}— maps host:container to the same valuemongodb:${MONGODB_PORT_NUMBER}via the Docker networkmongodb:${MONGODB_PORT_NUMBER}However,
mongodis started without a--portflag (line 99), so it always listens on port 27017 inside the container. WhenMONGODB_PORT_NUMBERis anything other than27017, all three references point to a port nothing is listening on.Steps to reproduce
MONGODB_PORT_NUMBER=49335(or any non-default value) in.envdocker compose -f compose.database.yml -f compose.yml up -dmongodb-init-containerlogs:rocketchatlogs:Fix
Hardcode the internal container port to
27017(matchingmongod's default) and keepMONGODB_PORT_NUMBERonly for the host-side mapping. This is consistent with howNATS_PORT_NUMBERalready works in this project: