title: MongoDB + Mongo-Express docker-compose causing MongoError: Authentication failed
body: <p>I've been on this issue for hours now and I really don't know what else to do (and all the research I did didn't provide any solution unfortunately). So I'm asking if anyone can think of an answer why this is not working:</p>
  
  <p>I run a <strong>docker-compose file with mongo and mongo-express images</strong>. Using the default code provided <a href="https://hub.docker.com/_/mongo/" rel="noreferrer">here</a> didnt work ( mongo-express stopped with exit code 1) so I tried tons of configurations leaving me with the docker-compose file below ( that actually works to the degree that mongo-express gets started and shows </p>
  
  <p><strong><em>Databases:</em>   <em>admin</em></strong></p>
  
  <p><strong><em>Server Status:</em>
  <em>Turn on admin in config.js to view server stats!</em></strong></p>
  
  <p>displayed in the GUI). But from there nothing works. The console shows the problem:</p>
  
  <pre><code>mongoviewer_1  | Database connected
  database_1     | 2018-08-22T09:15:27.743+0000 I ACCESS   [conn2] SASL SCRAM-SHA-1 authentication failed for admin on admin from client; UserNotFound: Could not find user admin@admin
  
  mongoviewer_1  | unable to list databases
  mongoviewer_1  | { MongoError: command listDatabases requires authentication
  mongoviewer_1  |     at Function.MongoError.create (/node_modules/mongodb-core/lib/error.js:31:11)
  mongoviewer_1  |     at /node_modules/mongodb-core/lib/connection/pool.js:483:72
  mongoviewer_1  |     at authenticateStragglers (/node_modules/mongodb-core/lib/connection/pool.js:429:16)
  mongoviewer_1  |     at Connection.messageHandler (/node_modules/mongodb-core/lib/connection/pool.js:463:5)
  mongoviewer_1  |     at Socket.&lt;anonymous&gt; (/node_modules/mongodb-core/lib/connection/connection.js:319:22)
  mongoviewer_1  |     at emitOne (events.js:116:13)
  mongoviewer_1  |     at Socket.emit (events.js:211:7)
  mongoviewer_1  |     at addChunk (_stream_readable.js:263:12)
  mongoviewer_1  |     at readableAddChunk (_stream_readable.js:250:11)
  mongoviewer_1  |     at Socket.Readable.push (_stream_readable.js:208:10)
  mongoviewer_1  |   name: 'MongoError',
  mongoviewer_1  |   message: 'command listDatabases requires authentication',
  mongoviewer_1  |   ok: 0,
  mongoviewer_1  |   errmsg: 'command listDatabases requires authentication',
  mongoviewer_1  |   code: 13,
  mongoviewer_1  |   codeName: 'Unauthorized' }
  </code></pre>
  
  <p>The docker-compose looks like follows:</p>
  
  <pre><code>  database:
      image: mongo:latest
      environment:
        MONGO_INITDB_ROOT_USERNAME: admin
        MONGO_INITDB_ROOT_PASSWORD: password
        MONGO_INITDB_DATABASE: dockerdb
      ports:
      - "27017:27017"
    mongoviewer:
      image: mongo-express
      environment:
        ME_CONFIG_MONGODB_SERVER: database
        ME_CONFIG_BASICAUTH_USERNAME: ""
        ME_CONFIG_MONGODB_AUTH_DATABASE: admin
        ME_CONFIG_MONGODB_AUTH_USERNAME: admin
        ME_CONFIG_MONGODB_AUTH_PASSWORD: password
        ME_CONFIG_MONGODB_ADMINUSERNAME: admin
        ME_CONFIG_MONGODB_ADMINPASSWORD: password
      ports:
      - "8081:8081"
      links:
      - database
      depends_on:
      - database
  </code></pre>
  
  <p>That's the current version I was trying and I tried so many other configurations but nothing fixed the auth problem.</p>
  
  <p>If anyone has an answer or at least an idea on what to do I'd be extremely thankfull!</p>