Jump to content

MongoDB with single replica (docker compose)

Recommended Posts

Hey everyone,

I'm Kevin, and I could use some help with Unraid and my Docker Compose file. Everything works smoothly when I'm using Docker Desktop locally, but as soon as I try it on Unraid, I can't connect to MongoDB.

Here's my Docker Compose file:

version: '3'
    image: mongo:7.0.4
    command: ['--replSet', 'rs0', '--bind_ip_all', '--port', '27017']
      - 27017:27017
      test: echo "try { rs.status() } catch (err) { rs.initiate({_id:'rs0',members:[{_id:0,host:'mongo1:27017'}]}) }" | mongosh --port 27017 --quiet
      interval: 5s
      timeout: 30s
      start_period: 0s
      start_interval: 1s
      retries: 30
      - 'mongo1_data:/data/db'
      - 'mongo1_config:/data/configdb'
    image: mongo-express
    restart: always
      - 8081:8081
      ME_CONFIG_MONGODB_URL: mongodb://mongo1:27017/


I've tried a bunch of things like hardcoding the local IP to the port, changing ports, and defining networks, but none of them seem to solve the issue. What's really odd is that when I attempt to access port 27017 through a web browser, I get a message saying: "It looks like you are trying to access MongoDB over HTTP on the native driver port."


So, it appears that something is listening, but when I try to connect with MongoDB Compass or Mongo Express, it just doesn't work. This problem seems to be related to Unraid because it works perfectly fine locally.

Any ideas or suggestions would be greatly appreciated!

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...