mongo-express-docker icon indicating copy to clipboard operation
mongo-express-docker copied to clipboard

MongoError: not master and slaveOk=false

Open cilerler opened this issue 6 years ago • 6 comments

How can I set replicaSet=rs0&slaveOk=true?

Database connected
Admin Database connected
unable to list databases
{ MongoError: not master and slaveOk=false
    at Function.MongoError.create (/node_modules/mongodb-core/lib/error.js:31:11)
    at /node_modules/mongodb-core/lib/connection/pool.js:483:72
    at authenticateStragglers (/node_modules/mongodb-core/lib/connection/pool.js:429:16)
    at Connection.messageHandler (/node_modules/mongodb-core/lib/connection/pool.js:463:5)
    at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:319:22)
    at emitOne (events.js:116:13)
    at Socket.emit (events.js:211:7)
    at addChunk (_stream_readable.js:263:12)
    at readableAddChunk (_stream_readable.js:250:11)
    at Socket.Readable.push (_stream_readable.js:208:10)

cilerler avatar Sep 22 '19 03:09 cilerler

Just posting here because I also am seeing the same issue.

andrew-landsverk-win avatar Feb 06 '20 20:02 andrew-landsverk-win

You should be able to use ME_CONFIG_MONGODB_URL to include extra connection parameters, right?

tianon avatar Feb 07 '20 00:02 tianon

I was not able to, the container fails to start when I try that.

andrew-landsverk-win avatar Feb 07 '20 13:02 andrew-landsverk-win

Ah! I bet we also need to bail in the following block if ME_CONFIG_MONGODB_URL is set (although I haven't checked the mongo-express source to verify the variable precedence, which we should probably do here before we change anything):

https://github.com/mongo-express/mongo-express-docker/blob/4b43fe8a1206434cb32a006cd155dd71462f092f/docker-entrypoint.sh#L22-L27

As a workaround, you should be able to use docker run ... --entrypoint node mongo-express app to bypass that block and just run mongo-express directly.

tianon avatar Feb 07 '20 21:02 tianon

The workaround is slightly more challenging when trying to deploy to a managed Kubernetes provider :)

andrew-landsverk-win avatar Feb 10 '20 13:02 andrew-landsverk-win

In Kubernetes, it's roughly the same, just slightly different names for the same concepts:

apiVersion: v1
kind: Pod
metadata:
  ...
spec:
  containers:
  - name: mongo-express
    image: mongo-express
    command: ["node"]
    args: ["app"]
  restartPolicy: OnFailure

https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/#define-a-command-and-arguments-when-you-create-a-pod

tianon avatar Feb 12 '20 23:02 tianon