Hope you're all doing well. I'm encountering something I'm a little suprised by. I don't know if I'm not asking the question right, or what but I have not been able to find someone who is experiencing this circumstance (which seems strange to me).
I've configured a docker configuration (docker-compose.yml) that includes credentials for the user in the mongo-express environment. I am not encountering any error, but it won't let me use the credentials I've configured. Instead of getting rejection message or error, it's just clearing the credentials I've entered and it is not doing anything.
Below you will find the YML file I've used to configure the different images. You can find the complete body of code here
Please see the YML file below:
version: '3'
services:
frontend:
restart: always
build: ./frontend
ports:
- '3000:3000'
volumes:
- /app/node_modules
- ./frontend:/app
environment:
- CHOKIDAR_USEPOLLING=true
api:
restart: always
build: ./api
ports:
- '5050:5050'
volumes:
- ./api:/app
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: very-strong-db-password
volumes:
- mongodb_data:/data/db
mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_SERVER: mongo
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: very-strong-db-password
depends_on:
- mongo
volumes:
mongodb_data:
You might have seen something like this in the logs:
That indicates that Mongo Express is still using the default credentials for HTTP authentication.
You can change these with the
ME_CONFIG_BASICAUTH_USERNAMEandME_CONFIG_BASICAUTH_PASSWORDenvironment variables.Revised
docker-compose.yml:I have not specified a new username for HTTP authentication (so just use the default
admin) but have put in a cryptic one for the password. You can change the username too if you wish.