I'm setting up my first docker containers with mongo and mongo-express using the official docker-compose instructions e.g. something like this:

# Use root/example as user/password credentialsversion: '3.1'services:mongo:image: mongorestart: alwaysenvironment:MONGO_INITDB_ROOT_USERNAME: rootMONGO_INITDB_ROOT_PASSWORD: examplemongo-express:image: mongo-expressrestart: alwaysports:- 8081:8081environment:ME_CONFIG_MONGODB_ADMINUSERNAME: rootME_CONFIG_MONGODB_ADMINPASSWORD: exampleME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/

I can access mongo-express through my browser but there is no login screen it just loads all of the tables immediately - no authentication. Is there a way to configure mongo-express authentication to load a login screen to accept env vars in the docker-compose yml file and prevent immediate access to the tables?

1

Best Answer


The mongo docker container provides env vars to control access to admin panel via basic auth only. Other recommendations are to add your own via passport etc, so wouldnt use basic auth in production, but this works fine for testing small dbs.

  • ME_CONFIG_MONGODB_ENABLE_ADMIN
  • ME_CONFIG_BASICAUTH_USERNAME
  • ME_CONFIG_BASICAUTH_PASSWORD