Coder Social home page Coder Social logo

mongo-express-docker's Introduction

mongo-express

npm version npm GitHub stars Known Vulnerabilities Build Status

A web-based MongoDB admin interface written with Node.js, Express, and Bootstrap 5

Features

  • Connect to multiple databases
  • View/add/delete databases
  • View/add/rename/delete collections
  • View/add/update/delete documents
  • Preview audio/video/image assets inline in the collection view
  • Nested and/or large objects are collapsible for easy overview
  • Async on-demand loading of big document properties (>100KB default) to keep collection view fast
  • GridFS support - add/get/delete incredibly large files
  • Use BSON data types in documents
  • Mobile / Responsive - Bootstrap 5 works passably on small screens when you're in a bind
  • Connect and authenticate to individual databases
  • Authenticate as admin to view all databases
  • Database blacklist/whitelist
  • Custom CA/TLS/SSL and CA validation disabling
  • Supports replica sets

Screenshots

Home Page Database View Collection View Editing A Document

These screenshots are from version 0.30.40 View the album for more screenshots: (server status, database views, etc..) https://imgur.com/a/9vHsF

Development

To test or develop with the latest version (master branch) you can install using this git repository:

npm i mongo-express@github:mongo-express/mongo-express
OR
yarn add mongo-express@github:mongo-express/mongo-express
OR
pnpm add mongo-express@github:mongo-express/mongo-express

Copy config.default.js to config.js and edit the default property to fit your local environment

Run the development build using:

npm run start-dev
OR
yarn start-dev
OR
pnpm run start-dev

Usage (npm / yarn / pnpm / CLI)

mongo-express requires Node.js v4 or higher.

To install:

npm i -g mongo-express
OR
yarn add -g mongo-express
OR
pnpm add -g mongo-express

Or if you want to install a non-global copy:

npm i mongo-express
OR
yarn add mongo-express
OR
pnpm add mongo-express

By default config.default.js is used where the basic access authentication is admin:pass. This is obviously not safe, and there are warnings in the console.

To configure:

Copy YOUR_PATH/node_modules/mongo-express/config.default.js into a new file called YOUR_PATH/node_modules/mongo-express/config.js.

Note: YOUR_PATH will depend on your current OS user and system configuration. You can see it in the output text shown after executing npm install.

Fill in your MongoDB connection details and any other options you want to change in config.js.

You will also need to create a .env file with the variables for your cookie and session secrets, these are just default values

ME_CONFIG_SITE_COOKIESECRET: 'cookiesecret',
ME_CONFIG_SITE_SESSIONSECRET: 'sessionsecret',

To run:

cd YOUR_PATH/node_modules/mongo-express/ && node app.js

or if you installed it globally, you can immediately start mongo-express like this:

mongo-express

You can add some configuration options. Example:

node app.js --url mongodb://127.0.0.1:27017

or:

mongo-express --URL mongodb://127.0.0.1:27017

Configuration options:

Option Short Description
--version -V output the version number
--url <url> -U <url> connection string url (<url> example: mongodb://127.0.0.1:27017)
--admin -a enable authentication as admin
--port <port> -p <port> listen on specified port (default <port> is 8081)
--help -h display help for command options

Usage (Express 4 middleware)

To mount as Express 4 middleware (see node_modules/mongo-express/app.js):

var mongo_express = require('mongo-express/lib/middleware')
var mongo_express_config = require('./mongo_express_config')

app.use('/mongo_express', mongo_express(mongo_express_config))

Usage (Docker)

Make sure you have a running MongoDB container on a Docker network (--network some-network below) with --name or --network-alias set to mongo. Alternatively, set the connection string ME_CONFIG_MONGODB_URL to the proper connection for your MongoDB container on your Docker network.

Use the Docker Hub image:

$ docker run -it --rm -p 8081:8081 --network some-network mongo-express

Build from source:

Build an image from the project directory, then run the image.

$ docker build -t mongo-express .
$ docker run -it --rm -p 8081:8081 --network some-network mongo-express

You can use the following environment variables to modify the container's configuration:

Name Default Description
ME_CONFIG_MONGODB_URL mongodb://admin:pass@localhost:27017/db?ssl=false
ME_CONFIG_MONGODB_ENABLE_ADMIN false Enable administrator access. Send strings: "true" or "false".
ME_CONFIG_MONGODB_AUTH_USERNAME admin Database username (only needed if ENABLE_ADMIN is "false").
ME_CONFIG_MONGODB_AUTH_PASSWORD pass Database password (only needed if ENABLE_ADMIN is "false").
ME_CONFIG_MONGODB_ALLOW_DISK_USE false Remove the limit of 100 MB of RAM on each aggregation pipeline stage.
ME_CONFIG_MONGODB_TLS false Use TLS client certificate
ME_CONFIG_MONGODB_TLS_ALLOW_CERTS true Validate mongod server certificate against CA
ME_CONFIG_MONGODB_TLS_CA_FILE `` CA certificate File
ME_CONFIG_MONGODB_TLS_CERT_FILE `` TLS client certificate file
ME_CONFIG_MONGODB_TLS_CERT_KEY_FILE `` TLS client certificate key file
ME_CONFIG_MONGODB_TLS_CERT_KEY_FILE_PASSWORD `` TLS client certificate key file password
ME_CONFIG_MONGODB_URL_FILE `` File version of ME_CONFIG_MONGODB_URL
ME_CONFIG_SITE_BASEURL / Set the express baseUrl to ease mounting at a subdirectory. Remember to include leading and trailing slash.
ME_CONFIG_HEALTH_CHECK_PATH /status Set the mongo express healthcheck path. Remember to add the forward slash at the start.
ME_CONFIG_SITE_COOKIESECRET cookiesecret String used by cookie-parser middleware to sign cookies.
ME_CONFIG_SITE_SESSIONSECRET sessionsecret String used to sign the session ID cookie by express-session middleware.
ME_CONFIG_BASICAUTH false Deprecated, use ME_CONFIG_BASICAUTH_ENABLED instead.
ME_CONFIG_BASICAUTH_ENABLED false Enable Basic Authentication. Send strings: "true" or "false".
ME_CONFIG_BASICAUTH_USERNAME `` mongo-express web login name. If not defined, admin is the username.
ME_CONFIG_BASICAUTH_USERNAME_FILE `` File version of ME_CONFIG_BASICAUTH_USERNAME
ME_CONFIG_BASICAUTH_PASSWORD `` mongo-express web login password. If not defined, pass is the password.
ME_CONFIG_BASICAUTH_PASSWORD_FILE `` File version of ME_CONFIG_BASICAUTH_PASSWORD
ME_CONFIG_REQUEST_SIZE 100kb Used to configure maximum Mongo update payload size. CRUD operations above this size will fail due to restrictions in body-parser.
ME_CONFIG_OPTIONS_READONLY false if readOnly is true, components of writing are not visible.
ME_CONFIG_OPTIONS_FULLWIDTH_LAYOUT false If set to true an alternative page layout is used utilizing full window width.
ME_CONFIG_OPTIONS_PERSIST_EDIT_MODE false If set to true, remain on the same page after clicking on the Save button
ME_CONFIG_OPTIONS_NO_DELETE false If noDelete is true, components of deleting are not visible.
ME_CONFIG_SITE_SSL_ENABLED false Enable SSL.
ME_CONFIG_SITE_SSL_CRT_PATH SSL certificate file.
ME_CONFIG_SITE_SSL_KEY_PATH SSL key file.
ME_CONFIG_SITE_GRIDFS_ENABLED false Enable gridFS to manage uploaded files.
ME_CONFIG_DOCUMENTS_PER_PAGE 10 How many documents you want to see at once in collection view
PORT 8081 port that mongo-express will run on.
VCAP_APP_HOST localhost address that mongo-express will listen on for incoming connections.

Example:

docker run -it --rm \
    --name mongo-express \
    --network web_default \
    -p 8081:8081 \
    -e ME_CONFIG_BASICAUTH_ENABLED="false" \
    -e ME_CONFIG_MONGODB_URL="mongodb://mongo:27017" \
    mongo-express

This example links to a container name typical of docker-compose, changes the editor's color theme, and disables basic authentication.

To use:

The default port exposed from the container is 8081, so visit http://localhost:8081 or whatever URL/port you entered into your config (if running standalone) or whatever config.site.baseUrl (if mounting as a middleware).

Using Docker Extensions:

Pre-requisite:

  • Docker Desktop 4.15

Usage:

By using Mongo Express Docker Extension, it's easy to setup Mongo Express on Docker Desktop with just one click.

Usage (IBM Cloud)

Deploy to IBM Cloud

Doing manually:

  • Git clone this repository
  • Create a new or use already created MongoDB service
  • Change the file examples/ibm-cloud/manifest.yml to fit your IBM Cloud app and service environment

Doing automatically:

  • Click the button below to fork into IBM DevOps Services and deploy your own copy of this application on IBM Cloud

Deploy to IBM Cloud

Then, take the following action to customize to your environment:

  • Create your config.js file based on config.default.js
    • Check if it is necessary to change the dbLabel according to the MongoDB service created
    • Change the basicAuth properties, do not to keep the default values

Search

  • Simple search takes the user provided fields (key & value) and prepares a MongoDB find() object, with projection set to {} so returns all columns.
  • Advanced search passes the find and projection fields/objects straight into MongoDB db.collection.find(query, projection). The find object is where your query happens, while the projection object determines which columns are returned.

See MongoDB db.collection.find() documentation for examples and exact usage.

Planned features

Pull Requests are always welcome! <3

Limitations

  • Documents must have the document._id property to be edited
  • Binary BSON data type not tested

E2E Testing

We are currently trying to use Cypress, to open cypress use the command `cypress open`
To instrument the code to allow the E2E coverage to run, please run this command: `yarn nyc instrument --compact=false lib instrumented`

Not Tested

  • Binary/BinData

JSON documents are parsed through a javascript virtual machine, so the web interface can be used for executing malicious javascript on a server.

mongo-express should only be used privately for development purposes.

BSON Data Types

The following BSON data types are supported in the mongo-express document editor/viewer.

Native Javascript Types

Strings, numbers, lists, booleans, null, etc.

All numbers in Javascript are 64-bit floating points.

ObjectID/ObjectId

ObjectId()

Creates a new Object ID type.

ObjectId(id)

Use Object ID with the given 24-digit hexadecimal string.

ISODate

ISODate()

Creates a new ISODate object with the current time.

new Date() can also be used (note the new keyword there).

ISODate(timestamp)

Uses ISODate object with the given timestamp.

UUID

UUID()

Creates a new UUID v4.

Can also be used new UUID() (note the new keyword there).

UUID(uuid)

Uses UUID v4 with the given 24-digit hexadecimal string.

Example: UUID("dee11d4e-63c6-4d90-983c-5c9f1e79e96c") or UUID("dee11d4e63c64d90983c5c9f1e79e96c")

DBRef/Dbref

DBRef(collection, objectID)

DBRef(collection, objectID, database)

Object ID is the ID string, not the ObjectId type.

The database value is optional.

Timestamp

Timestamp()

Creates a new Timestamp object with a value of 0.

Timestamp(time, ordinal)

Example: Timestamp(ISODate(), 0).

See http://www.mongodb.org/display/DOCS/Timestamp+data+type for more info about the Timestamp data type.

Code

Code(code)

Code can be a native Javascript function, or it can be a string.

Specifying a scope/context is not supported.

MinKey

MinKey()

MaxKey

MaxKey()

Symbol

Symbol(string)

Example Document

Here is an example of a document which can be read/edited in mongo-express (media truncated for legibility):

{
  "_id": ObjectId(),
  "dates": {
    "date": ISODate("2012-05-14T16:20:09.314Z"),
    "new_date": ISODate(),
    "alternative": new Date()
  },
  "photo": "data:image/jpeg;base64,/9j/4...",
  "video": "data:video/webm;base64,GkXfo...",
  "audio": "data:audio/ogg;base64,T2dnUw...",
  "bool": true,
  "string": "hello world!",
  "list of numbers": [
    123,
    111e+87,
    4.4,
    -12345.765
  ],
  "reference": DBRef("collection", "4fb1299686a989240b000001"),
  "ts": Timestamp(ISODate(), 1),
  "minkey": MinKey(),
  "maxkey": MaxKey(),
  "func": Code(function() { alert('Hello World!') }),
  "symbol": Symbol("test")
}

mongo-express-docker's People

Contributors

bkabrda avatar blackthornyugen avatar codingkoopa avatar docker-library-bot avatar emcniece avatar fitztrev avatar jafarakhondali avatar joshantbrown avatar ketouem avatar knickers avatar laurentgoderre avatar mahdiabbasi95 avatar rtritto avatar scaraux avatar shakaran avatar taboca avatar thomasleveil avatar tianon avatar torrespro avatar zxkane avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongo-express-docker's Issues

Can't Import .csv - Docker logs return 400

When i click import button, and choose .csv file to import, it does nothing.
I tried to refresh the page but still nothing in the collection.
I checked the docker logs:

 POST /db/sc/import/kay 400 14.482 ms - 8
 POST /db/sc/import/kay 400 26.983ms - 8
 POST /db/sc/import/kay 400 15.84 5 ms - 8

Allow usage without docker linking

Now if mongo is not linked to docker, but is available via host/port mongo express will restart.

The "port check" is not valid:

/dev/tcp/$host/$port

Also after restart it

That makes this image only usable with docker compose and absolutely useless for using for other environments when mongo is located on different machine.

Expected behaviour:
Allow setting ME_CONFIG_MONGODB_SERVER to something other than linked host
Server should connect server set in ME_CONFIG_MONGODB_SERVER variable if it's runnning on local docker or remote machine

node:5.6-slim is unsupported

See https://github.com/nodejs/LTS for information about Node's support levels, but 5.6-slim is no longer supported.

The two main options I see are to switch to either node:5-slim (latest in the 5.x series, staying supported, but at the cost of a slightly more experimental Node release that won't be supported for a ton longer, but maybe punt on that until 6.x is officially LTS?) or actually downgrading to the current LTS, node:4-slim, but I don't know the implications of downgrading (do users of the image commonly enhance it by installing more utilities? does it work better on 5.x?)

Wrong parsing of options `ME_CONFIG_MONGODB_SSLVALIDATE` and `ME_CONFIG_MONGODB_SSL`

For v0.54 (the one upon which Docker Hub image is built)

In lib/db.js, at line 172:
if environment variable ME_CONFIG_MONGODB_SSL is 'true', then the string is passed as is at lines 190 & 196.
The problem is the Server() or ReplSet() methods don't work well with string instead of booleans and then:

dbOptions = { ssl: 'true' }

is handled as:

dbOptions = { ssl: false }

which ... sucks.

also applies to line 173 with sslValidate.

Add support for replica set

When using a mongo replicaset, the dockerfile wait for TCP port on the full chain.

Config :
ME_CONFIG_MONGODB_SERVER="mongo-0.mongo,mongo-1.mongo"

While booting, the container logs some errors while waiting for hosts

Tue Oct  9 08:41:51 UTC 2018 retrying to connect to mongo-0.mongo,mongo-1.mongo:27017 (2/5)
/docker-entrypoint.sh: line 14: mongo-0.mongo,mongo-1.mongo: Name does not resolve
/docker-entrypoint.sh: line 14: /dev/tcp/mongo-0.mongo,mongo-1.mongo/27017: Invalid argument

Mongo-express docker fails to connect to Mongo docker if DB volume is mounted

I have this docker-compose file:

version: '3.7'
services:
  db-mongo:
    image: mongo
    container_name: db-mongo
  environment:
      - MONGO_INITDB_DATABASE=auth
      - MONGO_INITDB_ROOT_USERNAME=admin
      - MONGO_INITDB_ROOT_PASSWORD=pass
  volumes:
     - /Users/John/Documents/Docker/mongoDB/db-mongo:/data/db
   ports:
      - '27017:27017'
  db-mongo-admin:
    image: mongo-express
    container_name: db-mongo-admin
    depends_on:
      - db-mongo
    environment:
      - ME_CONFIG_MONGODB_SERVER=db-mongo
      - ME_CONFIG_MONGODB_ADMINUSERNAME=admin
      - ME_CONFIG_MONGODB_ADMINPASSWORD=pass
      - ME_CONFIG_BASICAUTH_USERNAME=admin
      - ME_CONFIG_BASICAUTH_PASSWORD=fairlylongpassword
    ports:
      - '8081:8081'

When i start it up, it fails with

...
Mon Jan 27 06:11:19 UTC 2020 retrying to connect to db-mongo:27017 (5/5)
/docker-entrypoint.sh: connect: Connection refused
/docker-entrypoint.sh: line 14: /dev/tcp/db-mongo/27017: Connection refused
Welcome to mongo-express
------------------------
/node_modules/mongodb/lib/server.js:265
        process.nextTick(function() { throw err; })
                                      ^
MongoError: failed to connect to server [db-mongo:27017] on first connect
...

But if I remove the bind mount from the Mongo container, without changing anything else, both containers start fine and I can use mongo-express to log to the DB.

Basic login security

I'm confused on how to configure this for even basic website authentication.

I have tried multiple configuration options in my docker-compose.yml but only got the login prompt one time. I didn't tell Safari to save it, yet I haven't not had it come back.

What specifically do I need to configure to make it so I get a login prompt for mongo-express.

Thank you.

version: '3.6'

services:

  mongo:
    container_name: mongo
    build: .
    restart: always
    env_file: .env
    environment:
      MONGO_INITDB_ROOT_USERNAME: $MDB_ADMIN
      MONGO_INITDB_ROOT_PASSWORD: $MDB_PWD
    volumes:
      - ./data:/data/db
    networks:
      - my-bridge-net

  mongo-express:
    container_name: mongo-express
    image: mongo-express
    restart: always
    ports:
      - 8008:8081
    env_file: .env
    environment:
#      ME_CONFIG_OPTIONS_EDITORTHEME: ambiance
#      ME_CONFIG_MONGODB_ENABLE_ADMIN: 0
      ME_CONFIG_BASICAUTH_USERNAME: username
      ME_CONFIG_BASICAUTH_PASSWORD: password
      ME_CONFIG_MONGODB_ADMINUSERNAME: $MDB_ADMIN
      ME_CONFIG_MONGODB_ADMINPASSWORD: $MDB_PWD
    networks:
      - my-bridge-net

networks:
  my-bridge-net:
    external: true```

Db not found in mongo express, which is connected with my node application

I have created an image with Docker for mongo db named mongodb and I am running mongo express using this mongodb.

image

Here's my code of app.js

const MongoClient = require('mongodb').MongoClient;
const assert = require('assert');

// Connection URL
const url = 'mongodb://127.0.0.1:27017';

// Database Name
const dbName = 'abstractdb'; //''myproject';

// Use connect method to connect to the server
MongoClient.connect(url, function (err, client) {

    assert.equal(null, err);
    console.log("Connected successfully to server.");

    const db = client.db(dbName);
    // insertDocuments(db, function () {
    //     client.close();
    // });

     insertDocuments(db, function () {
        findDocuments(db, function () {
            client.close();
        });
     });

});

const insertDocuments = function (db, callback) {
    // Get the documents collection
    const collection = db.collection('documents');
    // Insert some documents
    debugger;
    collection.insertMany([
        { a: 4 }, { a: 5 }, { a: 6 }
    ], function (err, result) {
        
        debugger;

        assert.equal(err, null);
        assert.equal(3, result.result.n);
        assert.equal(3, result.ops.length);

        debugger;

        console.log("Inserted 3 documents into the collection");
        callback(result);
    });
}

const findDocuments = function (db, callback) {
    // Get the documents collection
    const collection = db.collection('documents') //('abstract');
    // Find some documents`
    debugger;
    collection.find({}).toArray(function (err, docs) {
        assert.equal(err, null);
        debugger;
        console.log("Found the following records");
        console.log(docs)
        callback(docs);
    });
}

Whenever I run my project using the command node app.js, it inserts the data and retrieves it as shown in below image:

image

However, when I check it in browser http://localhost:8081/, I can not see this newly added data, and I can not even see the database/collection created. It just shows the default admin, config and local.

image

The package config contains "mongodb": "^3.5.9".

I have also tried by changing the container name to localmongo, but nothing worked.
Please help me in this.

Mongo Express Docker Container not activating.

Hi,

I am trying to check the Status of a newly created Mongo Express Docker Container by using the below command:

docker logs [Container ID]

but getting the below error:

(node:5) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(node:5) UnhandledPromiseRejectionWarning: MongoError: command listDatabases requires authentication
at Connection. (/node_modules/mongodb/lib/core/connection/pool.js:453:61)
at Connection.emit (events.js:314:20)
at processMessage (/node_modules/mongodb/lib/core/connection/connection.js:454:10)
at Socket. (/node_modules/mongodb/lib/core/connection/connection.js:623:15)
at Socket.emit (events.js:314:20)
at addChunk (_stream_readable.js:297:12)
at readableAddChunk (_stream_readable.js:272:9)
at Socket.Readable.push (_stream_readable.js:213:10)
at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(node:5) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:5) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Please note that this Container will be connecting to Mongo DB and all the details have been mentioned in the command. Looks like there is an update in the command which i'm not sure what. Below is what actually created the Mongo Express. It is showing as Running when i check with the dcoker ps command. However, when i type in a 'browser: localhost:8081' nothing is displayed.

Below is command that created Mongo Express:
docker run -d -p 8081:8081 -e ME_CONFIG_MONGODB_ADMINUSERNAME=admin -e ME_CONFIG_MONGODB_ADMINPASSWORD=password -e ME_CONFIG_MONGODB_SERVER=mongodb --name Mongo-express --net Mongo-Network mongo-express

MongoClient constructor error "useUnifiedTopology: true"

When I am trying to connect to the server it is showing this "deprecated" message. I tried to find the "MongoClient constructor" but was unable to find it. How can I fix this?

Error message here:
Welcome to mongo-express
------------------------


(node:7) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(node:7) UnhandledPromiseRejectionWarning: MongoError: command listDatabases requires authentication
    at Connection.<anonymous> (/node_modules/mongodb/lib/core/connection/pool.js:453:61)
    at Connection.emit (events.js:314:20)
    at processMessage (/node_modules/mongodb/lib/core/connection/connection.js:454:10)
    at Socket.<anonymous> (/node_modules/mongodb/lib/core/connection/connection.js:623:15)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(node:7) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:7) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

can't name mongo anything else but 'mongo'

in docker-compose.yml:

mongo-express:
container_name: mongo-express
image: mongo-express
depends_on:
- mongo
environment:
- ME_CONFIG_MONGODB_SERVER=I_can_put_anything_here

this will work, as long as the mongo container is named 'mongo'; the ME_CONFIG_MONGODB_SERVER field is totally ignored.

if I name my mongo container 'mongodb', then mongo-express doesn't start properly.

[Bug] Basic auth don't work behind traefik (keep repeating asking log/pwd)

Hello,

We use traefik v2 as frontal reverse proxy.
It seems the auth basic feature of mongo express docker don't work with traefik.
When we set ME_CONFIG_BASICAUTH_USERNAME and ME_CONFIG_BASICAUTH_PASSWORD, on the browser there is the popin asking for login/password, but even with good credential, it keeps again and indefinitly to ask them.

For information, on this same docker stack we use apache behing traefik and the basic auth of apache works fine, that's why I suspect mongo-express-docker to have maybe a problem.

Thanks.

[Bug] Docker entrypoint breaks possibility to use linux socket

Hello,

First thanks for providing this great software !

We wanted to link mogo-express to mongodb by unix socket (as our mongodb is open via socket only for performance and security reason), but when we set ME_CONFIG_MONGODB_URL as a socket connection (ie: mongodb:///tmp/mongodb-27017.sock) in docker log the message ... retrying to connect ... keeps reapeating.
(we tried with mongodb://%2Ftmp%2Fmongodb-27017.sock too).

After diging into the entrypoint it seems it cannot work at all with linux socket as it check for tcp connection, please see:
https://github.com/mongo-express/mongo-express-docker/blob/master/docker-entrypoint.sh#L14

The native mongo-express seems to be able to works with socket, but this docker entrypoint limitation seems to defeat all socket use as it check only and wait for tcp connection.

Purpose of this issue is to change the entry point to check for socket connexion too.

Thanks.

ME_CONFIG_MONGODB_URL is not listed in the README

If you want to point the container to mongo using a connection string instead of the mongo container name, you have to use ME_CONFIG_MONGODB_URL, but this variable is not listed on the README for the current image.

It's worth noting that you also have to set ME_CONFIG_MONGODB_SERVER = "" in order for this work, since otherwise the default of "mongo" is used, and the container just uses that.

Unable to see server status

Seeing "Turn on admin in config.js to view server stats!" after specifying ME_CONFIG_MONGODB_ENABLE_ADMIN=true

Feature Request: Unauthenticated health check

For certain deployments, e.g. Kubernetes with CGE Load Balancers, each pod is required to provide an unauthenticated health check route. This route ("/" by default, but I think it can be configured) should responds with status code 200 OK when the service is running properly.

Currently, mongo-express only supports this requirement if basic auth is disabled, which then leaves it completely unauthenticated.

I propose an additional parameter ME_CONFIG_HEALTH_CHECK_PATH, which creates an unauthenticated route that simply returns 200 OK when called. The fact that the route can be called should suffice as a health check, although more elaborate ones could also be implemented.

Ideally this route should work in combination with ME_CONFIG_SITE_BASEURL, such that the following scenario would be possible:

  • ME_CONFIG_SITE_BASEURL = "/express" -> The mongo-express UI is served on "/express"
  • ME_CONFIG_HEALTH_CHECK_PATH = "/" -> Health checks can be run on "/"

mongodb mongo-express docker-compose.yml

Pulling mongo (mongo:3.6.22-xenial)...
3.6.22-xenial: Pulling from library/mongo
4007a89234b4: Pull complete
5dfa26c6b9c9: Pull complete
0ba7bf18aa40: Pull complete
4c6ec688ebe3: Pull complete
6e27db06de4c: Pull complete
bbecf0ce3761: Pull complete
ce97543d924d: Pull complete
7299669aa5f5: Pull complete
e5fda94ce451: Pull complete
3673227c8d34: Pull complete
4bb718560867: Pull complete
c687b7b215c2: Pull complete
858fb3568c68: Pull complete
Digest: sha256:0a514a1da4da907230f62b9feac783d7cfe601ea51cba33398402f171c359256
Status: Downloaded newer image for mongo:3.6.22-xenial
Pulling mongo-express (mongo-express:0.54.0)...
0.54.0: Pulling from library/mongo-express
e95f33c60a64: Pull complete
8ad47429afec: Pull complete
ed32558722b1: Pull complete
b1f8c696047a: Pull complete
ac51d5cab64d: Pull complete
20aee6a49efa: Pull complete
8c46e74838a7: Pull complete
be294c44cfba: Pull complete
Digest: sha256:6ac0e6f0a7b2739a03fd29dc8c66853a57c527a2ba8b5ab7bfa7dae9ecbc7c92
Status: Downloaded newer image for mongo-express:0.54.0
Creating 2020-08-31-docker-compose_react-app_1 ... done
Creating mongo                                 ... done
Creating mongo-express                          ... done
Creating 2020-08-31-docker-compose_api-server_1 ... done
Attaching to 2020-08-31-docker-compose_react-app_1, mongo, mongo-express, 2020-08-31-docker-compose_api-server_1
react-app_1      | yarn run v1.22.5
react-app_1      | $ react-scripts start
mongo            | 2021-03-21T13:41:34.084+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=bfa1f60de773
mongo            | 2021-03-21T13:41:34.085+0000 I CONTROL  [initandlisten] db version v3.6.22
mongo            | 2021-03-21T13:41:34.085+0000 I CONTROL  [initandlisten] git version: 62d9f36d148e4dacfec1ca8fcb110f1cc410336f
mongo            | 2021-03-21T13:41:34.085+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
mongo            | 2021-03-21T13:41:34.085+0000 I CONTROL  [initandlisten] allocator: tcmalloc
mongo            | 2021-03-21T13:41:34.085+0000 I CONTROL  [initandlisten] modules: none
mongo            | 2021-03-21T13:41:34.085+0000 I CONTROL  [initandlisten] build environment:
mongo            | 2021-03-21T13:41:34.085+0000 I CONTROL  [initandlisten]     distmod: ubuntu1604
mongo            | 2021-03-21T13:41:34.085+0000 I CONTROL  [initandlisten]     distarch: x86_64
mongo            | 2021-03-21T13:41:34.085+0000 I CONTROL  [initandlisten]     target_arch: x86_64
mongo            | 2021-03-21T13:41:34.085+0000 I CONTROL  [initandlisten] options: { net: { bindIpAll: true }, security: { authorization: "enabled" } }
mongo            | 2021-03-21T13:41:34.085+0000 W -        [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
mongo-express    | Waiting for mongo:27017...
mongo            | 2021-03-21T13:41:34.099+0000 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
mongo            | 2021-03-21T13:41:34.099+0000 W STORAGE  [initandlisten] Recovering data from the last clean checkpoint.
mongo            | 2021-03-21T13:41:34.099+0000 I STORAGE  [initandlisten] 
mongo            | 2021-03-21T13:41:34.099+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
mongo            | 2021-03-21T13:41:34.099+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
mongo            | 2021-03-21T13:41:34.099+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=2580M,cache_overflow=(file_max=0M),session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),compatibility=(release="3.0",require_max="3.0"),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
mongo            | 2021-03-21T13:41:38.655+0000 E STORAGE  [initandlisten] WiredTiger error (-31802) [1616334098:655048][1:0x7f0e9534ba40], connection: __log_open_verify, 1028: Version incompatibility detected: unsupported WiredTiger file version: this build requires a maximum version of 2, and the file is version 3: WT_ERROR: non-specific WiredTiger error Raw: [1616334098:655048][1:0x7f0e9534ba40], connection: __log_open_verify, 1028: Version incompatibility detected: unsupported WiredTiger file version: this build requires a maximum version of 2, and the file is version 3: WT_ERROR: non-specific WiredTiger error
mongo            | 2021-03-21T13:41:38.655+0000 E STORAGE  [initandlisten] An unsupported journal format detected - If you are trying to rollback from version 4.0 to 3.6, please re-start a 4.0 binary and cleanly shut it down so that the journal format will be downgraded.
mongo            | 2021-03-21T13:41:38.756+0000 E -        [initandlisten] Assertion: 28595:-31802: WT_ERROR: non-specific WiredTiger error src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 488
mongo            | 2021-03-21T13:41:38.758+0000 I STORAGE  [initandlisten] exception in initAndListen: Location28595: -31802: WT_ERROR: non-specific WiredTiger error, terminating
mongo            | 2021-03-21T13:41:38.762+0000 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
mongo            | 2021-03-21T13:41:38.762+0000 I NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
mongo            | 2021-03-21T13:41:38.762+0000 I CONTROL  [initandlisten] now exiting
mongo            | 2021-03-21T13:41:38.763+0000 I CONTROL  [initandlisten] shutting down with code:100
mongo exited with code 100
mongo-express    | /docker-entrypoint.sh: line 14: mongo: Try again
mongo-express    | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express    | Sun Mar 21 13:41:46 UTC 2021 retrying to connect to mongo:27017 (2/5)
api-server_1     | (node:1) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
api-server_1     | (Use `node --trace-deprecation ...` to show where the warning was created)
api-server_1     | Server running on port 5000
api-server_1     | Connection error failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
api-server_1     |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
api-server_1     |   name: 'MongoNetworkError'
api-server_1     | }]
api-server_1     | MongoDB connection error: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
api-server_1     |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
api-server_1     |   name: 'MongoNetworkError'
api-server_1     | }]
api-server_1     |     at Pool.<anonymous> (/usr/src/app/node_modules/mongodb/lib/core/topologies/server.js:438:11)
api-server_1     |     at Pool.emit (events.js:315:20)
api-server_1     |     at /usr/src/app/node_modules/mongodb/lib/core/connection/pool.js:562:14
api-server_1     |     at /usr/src/app/node_modules/mongodb/lib/core/connection/pool.js:995:11
api-server_1     |     at /usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:31:7
api-server_1     |     at callback (/usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:264:5)
api-server_1     |     at Socket.<anonymous> (/usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:294:7)
api-server_1     |     at Object.onceWrapper (events.js:422:26)
api-server_1     |     at Socket.emit (events.js:315:20)
api-server_1     |     at emitErrorNT (internal/streams/destroy.js:106:8)
api-server_1     |     at emitErrorCloseNT (internal/streams/destroy.js:74:3)
api-server_1     |     at processTicksAndRejections (internal/process/task_queues.js:80:21)
mongo-express    | /docker-entrypoint.sh: line 14: mongo: Try again
mongo-express    | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
react-app_1      | ℹ 「wds」: Project is running at http://172.23.0.2/
react-app_1      | ℹ 「wds」: webpack output is served from 
react-app_1      | ℹ 「wds」: Content not from webpack is served from /usr/src/app/public
react-app_1      | ℹ 「wds」: 404s will fallback to /
react-app_1      | Starting the development server...
react-app_1      | 
mongo-express    | Sun Mar 21 13:41:52 UTC 2021 retrying to connect to mongo:27017 (3/5)
react-app_1      | Browserslist: caniuse-lite is outdated. Please run the following command: `npx browserslist --update-db`
mongo-express    | /docker-entrypoint.sh: line 14: mongo: Try again
mongo-express    | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express    | Sun Mar 21 13:41:58 UTC 2021 retrying to connect to mongo:27017 (4/5)
mongo-express    | /docker-entrypoint.sh: line 14: mongo: Try again
mongo-express    | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express    | Sun Mar 21 13:42:04 UTC 2021 retrying to connect to mongo:27017 (5/5)
mongo-express    | /docker-entrypoint.sh: line 14: mongo: Try again
mongo-express    | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express    | Welcome to mongo-express
mongo-express    | ------------------------
mongo-express    | 
mongo-express    | 
mongo-express    | Mongo Express server listening at http://0.0.0.0:8081
mongo-express    | Server is open to allow connections from anyone (0.0.0.0)
mongo-express    | 
mongo-express    | /node_modules/mongodb/lib/server.js:265
mongo-express    |         process.nextTick(function() { throw err; })
mongo-express    |                                       ^
mongo-express    | Error [MongoError]: failed to connect to server [mongo:27017] on first connect
mongo-express    |     at Pool.<anonymous> (/node_modules/mongodb-core/lib/topologies/server.js:326:35)
mongo-express    |     at Pool.emit (events.js:314:20)
mongo-express    |     at Connection.<anonymous> (/node_modules/mongodb-core/lib/connection/pool.js:270:12)
mongo-express    |     at Object.onceWrapper (events.js:421:26)
mongo-express    |     at Connection.emit (events.js:314:20)
mongo-express    |     at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:175:49)
mongo-express    |     at Object.onceWrapper (events.js:421:26)
mongo-express    |     at Socket.emit (events.js:314:20)
mongo-express    |     at emitErrorNT (internal/streams/destroy.js:92:8)
mongo-express    |     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
mongo-express exited with code 1
react-app_1      | Compiled with warnings.
react-app_1      |
react-app_1      | ./src/components/Logo.jsx
react-app_1      |   Line 14:17:  img elements must have an alt prop, either with meaningful text, or an empty string for decorative images  jsx-a11y/alt-text
react-app_1      |
react-app_1      | Search for the keywords to learn more about each warning.
react-app_1      | To ignore, add // eslint-disable-next-line to the line before.
react-app_1      |

Doesn't work with docker swarm

mongo-express fails to run when deploying a "multi" stack architecture including mongo services via a docker-compose file to a swarm.

None of our databases are deployed with their ports exposed for security reasons and all services should be able to be located via it's service name as we have no idea beforehand onto which node mongodb will be deployed. We use amazon EFS to store the actual data so rescheduling the mongodb to another instance is easily supported.

However, when setting "mongo" as the server for mongo-express it fails to startup as it never passes the test in the "docker-entrypoint.sh"

i.e.
while ! exec 6<>/dev/tcp/$host/$port && [[ $tries -lt $max_tries ]]; do .....

Update to version 0.47.0

Hello, @tianon @knickers!

I'd like to reach out to you and ask if you can please update the project to the 0.47.0 version, as it fixes a major issue with data export:

Release note

  • Fixed issue where export would only export partial results (#406)

Please let me know if I can help somehow.

Thanks!

Cannot Import JSON file

I try to import an JSON file to mongo-express but it will output an error 400, error message is always BAD file. Is there way to fix this. Thank you in advance.

Can't run mongo-express docker image: Fatal process OOM in insufficient memory to create an Isolate

Hi there,

I'm trying to run this container directly on bash and i can't get it started:

Notice: i broke it in more lines to be more readable

docker run --name=mongo-gui -p 27018:8081 \
-e ME_CONFIG_MONGODB_URL="mongodb://172.17.0.1:27017" \
-e ME_CONFIG_MONGODB_ENABLE_ADMIN=true \
-e ME_CONFIG_BASICAUTH_USERNAME=randomusername \
-e ME_CONFIG_BASICAUTH_PASSWORD=randompassword \
-e ME_CONFIG_OPTIONS_EDITORTHEME="dracula" \
-d mongo-express

Running a docker logs mongo-gui, it returns me this:

<--- Last few GCs --->


<--- JS stacktrace --->


#
# Fatal process OOM in insufficient memory to create an Isolate
#

My enviroment and important details

  • My docker version is 20.10.17, build 100c701
  • My containerd version is 1.6.6
  • My docker host is a Oracle Linux Server 8.6 with arm64 architecture;
  • I got 16GB RAM so memory coudn't be the problem
  • I tried running more simple containers such as this and got same problem:
docker run --name=mongo-gui --net=host -e ME_CONFIG_MONGODB_SERVER=mongo-dev -p 27018:8081 -d mongo-express
  • My mongo-express docker image is the latest, i tryed to remove it for many times and pulling again to remount container but nothing solved;
  • I coudn't find anything about that error, is there any way to pass max-old-space-size as a env variable for mongo-express image?

Connect to CosmosDB in Azure

Hi!
Is there a way using mongo-express-docker to connect to CosmosDB in Azure? For this, a link of the following form is used: mongodb://username:password@host:port/[database]?ssl=true

I know there is a parameter ME_CONFIG_MONGODB_URL, but when using it I still need to specify something in the ME_CONFIG_MONGODB_SERVER and ME_CONFIG_MONGODB_PORT parameters. It looks like parameter ME_CONFIG_MONGODB_URL is not working.

Add ARM64v8 support

I am able to build & run mongo-express properly on arm64v8 architecture.

The changes done are very minimal w.r.t. node & tini.
The resulting image is properly tested and I can also provide build and run logs, if required.

I would be happy to raise PR, if you allow me for it.

Regards,

max_tries to be a configuration

I have a MacBook air 2013 — perhaps a bit loaded — and I am under the impression that the max_tries = 5 was not enough time which led to Mongo Express failing.

The max_tries variable I am referring to is:
https://github.com/mongo-express/mongo-express-docker/blob/master/docker-entrypoint.sh#L11

When looking at my logs I can see that it may have reached out to the maximum:

Filtering the 'retrying' lines

tabocalabs.remotebot.mongo-express_1  | Wed Jan 20 20:27:07 UTC 2021 retrying to connect to tabocalabs.remotebot.mongo-express_1  | Wed Jan 20 20:27:08 UTC 2021 retrying to connect to tabocalabs.remotebot.mongo-express_1  | Wed Jan 20 20:27:09 UTC 2021 retrying to connect to tabocalabs.remotebot.mongo-express_1  | Wed Jan 20 20:27:10 UTC 2021 retrying to connect to 

Full log until the error

Creating network "remote-mongodb-stories_mongo-compose-network" with driver "bridge"
Creating remote-mongodb-stories_tabocalabs.remotebot.mongo_1 ... done
Creating remote-mongodb-stories_tabocalabs.remotebot.mongo-express_1 ... done
Attaching to remote-mongodb-stories_tabocalabs.remotebot.mongo_1, remote-mongodb-stories_tabocalabs.remotebot.mongo-express_1
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:04.986+00:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:05.038+00:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
tabocalabs.remotebot.mongo-express_1  | /docker-entrypoint.sh: connect: Connection refused
tabocalabs.remotebot.mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/tabocalabs.remotebot.mongo/27017: Connection refused
tabocalabs.remotebot.mongo-express_1  | Waiting for tabocalabs.remotebot.mongo:27017...
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:05.041+00:00"},"s":"I",  "c":"NETWORK",  "id":4648601, "ctx":"main","msg":"Implicit TCP FastOpen unavailable. If TCP FastOpen is required, set tcpFastOpenServer, tcpFastOpenClient, and tcpFastOpenQueueSize."}
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:05.061+00:00"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":1,"port":27017,"dbPath":"/data/db","architecture":"64-bit","host":"28aa4a326016"}}
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:05.061+00:00"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.3","gitVersion":"913d6b62acfbb344dde1b116f4161360acd8fd13","openSSLVersion":"OpenSSL 1.1.1  11 Sep 2018","modules":[],"allocator":"tcmalloc","environment":{"distmod":"ubuntu1804","distarch":"x86_64","target_arch":"x86_64"}}}}
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:05.061+00:00"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Ubuntu","version":"18.04"}}}
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:05.061+00:00"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"net":{"bindIp":"*"},"security":{"authorization":"enabled"}}}}
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:05.093+00:00"},"s":"W",  "c":"STORAGE",  "id":22271,   "ctx":"initandlisten","msg":"Detected unclean shutdown - Lock file is not empty","attr":{"lockFile":"/data/db/mongod.lock"}}
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:05.156+00:00"},"s":"I",  "c":"STORAGE",  "id":22270,   "ctx":"initandlisten","msg":"Storage engine to use detected by data files","attr":{"dbpath":"/data/db","storageEngine":"wiredTiger"}}
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:05.181+00:00"},"s":"W",  "c":"STORAGE",  "id":22302,   "ctx":"initandlisten","msg":"Recovering data from the last clean checkpoint."}
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:05.186+00:00"},"s":"I",  "c":"STORAGE",  "id":22315,   "ctx":"initandlisten","msg":"Opening WiredTiger","attr":{"config":"create,cache_size=487M,session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress,compact_progress],"}}
tabocalabs.remotebot.mongo-express_1  | Wed Jan 20 20:27:07 UTC 2021 retrying to connect to tabocalabs.remotebot.mongo:27017 (2/5)
tabocalabs.remotebot.mongo-express_1  | /docker-entrypoint.sh: connect: Connection refused
tabocalabs.remotebot.mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/tabocalabs.remotebot.mongo/27017: Connection refused
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:08.663+00:00"},"s":"E",  "c":"STORAGE",  "id":22435,   "ctx":"initandlisten","msg":"WiredTiger error","attr":{"error":95,"message":"[1611174428:663344][1:0x7f560c709ac0], connection: __posix_std_fallocate, 58: /data/db/journal/WiredTigerTmplog.0000000001: fallocate:: Operation not supported"}}
tabocalabs.remotebot.mongo_1          | {"t":{"$date":"2021-01-20T20:27:08.663+00:00"},"s":"E",  "c":"STORAGE",  "id":22435,   "ctx":"initandlisten","msg":"WiredTiger error","attr":{"error":95,"message":"[1611174428:663942][1:0x7f560c709ac0], connection: __posix_sys_fallocate, 75: /data/db/journal/WiredTigerTmplog.0000000001: fallocate:: Operation not supported"}}
tabocalabs.remotebot.mongo-express_1  | Wed Jan 20 20:27:08 UTC 2021 retrying to connect to tabocalabs.remotebot.mongo:27017 (3/5)
tabocalabs.remotebot.mongo-express_1  | /docker-entrypoint.sh: connect: Connection refused
tabocalabs.remotebot.mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/tabocalabs.remotebot.mongo/27017: Connection refused
tabocalabs.remotebot.mongo-express_1  | /docker-entrypoint.sh: connect: Connection refused
tabocalabs.remotebot.mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/tabocalabs.remotebot.mongo/27017: Connection refused
tabocalabs.remotebot.mongo-express_1  | Wed Jan 20 20:27:09 UTC 2021 retrying to connect to tabocalabs.remotebot.mongo:27017 (4/5)
tabocalabs.remotebot.mongo-express_1  | Wed Jan 20 20:27:10 UTC 2021 retrying to connect to tabocalabs.remotebot.mongo:27017 (5/5)
tabocalabs.remotebot.mongo-express_1  | /docker-entrypoint.sh: connect: Connection refused
tabocalabs.remotebot.mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/tabocalabs.remotebot.mongo/27017: Connection refused
tabocalabs.remotebot.mongo-express_1  | Welcome to mongo-express
tabocalabs.remotebot.mongo-express_1  | ------------------------
tabocalabs.remotebot.mongo-express_1  | 
tabocalabs.remotebot.mongo-express_1  | 
tabocalabs.remotebot.mongo-express_1  | Mongo Express server listening at http://0.0.0.0:8081
tabocalabs.remotebot.mongo-express_1  | Server is open to allow connections from anyone (0.0.0.0)
tabocalabs.remotebot.mongo-express_1  | 
tabocalabs.remotebot.mongo-express_1  | /node_modules/mongodb/lib/server.js:265
tabocalabs.remotebot.mongo-express_1  |         process.nextTick(function() { throw err; })
tabocalabs.remotebot.mongo-express_1  |                                       ^
tabocalabs.remotebot.mongo-express_1  | Error [MongoError]: failed to connect to server [tabocalabs.remotebot.mongo:27017] on first connect
tabocalabs.remotebot.mongo-express_1  |     at Pool.<anonymous> (/node_modules/mongodb-core/lib/topologies/server.js:326:35)
tabocalabs.remotebot.mongo-express_1  |     at Pool.emit (events.js:314:20)
tabocalabs.remotebot.mongo-express_1  |     at Connection.<anonymous> (/node_modules/mongodb-core/lib/connection/pool.js:270:12)
tabocalabs.remotebot.mongo-express_1  |     at Object.onceWrapper (events.js:421:26)
tabocalabs.remotebot.mongo-express_1  |     at Connection.emit (events.js:314:20)
tabocalabs.remotebot.mongo-express_1  |     at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:175:49)
tabocalabs.remotebot.mongo-express_1  |     at Object.onceWrapper (events.js:421:26)
tabocalabs.remotebot.mongo-express_1  |     at Socket.emit (events.js:314:20)
tabocalabs.remotebot.mongo-express_1  |     at emitErrorNT (internal/streams/destroy.js:92:8)
tabocalabs.remotebot.mongo-express_1  |     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
remote-mongodb-stories_tabocalabs.remotebot.mongo-express_1 exited with code 1

After that "docker container ls" gave me only mongo, not mongo-express. Then I did again another "docker-compose" up, assuming it would only come up with what is not available, and then it worked. Thus I am assuming that "docker-compose" up on the second attempt brought express properly after mongo was up.

Suggestion

Wonder if makes sense this variable to be available as an environment variable. If it makes I wonder if the patch is simple. Would it be as simple as doing something like the following:

Existing code

    local max_tries=5 tries=1

Proposed code

    local max_tries=$ME_CONFIG_MONGODB_MAXTRIES tries=1 

TypeError: Cannot read property 'listDatabases' of undefined

I updated my mongo-express kubernetes deployment to arm64v8/mongo-express:0.54 yesterday.

Since then, I got this error message :

Admin database is not accessible
TypeError: Cannot read property 'listDatabases' of undefined
    at Object.connectionData.updateDatabases (/node_modules/mongo-express/lib/db.js:41:11)
    at /node_modules/mongo-express/lib/router.js:94:11
    at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
    at next (/node_modules/express/lib/router/route.js:137:13)
    at Route.dispatch (/node_modules/express/lib/router/route.js:112:3)
    at Layer.handle [as handle_request] (/node_modules/express/lib/router/layer.js:95:5)
    at /node_modules/express/lib/router/index.js:281:22
    at param (/node_modules/express/lib/router/index.js:354:14)
    at param (/node_modules/express/lib/router/index.js:365:14)
    at Function.process_params (/node_modules/express/lib/router/index.js:410:3)

I'm connecting to a mongodb statefulset of 3 replicas. It worked before update (I don't remember which version was working before this one).

My deployment.yaml looks like this

apiVersion: apps/v1
kind: Deployment
metadata: 
  name: mongo-ui-deploy
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mongo-ui
  template:
    metadata:
      labels:
        app: mongo-ui
    spec:
      containers:
        - name: mongo-ui
          image: arm64v8/mongo-express:0.54
          env:
            - name: ME_CONFIG_BASICAUTH_USERNAME
              value: '[auth_username]'
            - name: ME_CONFIG_BASICAUTH_PASSWORD
              value: '[auth_verystrongpassword]'
            - name: ME_CONFIG_MONGODB_ENABLE_ADMIN
              value: 'true'
            - name: ME_CONFIG_MONGODB_ADMINUSERNAME
              value: '[mongo_username]'
            - name: ME_CONFIG_MONGODB_ADMINPASSWORD
              value: '[mongo_verystrongpassword]'
            - name: ME_CONFIG_MONGODB_SERVER
              value: 'mongod-0.mongo-srv.default.svc.cluster.local,mongod-1.mongo-srv.default.svc.cluster.local,mongod-2.mongo-srv.default.svc.cluster.local'
            - name: ME_CONFIG_SITE_COOKIESECRET
              value: '[cookie-secret]'
            - name: ME_CONFIG_SITE_SESSIONSECRET
              value: '[session-secret]'   
            - name: ME_CONFIG_SITE_BASEURL
              value: '/'         
---
apiVersion: v1
kind: Service
metadata:
  name: mongo-ui-srv
spec:
  selector:
    app: mongo-ui
  ports:
    - name: mongo-ui
      protocol: TCP
      port: 8081
      targetPort: 8081
---

sync configuration part with origin mong-express README for Docker secrets

I try to use secrets and docker-compose to start mongo-express. At first I ONLY follow the offical docker README page, so my docker-compose.yml looks like:

  mongo-express:
    image: mongo-express
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: /run/secrets/mongo_admin_user
      ME_CONFIG_MONGODB_ADMINPASSWORD: /run/secrets/mongo_admin_pass
    secrets:
      - mongo_admin_user
      - mongo_admin_pass
  secrets:
    mongo_admin_user:
      file: mongo_admin_user.txt
    mongo_admin_pass:
      file: mongo_admin_pass.txt

which results in the container restarting repeatedly, whose logs look like:

(node:8) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Could not connect to database using connectionString: mongodb:///run/secrets/mongo_admin_user:/run/secrets/mongo_admin_pass@mongo:27017/"
(node:7) UnhandledPromiseRejectionWarning: MongoParseError: Unescaped slash in userinfo section
Welcome to mongo-express

After that, I read a relevant issue, a PR, and README of mongo-express. It seems that any variable pointing to Docker secrets in mongo-express-docker is valid only if it has a _FILE postfix.

  mongo-express:
    image: mongo-express
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME_FILE: /run/secrets/mongo_admin_user
      ME_CONFIG_MONGODB_ADMINPASSWORD_FILE: /run/secrets/mongo_admin_pass
    secrets:
      - mongo_admin_user
      - mongo_admin_pass
  secrets:
    mongo_admin_user:
      file: mongo_admin_user.txt
    mongo_admin_pass:
      file: mongo_admin_pass.txt

Therefore, I suggest that README of the offical mongo-express Docker image should be synced with the README of the origin mongo-express , otherwise people would be confused.

Update to version 0.52.1

Hello, @tianon @knickers!

I'd like to reach out to you and ask if you can please update the project to the 0.52.1 version, as it adds a new feature to support secrets on docker with _FILE suffix

Thanks!

UnhandledPromiseRejectionWarning: MongoError: command listDatabases requires authentication

After last updates without any changes new issue occurred on mongo express (using docker compose):

Configuration:

    ports:
      - "8081:8081"
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: XXX
      ME_CONFIG_BASICAUTH_USERNAME: root
      ME_CONFIG_BASICAUTH_PASSWORD: XXX

And error:

(node:6) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
(node:6) UnhandledPromiseRejectionWarning: MongoError: command listDatabases requires authentication
    at Connection.<anonymous> (/node_modules/mongodb/lib/core/connection/pool.js:451:61)
    at Connection.emit (events.js:314:20)
    at processMessage (/node_modules/mongodb/lib/core/connection/connection.js:451:10)
    at Socket.<anonymous> (/node_modules/mongodb/lib/core/connection/connection.js:620:15)
    at Socket.emit (events.js:314:20)
    at addChunk (_stream_readable.js:297:12)
    at readableAddChunk (_stream_readable.js:272:9)
    at Socket.Readable.push (_stream_readable.js:213:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(node:6) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:6) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Fatal process OOM in insufficient memory to create an Isolate

encounter error below when trying to run latest mongo express image on Oracle A1 Compute

#
# Fatal process OOM in insufficient memory to create an Isolate
#


<--- Last few GCs --->


<--- JS stacktrace --->

below are the uname of the VM.

Linux oci-vm1 5.4.17-2136.310.7.1.el8uek.aarch64 #2 SMP Wed Aug 17 15:17:46 PDT 2022 aarch64 aarch64 aarch64 GNU/Linux.

this error and environment is similiar to this previously reported issue.

mongo-express/mongo-express#866

Actualize docker image.

Please actualize your official docker image on https://hub.docker.com/_/mongo-express/.

Some issues which was already fixed in main branch at github , still exists in image on docker hub.

for example: issue #361 (db is not a function) still exist at this image.

PS: I'm have alredy fixed this local, but think it will be a good practice update official image . Thanks

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)

Could not create collection

mongo:
    image: mongo:4.2
    restart: always
    environment:
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: 111111
    volumes:
      - ./../mongodb:/var/lib/mongodb
  mongo-express:
    image: mongo-express:0.49
    restart: always
    ports:
      - 8081:8081
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: root
      ME_CONFIG_MONGODB_ADMINPASSWORD: 111111
    links:
      - mongo

111

Accessing documents with BinData as value for `_id`

Hello there. I'm new to MongoDB and C#, so please don't frown when this is a stupid question. But I'm unable to access documents in the web client where the value for the _id column (property?) was generated from a C# Guid.

Here's my (simplified) C# class:

    public class MyClass
    {
        [BsonId]
        public Guid MyId {get; set; }

        public string MyPropertyA { get; set; }
    }

Now when I store a document:

var myClassObj = new MyClass
{
    MyId = Guid.NewGuid(), // Let's assume it is "C56A4180-65AA-42EC-A945-5FD21DEC0538"
    MyPropertyA = "Foo"
}
await mongoClient.SaveDocument(myClassObj.ToBsonDocument());

This is what ends up in the mongo database (retrieved with mongo cli):

{ "_id" : BinData(3,"gEFqxapl7EKpRV/SHewFOA=="), "MyPropertyA": "Foo" }

This is what is rendered in the collection view:

mongodb guid error

And I cannot open the document. The error message is Document not found!.

I'm not sure if this is an error with mongo, mongo-express or C# Guids. I'm still learning and would appreciate some insights.

Invalid query type when trying to edit a document

I use the last 0.54 version and I got an error when i tried to edit a document.
To reproduce this issue:

  • made a 'simple' query to filter documents
  • then click on one document
  • the error appears and we can't edit the document

image

Installation using Portainer's "Build Image" feature not workin

Portainer has a Build Image feature, where you just copy-paste the Dockerfile; however, it fails with the following warning:
`Step 1/11 : FROM node:12-alpine3.11

---> 0206ff8a5f9e
Step 2/11 : RUN apk add --no-cache bash tini

---> Running in 53f531dc9a3e
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.11/community/x86_64/APKINDEX.tar.gz
(1/5) Installing ncurses-terminfo-base (6.1_p20200118-r4)
(2/5) Installing ncurses-libs (6.1_p20200118-r4)
(3/5) Installing readline (8.0.1-r0)
(4/5) Installing bash (5.0.11-r1)
Executing bash-5.0.11-r1.post-install
(5/5) Installing tini (0.18.0-r0)
Executing busybox-1.31.1-r9.trigger
OK: 9 MiB in 21 packages
Removing intermediate container 53f531dc9a3e
---> 8fb0ba29415f
Step 3/11 : EXPOSE 8081

---> Running in f7f64d31e24a
Removing intermediate container f7f64d31e24a
---> 7922283359db
Step 4/11 : ENV ME_CONFIG_EDITORTHEME="default" ME_CONFIG_MONGODB_SERVER="mongo" ME_CONFIG_MONGODB_ENABLE_ADMIN="true" ME_CONFIG_BASICAUTH_USERNAME="" ME_CONFIG_BASICAUTH_PASSWORD="" VCAP_APP_HOST="0.0.0.0"

---> Running in 98aeabc079e1
Removing intermediate container 98aeabc079e1
---> 1c10376b2b57
Step 5/11 : ENV MONGO_EXPRESS 0.54.0

---> Running in f30fbb3d6fda
Removing intermediate container f30fbb3d6fda
---> 9e787c2e4c75
Step 6/11 : RUN set -eux; apk add --no-cache --virtual .me-install-deps git; npm install mongo-express@$MONGO_EXPRESS; apk del --no-network .me-install-deps

---> Running in 9e3bbe13687a

[email protected] postinstall /node_modules/mongo-express
patch-package
patch-package 6.2.2
Applying patches...
Error: Patch file found for package mongodb-query-parser which is not present at node_modules/mongodb-query-parser
npm WARN saveError ENOENT: no such file or directory, open '/package.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN
notsup Unsupported engine for [email protected]: wanted: {"node":">=0.10.0 <7"} (current: {"node":"12.20.1","npm":"6.14.10"})
npm
WARN notsup Not compatible with your version of node/npm: [email protected]
npm WARN enoent
ENOENT: no such file or directory, open '/package.json'
npm WARN !invalid#1 No description
npm WARN !invalid#1 No repository field.
npm WARN !invalid#1 No README data
npm WARN
!invalid#1 No license field.

  • [email protected]
    added 417 packages from 214 contributors and audited 417 packages in 19.327s

3 packages are looking for funding
run npm fund for details
found 7 vulnerabilities (2 low, 2 high, 3 critical)
run npm audit fix to fix them, or npm audit for details

  • apk del --no-network .me-install-deps
    WARNING: Ignoring APKINDEX.70f61090.tar.gz: No such file or directory
    WARNING: Ignoring APKINDEX.ca2fea5b.tar.gz: No such file or directory
    (1/7) Purging .me-install-deps (20210209.103007)
    (2/7) Purging git (2.24.3-r0)
    (3/7) Purging libcurl (7.67.0-r3)
    (4/7) Purging ca-certificates (20191127-r2)
    Executing ca-certificates-20191127-r2.post-deinstall
    (5/7) Purging nghttp2-libs (1.40.0-r1)
    (6/7) Purging expat (2.2.9-r1)
    (7/7) Purging pcre2 (10.34-r1)
    Executing busybox-1.31.1-r9.trigger
    OK: 9 MiB in 21 packages
    Removing intermediate container 9e3bbe13687a
    ---> 847a753fcc19
    Step 7/11 : COPY docker-entrypoint.sh /

COPY failed: file not found in build context or excluded by .dockerignore: stat docker-entrypoint.sh: file does not exist`

wait for db port to be available

When starting a mongo-express container, with environment variable ME_CONFIG_MONGODB_SERVER set, at the same time as a mongo container, mongo-express eventually fails to start due to failing to connect to mongo.

It would be nice if the mongo-express container could wait retry a few times in such case before eventually failing after a timeout.


mongoexpress_1   | Welcome to mongo-express
mongoexpress_1   | ------------------------
mongoexpress_1   |
mongoexpress_1   |
mongoexpress_1   | Mongo Express server listening at http://0.0.0.0:8081
mongoexpress_1   | Server is open to allow connections from anyone (0.0.0.0)
mongoexpress_1   | basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
mongoexpress_1   |
mongoexpress_1   | /node_modules/mongodb/lib/server.js:265
mongoexpress_1   |         process.nextTick(function() { throw err; })
mongoexpress_1   |                                       ^
mongoexpress_1   | MongoError: failed to connect to server [db:27017] on first connect
mongoexpress_1   |     at Pool.<anonymous> (/node_modules/mongodb-core/lib/topologies/server.js:326:35)
mongoexpress_1   |     at emitOne (events.js:116:13)
mongoexpress_1   |     at Pool.emit (events.js:211:7)
mongoexpress_1   |     at Connection.<anonymous> (/node_modules/mongodb-core/lib/connection/pool.js:270:12)
mongoexpress_1   |     at Object.onceWrapper (events.js:317:30)
mongoexpress_1   |     at emitTwo (events.js:126:13)
mongoexpress_1   |     at Connection.emit (events.js:214:7)
mongoexpress_1   |     at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:175:49)
mongoexpress_1   |     at Object.onceWrapper (events.js:315:30)
mongoexpress_1   |     at emitOne (events.js:116:13)
mv-rapport-commun-recette_mongoexpress_1 exited with code 1

Authentication failed.

Waiting for 192.168.150.31:27017...
,Welcome to mongo-express
,------------------------
,
,
,Mongo Express server listening at http://0.0.0.0:8081
,Server is open to allow connections from anyone (0.0.0.0)
,Database connected
,{ MongoError: Authentication failed.
, 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. (/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)
, name: 'MongoError',
, message: 'Authentication failed.',
, ok: 0,
, errmsg: 'Authentication failed.',
, code: 18,
, codeName: 'AuthenticationFailed' }
,Admin Database connected
,unable to list databases
,{ MongoError: command listDatabases requires authentication
, 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. (/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)
, name: 'MongoError',
, message: 'command listDatabases requires authentication',
, ok: 0,
, errmsg: 'command listDatabases requires authentication',
, code: 13,
, codeName: 'Unauthorized' }
,

MongoError: failed to connect to server [mongo:27017] on first connect

version: '3'
services:

  mongodb:
    image: mongo
    restart: always

  mongo-express:
    image: mongo-express
    restart: always
    ports:
      - 8081:8081

os: mac

image

log

➜  docker-buff git:(master) ✗ docker-compose up --force-recreate --build
Recreating docker-buff_mongodb_1       ... done
Recreating docker-buff_mongo-express_1 ... done
Attaching to docker-buff_mongodb_1, docker-buff_mongo-express_1
mongodb_1        | 2019-08-01T13:13:36.797+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
mongo-express_1  | Waiting for mongo:27017...
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=4ab148edbc7b
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten] db version v4.0.11
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten] git version: 417d1a712e9f040d54beca8e4943edce218e9a8c
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten] allocator: tcmalloc
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten] modules: none
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten] build environment:
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten]     distmod: ubuntu1604
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten]     distarch: x86_64
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten]     target_arch: x86_64
mongodb_1        | 2019-08-01T13:13:36.800+0000 I CONTROL  [initandlisten] options: { net: { bindIpAll: true } }
mongo-express_1  | /docker-entrypoint.sh: line 14: mongo: Name does not resolve
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongodb_1        | 2019-08-01T13:13:36.801+0000 I STORAGE  [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
mongodb_1        | 2019-08-01T13:13:36.801+0000 I STORAGE  [initandlisten]
mongodb_1        | 2019-08-01T13:13:36.801+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
mongodb_1        | 2019-08-01T13:13:36.801+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
mongodb_1        | 2019-08-01T13:13:36.801+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=487M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
mongodb_1        | 2019-08-01T13:13:37.570+0000 I STORAGE  [initandlisten] WiredTiger message [1564665217:570928][1:0x7f4f04268a80], txn-recover: Main recovery loop: starting at 2/4992 to 3/256
mongodb_1        | 2019-08-01T13:13:37.682+0000 I STORAGE  [initandlisten] WiredTiger message [1564665217:682082][1:0x7f4f04268a80], txn-recover: Recovering log 2 through 3
mongodb_1        | 2019-08-01T13:13:37.755+0000 I STORAGE  [initandlisten] WiredTiger message [1564665217:754999][1:0x7f4f04268a80], txn-recover: Recovering log 3 through 3
mongo-express_1  | Thu Aug  1 13:13:37 UTC 2019 retrying to connect to mongo:27017 (2/5)
mongo-express_1  | /docker-entrypoint.sh: line 14: mongo: Name does not resolve
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongodb_1        | 2019-08-01T13:13:37.818+0000 I STORAGE  [initandlisten] WiredTiger message [1564665217:818295][1:0x7f4f04268a80], txn-recover: Set global recovery timestamp: 0
mongodb_1        | 2019-08-01T13:13:37.834+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0)
mongodb_1        | 2019-08-01T13:13:37.844+0000 I CONTROL  [initandlisten]
mongodb_1        | 2019-08-01T13:13:37.844+0000 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
mongodb_1        | 2019-08-01T13:13:37.844+0000 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
mongodb_1        | 2019-08-01T13:13:37.844+0000 I CONTROL  [initandlisten]
mongodb_1        | 2019-08-01T13:13:37.865+0000 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
mongodb_1        | 2019-08-01T13:13:37.867+0000 I NETWORK  [initandlisten] waiting for connections on port 27017
mongo-express_1  | Thu Aug  1 13:13:38 UTC 2019 retrying to connect to mongo:27017 (3/5)
mongo-express_1  | /docker-entrypoint.sh: line 14: mongo: Name does not resolve
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express_1  | Thu Aug  1 13:13:39 UTC 2019 retrying to connect to mongo:27017 (4/5)
mongo-express_1  | /docker-entrypoint.sh: line 14: mongo: Name does not resolve
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express_1  | Thu Aug  1 13:13:40 UTC 2019 retrying to connect to mongo:27017 (5/5)
mongo-express_1  | /docker-entrypoint.sh: line 14: mongo: Name does not resolve
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express_1  | Welcome to mongo-express
mongo-express_1  | ------------------------
mongo-express_1  |
mongo-express_1  |
mongo-express_1  | Mongo Express server listening at http://0.0.0.0:8081
mongo-express_1  | Server is open to allow connections from anyone (0.0.0.0)
mongo-express_1  | basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
mongo-express_1  |
mongo-express_1  | /node_modules/mongodb/lib/server.js:265
mongo-express_1  |         process.nextTick(function() { throw err; })
mongo-express_1  |                                       ^
mongo-express_1  | MongoError: failed to connect to server [mongo:27017] on first connect
mongo-express_1  |     at Pool.<anonymous> (/node_modules/mongodb-core/lib/topologies/server.js:326:35)
mongo-express_1  |     at emitOne (events.js:116:13)
mongo-express_1  |     at Pool.emit (events.js:211:7)
mongo-express_1  |     at Connection.<anonymous> (/node_modules/mongodb-core/lib/connection/pool.js:270:12)
mongo-express_1  |     at Object.onceWrapper (events.js:317:30)
mongo-express_1  |     at emitTwo (events.js:126:13)
mongo-express_1  |     at Connection.emit (events.js:214:7)
mongo-express_1  |     at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:175:49)
mongo-express_1  |     at Object.onceWrapper (events.js:315:30)
mongo-express_1  |     at emitOne (events.js:116:13)
mongo-express_1  | Thu Aug  1 13:13:49 UTC 2019 retrying to connect to mongo:27017 (2/5)
mongo-express_1  | /docker-entrypoint.sh: line 14: mongo: Name does not resolve
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express_1  | Thu Aug  1 13:13:50 UTC 2019 retrying to connect to mongo:27017 (3/5)
mongo-express_1  | /docker-entrypoint.sh: line 14: mongo: Name does not resolve
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express_1  | Thu Aug  1 13:13:51 UTC 2019 retrying to connect to mongo:27017 (4/5)
mongo-express_1  | /docker-entrypoint.sh: line 14: mongo: Name does not resolve
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express_1  | Thu Aug  1 13:13:52 UTC 2019 retrying to connect to mongo:27017 (5/5)
mongo-express_1  | /docker-entrypoint.sh: line 14: mongo: Name does not resolve
mongo-express_1  | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express_1  | Welcome to mongo-express
mongo-express_1  | ------------------------
mongo-express_1  |
mongo-express_1  |
mongo-express_1  | Mongo Express server listening at http://0.0.0.0:8081
mongo-express_1  | Server is open to allow connections from anyone (0.0.0.0)
mongo-express_1  | basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!
mongo-express_1  |
mongo-express_1  | /node_modules/mongodb/lib/server.js:265
mongo-express_1  |         process.nextTick(function() { throw err; })
mongo-express_1  |                                       ^
mongo-express_1  | MongoError: failed to connect to server [mongo:27017] on first connect
mongo-express_1  |     at Pool.<anonymous> (/node_modules/mongodb-core/lib/topologies/server.js:326:35)
mongo-express_1  |     at emitOne (events.js:116:13)
mongo-express_1  |     at Pool.emit (events.js:211:7)
mongo-express_1  |     at Connection.<anonymous> (/node_modules/mongodb-core/lib/connection/pool.js:270:12)
mongo-express_1  |     at Object.onceWrapper (events.js:317:30)
mongo-express_1  |     at emitTwo (events.js:126:13)
mongo-express_1  |     at Connection.emit (events.js:214:7)
mongo-express_1  |     at Socket.<anonymous> (/node_modules/mongodb-core/lib/connection/connection.js:175:49)
mongo-express_1  |     at Object.onceWrapper (events.js:315:30)
mongo-express_1  |     at emitOne (events.js:116:13)
docker-buff_mongo-express_1 exited with code 1
^CGracefully stopping... (press Ctrl+C again to force)
Stopping docker-buff_mongodb_1         ... done
Stopping docker-buff_mongo-express_1   ... done
➜  docker-buff git:(master) ✗

mongodb mongo-express docker-compose.yml

Pulling mongo (mongo:3.6.22-xenial)...
3.6.22-xenial: Pulling from library/mongo
4007a89234b4: Pull complete
5dfa26c6b9c9: Pull complete
0ba7bf18aa40: Pull complete
4c6ec688ebe3: Pull complete
6e27db06de4c: Pull complete
bbecf0ce3761: Pull complete
ce97543d924d: Pull complete
7299669aa5f5: Pull complete
e5fda94ce451: Pull complete
3673227c8d34: Pull complete
4bb718560867: Pull complete
c687b7b215c2: Pull complete
858fb3568c68: Pull complete
Digest: sha256:0a514a1da4da907230f62b9feac783d7cfe601ea51cba33398402f171c359256
Status: Downloaded newer image for mongo:3.6.22-xenial
Pulling mongo-express (mongo-express:0.54.0)...
0.54.0: Pulling from library/mongo-express
e95f33c60a64: Pull complete
8ad47429afec: Pull complete
ed32558722b1: Pull complete
b1f8c696047a: Pull complete
ac51d5cab64d: Pull complete
20aee6a49efa: Pull complete
8c46e74838a7: Pull complete
be294c44cfba: Pull complete
Digest: sha256:6ac0e6f0a7b2739a03fd29dc8c66853a57c527a2ba8b5ab7bfa7dae9ecbc7c92
Status: Downloaded newer image for mongo-express:0.54.0
Creating 2020-08-31-docker-compose_react-app_1 ... done
Creating mongo ... done
Creating 2020-08-31-docker-compose_api-server_1 ... done
Creating mongo-express ... done
Attaching to 2020-08-31-docker-compose_react-app_1, mongo, mongo-express, 2020-08-31-docker-compose_api-server_1
react-app_1 | yarn run v1.22.5
react-app_1 | $ react-scripts start
mongo | 2021-03-21T13:27:57.582+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=e37b3e3284d3
mongo | 2021-03-21T13:27:57.585+0000 I CONTROL [initandlisten] db version v3.6.22
mongo | 2021-03-21T13:27:57.588+0000 I CONTROL [initandlisten] git version: 62d9f36d148e4dacfec1ca8fcb110f1cc410336f
mongo | 2021-03-21T13:27:57.590+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
mongo | 2021-03-21T13:27:57.594+0000 I CONTROL [initandlisten] allocator: tcmalloc
mongo | 2021-03-21T13:27:57.594+0000 I CONTROL [initandlisten] modules: none
mongo | 2021-03-21T13:27:57.594+0000 I CONTROL [initandlisten] build environment:
mongo | 2021-03-21T13:27:57.594+0000 I CONTROL [initandlisten] distmod: ubuntu1604
mongo-express | Waiting for mongo:27017...
mongo | 2021-03-21T13:27:57.594+0000 I CONTROL [initandlisten] distarch: x86_64
mongo | 2021-03-21T13:27:57.594+0000 I CONTROL [initandlisten] target_arch: x86_64
mongo | 2021-03-21T13:27:57.594+0000 I CONTROL [initandlisten] options: { net: { bindIpAll: true }, security: { authorization: "enabled" } }
mongo | 2021-03-21T13:27:57.594+0000 W - [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
mongo | 2021-03-21T13:27:57.598+0000 I - [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
mongo | 2021-03-21T13:27:57.599+0000 W STORAGE [initandlisten] Recovering data from the last clean checkpoint.
mongo | 2021-03-21T13:27:57.599+0000 I STORAGE [initandlisten]
mongo | 2021-03-21T13:27:57.599+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
mongo | 2021-03-21T13:27:57.599+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
mongo | 2021-03-21T13:27:57.599+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=2580M,cache_overflow=(file_max=0M),session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),compatibility=(release="3.0",require_max="3.0"),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
mongo | 2021-03-21T13:28:01.855+0000 E STORAGE [initandlisten] WiredTiger error (-31802) [1616333281:855857][1:0x7f0493415a40], connection: __log_open_verify, 1028: Version incompatibility detected: unsupported WiredTiger file version: this build requires a maximum version of 2, and the file is version 3: WT_ERROR: non-specific WiredTiger error Raw: [1616333281:855857][1:0x7f0493415a40], connection: __log_open_verify, 1028: Version incompatibility detected: unsupported WiredTiger file version: this build requires a maximum version of 2, and the file is version 3: WT_ERROR: non-specific WiredTiger error
mongo | 2021-03-21T13:28:01.856+0000 E STORAGE [initandlisten] An unsupported journal format detected - If you are trying to rollback from version 4.0 to 3.6, please re-start a 4.0 binary and cleanly shut it down so that the journal format will be downgraded.
mongo | 2021-03-21T13:28:01.894+0000 E - [initandlisten] Assertion: 28595:-31802: WT_ERROR: non-specific WiredTiger error src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 488
mongo | 2021-03-21T13:28:01.895+0000 I STORAGE [initandlisten] exception in initAndListen: Location28595: -31802: WT_ERROR: non-specific WiredTiger error, terminating
mongo | 2021-03-21T13:28:01.896+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets...
mongo | 2021-03-21T13:28:01.896+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
mongo | 2021-03-21T13:28:01.897+0000 I CONTROL [initandlisten] now exiting
mongo | 2021-03-21T13:28:01.897+0000 I CONTROL [initandlisten] shutting down with code:100
mongo exited with code 100
mongo-express | /docker-entrypoint.sh: line 14: mongo: Try again
mongo-express | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
api-server_1 | (node:1) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
api-server_1 | (Use node --trace-deprecation ... to show where the warning was created)
api-server_1 | Server running on port 5000
api-server_1 | Connection error failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
api-server_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
api-server_1 | name: 'MongoNetworkError'
api-server_1 | }]
api-server_1 | MongoDB connection error: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
api-server_1 | at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1146:16) {
api-server_1 | name: 'MongoNetworkError'
api-server_1 | }]
api-server_1 | at Pool. (/usr/src/app/node_modules/mongodb/lib/core/topologies/server.js:438:11)
api-server_1 | at Pool.emit (events.js:315:20)
api-server_1 | at /usr/src/app/node_modules/mongodb/lib/core/connection/pool.js:562:14
api-server_1 | at /usr/src/app/node_modules/mongodb/lib/core/connection/pool.js:995:11
api-server_1 | at /usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:31:7
api-server_1 | at callback (/usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:264:5)
api-server_1 | at Socket. (/usr/src/app/node_modules/mongodb/lib/core/connection/connect.js:294:7)
api-server_1 | at Object.onceWrapper (events.js:422:26)
api-server_1 | at Socket.emit (events.js:315:20)
api-server_1 | at emitErrorNT (internal/streams/destroy.js:106:8)
api-server_1 | at emitErrorCloseNT (internal/streams/destroy.js:74:3)
api-server_1 | at processTicksAndRejections (internal/process/task_queues.js:80:21)
mongo-express | Sun Mar 21 13:28:08 UTC 2021 retrying to connect to mongo:27017 (2/5)
react-app_1 | ℹ 「wds」: Project is running at http://172.22.0.2/
react-app_1 | ℹ 「wds」: webpack output is served from
react-app_1 | ℹ 「wds」: Content not from webpack is served from /usr/src/app/public
react-app_1 | ℹ 「wds」: 404s will fallback to /
react-app_1 | Starting the development server...
react-app_1 |
mongo-express | /docker-entrypoint.sh: line 14: mongo: Try again
mongo-express | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express | Sun Mar 21 13:28:14 UTC 2021 retrying to connect to mongo:27017 (3/5)
react-app_1 | Browserslist: caniuse-lite is outdated. Please run the following command: npx browserslist --update-db
mongo-express | /docker-entrypoint.sh: line 14: mongo: Try again
mongo-express | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express | Sun Mar 21 13:28:20 UTC 2021 retrying to connect to mongo:27017 (4/5)
mongo-express | /docker-entrypoint.sh: line 14: mongo: Try again
mongo-express | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express | Sun Mar 21 13:28:26 UTC 2021 retrying to connect to mongo:27017 (5/5)
mongo-express | /docker-entrypoint.sh: line 14: mongo: Try again
mongo-express | /docker-entrypoint.sh: line 14: /dev/tcp/mongo/27017: Invalid argument
mongo-express | Welcome to mongo-express
mongo-express | ------------------------
mongo-express |
mongo-express |
mongo-express | Mongo Express server listening at http://0.0.0.0:8081
mongo-express | Server is open to allow connections from anyone (0.0.0.0)
mongo-express |
mongo-express | /node_modules/mongodb/lib/server.js:265
mongo-express | process.nextTick(function() { throw err; })
mongo-express | ^
mongo-express | Error [MongoError]: failed to connect to server [mongo:27017] on first connect
mongo-express | at Pool. (/node_modules/mongodb-core/lib/topologies/server.js:326:35)
mongo-express | at Pool.emit (events.js:314:20)
mongo-express | at Connection. (/node_modules/mongodb-core/lib/connection/pool.js:270:12)
mongo-express | at Object.onceWrapper (events.js:421:26)
mongo-express | at Connection.emit (events.js:314:20)
mongo-express | at Socket. (/node_modules/mongodb-core/lib/connection/connection.js:175:49)
mongo-express | at Object.onceWrapper (events.js:421:26)
mongo-express | at Socket.emit (events.js:314:20)
mongo-express | at emitErrorNT (internal/streams/destroy.js:92:8)
mongo-express | at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
mongo-express exited with code 1
react-app_1 | Compiled with warnings.
react-app_1 |
react-app_1 | ./src/components/Logo.jsx
react-app_1 | Line 14:17: img elements must have an alt prop, either with meaningful text, or an empty string for decorative images jsx-a11y/alt-text
react-app_1 |
react-app_1 | Search for the keywords to learn more about each warning.
react-app_1 | To ignore, add // eslint-disable-next-line to the line before.
react-app_1 |

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.