My docker-compose.yml
mongo:
image: mongo
volumes:
- ./mongo:/data/db
ports:
- 27017:27017
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: pass
mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: pass
ME_CONFIG_MONGODB_URL: mongodb://root:pass@mongo:27017/
When I run docker-compose up it logs the following errors
for the mongo service: UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [mongo:27017] on first connect [MongoError: Authentication failed.
and for the mongo-express service: "error":"UserNotFound: Could not find user "root" for db "admin"
I tried adding ?authSource=admin to the ME_CONFIG_MONGODB_URL but the error remains.