mongo-express: The docker image built from tag v1.0.0 seems to be broken

My clause

I want use mongo-express docker image to connect to Atlas MongoDB. I know that there 3+ Atlas related isues in this repo

My URI looks like ME_CONFIG_MONGODB_URL=“mongodb+srv://2627-db:PASS@MY-CLUSTER.mongodb.net/2627-db?authSource=admin”

There is an advice to edit “config.js” I haven’t tried https://github.com/mongo-express/mongo-express/issues/584#issuecomment-800803419

The “latest” docker that is 1 year old, “1.0.0-alpha.4” still contains this bug.

The Mongo Shell is working with my URI:

$ mongosh mongodb+srv://2627-db:PASS@MY-CLUSTER.mongodb.net/2627-db?authSource=admin
Current Mongosh Log ID: 6320567cf31460f5da1131ae
Connecting to:          mongodb+srv://<credentials>@MY-CLUSTER..mongodb.net/2627-db?authSource=admin&appName=mongosh+1.5.4
Using MongoDB:          4.2.22
Using Mongosh:          1.5.4

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

Atlas atlas-######-shard-0 [primary] 2627-db>

reproduce

git checkout v1.0.0
docker build -t mongo-express:1.0.0 .
$ docker run -it --rm     --name mongo-express -p 8081:8081     -e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance"     -e ME_CONFIG_MONGODB_URL="mongodb+srv://2627-db:PASS@MY-CLUSTER.mongodb.net/2627-db?authSource=admin"     mongo-express:1.0.0
> mongo-express@1.0.0 start
> cross-env NODE_ENV=production node app

Welcome to mongo-express
------------------------


Could not connect to database using connectionString: mongodb+srv://2627-db:PASS@MY-CLUSTER.mongodb.net/2627-db?authSource=admin"
node:fs:599
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, open
    at Object.openSync (node:fs:599:3)
    at Object.readFileSync (node:fs:467:35)
    at transform (/app/node_modules/mongodb/lib/connection_string.js:903:23)
    at setOption (/app/node_modules/mongodb/lib/connection_string.js:442:36)
    at parseOptions (/app/node_modules/mongodb/lib/connection_string.js:297:9)
    at new MongoClient (/app/node_modules/mongodb/lib/mongo_client.js:65:63)
    at MongoClient.connect (/app/node_modules/mongodb/lib/mongo_client.js:233:33)
    at /app/lib/db.js:90:48
    at Array.map (<anonymous>)
    at connect (/app/lib/db.js:85:58) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT'
}

Node.js v18.7.0

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 20 (11 by maintainers)

Most upvoted comments

I think ghcr has a higher rate limit than dockerhub for anonymous downloads. Should be fine to use for now, but once we publish on dockerhub it might be better to switch to the official release.

I might delete my fork someday so it’s probably not good to use in a production environment.

@BlackthornYugen @rtritto your combined efforts now really made a change for me! 👍💯
For our IDP, other ways to access our Atlas MongoDB have limitations I don’t want to solve now.

⛁ You can access your Atlas MongoDB using:

  • MongoDB Compass or MongoDB Shell, run in a shell mongosh "{{ .mongo_uri }}". Please make sure your IP is included in the [IP Access List]
  • [Atlas Cluster control panel]. You got to have access to the Atlas project {{ .atlas_project }}.

@BlackthornYugen big thanks! I confurm that my DB page is working http://0.0.0.0:8081/db/ppserver-2627-db. I create a least priveleged user that has readWrite role only for this one database, it cannot list databases.

@BlackthornYugen one more, since I use the mongo-express docker image already (older version) in the CI, and my helm chart, is the download path ghcr.io/blackthornyugen/mongo-express-docker:v1.0.0 reliable or I gonna hit a download limit?

Just adding ME_CONFIG_MONGODB_SSL=true seems to allow me to connect to atlas and interact with a test database I created, but it looks like I don’t have permission to list databases?

image
Click to show full output
docker run -it --rm -p 8081:8081 -e ME_CONFIG_MONGODB_SSL=true -e "ME_CONFIG_MONGODB_URL=mongodb+srv://jsteelkw:$MONGO_PASSWORD@cluster0.wmg3grn.mongodb.net/?retryWrites=true&w=majority" ghcr.io/blackthornyugen/mongo-express-docker:v1.0.0
No custom config.js found, loading config.default.js
Welcome to mongo-express
------------------------


Mongo Express server listening at http://0.0.0.0:8081
Mongo Express server listening at http://0.0.0.0:8081
Server is open to allow connections from anyone (0.0.0.0)
basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
MongoServerError: user is not allowed to do action [serverStatus] on [admin.]
  at Connection.onMessage (/app/node_modules/mongodb/lib/cmap/connection.js:207:30)
  at MessageStream.<anonymous> (/app/node_modules/mongodb/lib/cmap/connection.js:60:60)
  at MessageStream.emit (node:events:513:28)
  at processIncomingData (/app/node_modules/mongodb/lib/cmap/message_stream.js:132:20)
  at MessageStream._write (/app/node_modules/mongodb/lib/cmap/message_stream.js:33:9)
  at writeOrBuffer (node:internal/streams/writable:392:12)
  at _write (node:internal/streams/writable:333:10)
  at Writable.write (node:internal/streams/writable:337:10)
  at TLSSocket.ondata (node:internal/streams/readable:766:22)
  at TLSSocket.emit (node:events:513:28) {
ok: 0,
code: 8000,
codeName: 'AtlasError',
[Symbol(errorLabels)]: Set(0) {}
}
GET / - - ms - -
GET / - - ms - -
MongoServerError: user is not allowed to do action [serverStatus] on [admin.]
  at Connection.onMessage (/app/node_modules/mongodb/lib/cmap/connection.js:207:30)
  at MessageStream.<anonymous> (/app/node_modules/mongodb/lib/cmap/connection.js:60:60)
  at MessageStream.emit (node:events:513:28)
  at processIncomingData (/app/node_modules/mongodb/lib/cmap/message_stream.js:132:20)
  at MessageStream._write (/app/node_modules/mongodb/lib/cmap/message_stream.js:33:9)
  at writeOrBuffer (node:internal/streams/writable:392:12)
  at _write (node:internal/streams/writable:333:10)
  at Writable.write (node:internal/streams/writable:337:10)
  at TLSSocket.ondata (node:internal/streams/readable:766:22)
  at TLSSocket.emit (node:events:513:28) {
ok: 0,
code: 8000,
codeName: 'AtlasError',
[Symbol(errorLabels)]: Set(0) {}
}
GET /db/test/ - - ms - -
GET /db/test/ 200 1405.020 ms - 9096
GET /public/css/style.css 200 2.931 ms - 1883
GET /public/css/bootstrap.min.css 200 5.864 ms - 121457
GET /public/css/bootstrap-theme.min.css 200 3.368 ms - 23411
GET /public/database-019de86007d9d924e860.min.js 200 3.194 ms - 1518
GET /public/vendor-29c8f8a1a8783a10b310.min.js 200 3.001 ms - 131097
GET /public/img/mongo-express-logo.png 200 0.617 ms - 17847


And still asks for password (but nothing works)

This sounds like a different issue, but if the BASICAUTH_USERNAME is blank it should set useBasicAuth to false and when it is false, it should not use basic auth. Can you open a separate ticket so that we can help troubleshoot?

@denist-huma are you removing the user/password from the connection string before you paste the logs or are they not showing at all?

You can try to add:

ME_CONFIG_MONGODB_SSL="true"
ME_CONFIG_MONGODB_SSLVALIDATE="false"

Good to try for debugging but we would not recommend disabling TLS validation in production. Keep in mind that others with similar issues may find this thread )