MongoError: not master and slaveOk=false
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)
Just posting here because I also am seeing the same issue.
You should be able to use ME_CONFIG_MONGODB_URL to include extra connection parameters, right?
I was not able to, the container fails to start when I try that.
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.
The workaround is slightly more challenging when trying to deploy to a managed Kubernetes provider :)
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