Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Couldn't access mongo-express from Docker

I am trying to carry out some experiments with Docker, MongoDB, and mongo-express.

Here was what I did:

docker network create my-network 
docker run -d -p 27017:27017 --network my-network --name my-mongo -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=pass mongo 
docker run -d -p 8081:8081   --network my-network --name my-mongo-express -e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" -e ME_CONFIG_MONGODB_SERVER="my-mongo" -e ME_CONFIG_BASICAUTH_USERNAME="admin" -e ME_CONFIG_BASICAUTH_PASSWORD="pass" mongo-express

No error message was received apparently.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

However, when I entered the address "localhost:8081" on Chrome, the page displayed an error message saying:

This page isn’t working
localhost didn’t send any data.
ERR_EMPTY_RESPONSE

How can I fix this?

>Solution :

You set the admin username and password on the database, but then you use the ‘normal’ user environment variables to try to log on. Instead of ME_CONFIG_BASICAUTH_USERNAME and ME_CONFIG_BASICAUTH_PASSWORD, you should use ME_CONFIG_MONGODB_ADMINUSERNAME and ME_CONFIG_MONGODB_ADMINPASSWORD, like this

docker run -d -p 8081:8081   --network my-network --name my-mongo-express -e ME_CONFIG_OPTIONS_EDITORTHEME="ambiance" -e ME_CONFIG_MONGODB_SERVER="my-mongo" -e ME_CONFIG_MONGODB_ADMINUSERNAME="admin" -e ME_CONFIG_MONGODB_ADMINPASSWORD="pass" mongo-express
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading