Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-34376

Unable to connect to MongoDB Replica set in Docker container

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None
    • None
    • ALL
    • Hide

      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" )

      Show
      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" )

    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.

      Attachments

        1. docker-compose.yml
          0.7 kB
        2. index.js
          0.4 kB
        3. mongoErrorLog
          2 kB
        4. Screen Shot 2018-04-08 at 3.36.15 PM.png
          Screen Shot 2018-04-08 at 3.36.15 PM.png
          63 kB

        Activity

          People

            Unassigned Unassigned
            nairi.harutyunyan@optym.com Nairi Harutyunyan
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: