docker-compose, mongodb, single node replica set

Viewed 206

I'm trying to configure a mongodb single node replica set using docker compose for connecting with elasticsearch using monstache in development. Using the documentation docs. I have the following docker compose file:

  mongo:
    image: mongo
    volumes:
      - ./data/mongo:/data/db
    environment:
      MONGO_INITDB_ROOT_USERNAME: ${MONGO_USERNAME}
      MONGO_INITDB_ROOT_PASSWORD: ${MONGO_PASSWORD}
      MONGO_REPLICA_SET_NAME: rs0
    restart: unless-stopped
    entrypoint: >
      /bin/sh -c '
      echo "rs.initiate()" > /docker-entrypoint-initdb.d/init-replicaset.js;
      /usr/local/bin/docker-entrypoint.sh mongod --replSet rs0 --bind_ip localhost --noauth
      '

But I keep getting errors. In this case:

{"t":{"$date":"2021-10-25T21:19:12.174Z"},"s":"F",  "c":"CONTROL",  "id":20574,   "ctx":"-","msg":"Error during global initialization","attr":{"error":{"code":2,"codeName":"BadValue","errmsg":"auth is not allowed when noauth is specified"}}}

Is there someone more familiar with Mongodb and replica sets that can help me get this running? I feel like I'm close to a working solution.

0 Answers
Related