Linked Questions

Popular Questions

Use keyFile in mongo5

Asked by At

I'm trying to set up Mongo5 with docker-compose and it's failing for me. I'm using pymongo 3.13.0 and motor 2.5 in the application that attaches to this Mongo

My Dockerfile:

FROM mongo:5.0
RUN mkdir /keys
COPY src/setup/replica.key /keys/replica.key
RUN chown 999:999 /keys/replica.key
RUN chmod 400 /keys/replica.key

The mongo section of my docker-compose:

mongo:
    build:
      args:
        REGISTRY_PATH: ${REGISTRY_PATH}
        IMAGE_TAG: ${IMAGE_TAG:-latest}
      context: .
      dockerfile: build/mongo/Dockerfile
    image: ${REGISTRY_PATH}mongo:${IMAGE_TAG:-latest}
    environment:
      MONGO_INITDB_DATABASE: <database>
      MONGO_INITDB_ROOT_USERNAME: admin
      MONGO_INITDB_ROOT_PASSWORD: <password>
      MONGO_USERNAME: <user>
      MONGO_PASSWORD: <password>
      MONGO_HOSTNAME: mongo
      BRANCH_NAME: ${BRANCH_NAME:-dev}
    command: "--auth --oplogSize 32 --quiet --replSet -nameReplicaSet --keyFile /keys/replica.key --logpath /dev/stdout"
    ports:
      - 27017:27017
    volumes:
      - ${MINIKUBE_REPO_PATH}/src/setup/replica.key:/keys/replica.key:ro
      - mongodb:/data/db
      - ${MINIKUBE_REPO_PATH}/src/setup/mongo-initdb.d:/docker-entrypoint-initdb.d/

After docker-compose up -d mongo

I get the error pymongo.errors.OperationFailure: The $changeStream stage is only supported on replica sets, full error: {'ok': 0.0, 'errmsg': 'The $changeStream stage is only supported on replica sets', 'code': 40573, 'codeName': 'Location40573'}

However, it looks to me like I'm configuring a replica set, so in my opinion this error shouldn't show up.

What am I missing here?

Related Questions