[SERVER-34376] Unable to connect to MongoDB Replica set in Docker container Created: 08/Apr/18  Updated: 08/Apr/18  Resolved: 08/Apr/18

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Nairi Harutyunyan Assignee: Unassigned
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2018-04-08 at 3.36.15 PM.png     File docker-compose.yml     File index.js     HTML File mongoErrorLog    
Operating System: ALL
Steps To Reproduce:

1) docker-compose up
2) connecting to any mongo (for example mongo1)
3) db = (new Mongo('localhost:27017')).getDB('test')
4) config = {
"_id": "comments",
"members": [

{ "_id": 0, "host": "node1:27017" }

,

{ "_id": 1, "host": "node2:27017" }

,

{ "_id": 2, "host": "node3:27017" }

]
}

5) rs.initiate(config)
6) node index.js
7) in shell, ( mongo "mongodb://localhost:30001,localhost:30002,localhost:30003/auto?replicaSet=myset" )

Participants:

 Description   

Hi I have mongo replica set with 3 servers, I can not connect to server using mongoose(NodeJS) and Mongo Shell, but with Studio 3T I can connect and change data.

I have tested the same but in my laptop, not in docker container, all works fine, mongoose(NodeJS) and Mongo Shell working fine.

I am using docker compose, I will add all files for reproduce the issue.



 Comments   
Comment by Nairi Harutyunyan [ 08/Apr/18 ]

But currently I don't know how I can access to docker network.

Comment by Nairi Harutyunyan [ 08/Apr/18 ]

please close the issue) because I don't have access

Comment by Nairi Harutyunyan [ 08/Apr/18 ]

nodejs:
build: ./node
links:

  • node1
  • node2
  • node3
    networks:
  • mongoclusternt
    depends_on:
  • node2
Comment by Nairi Harutyunyan [ 08/Apr/18 ]

I have fixed it, actually I need create docker component for nodejs app which will in mongo network.
Sorry for bothering

Generated at Thu Feb 08 04:36:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.