You set MONGO_INITDB_ROOT_USERNAME and MONGO_INITDB_ROOT_PASSWORD in Compose, start the official mongo image, and your app logs MongoServerError: Authentication failed. The password is right. You can see it in the container's environment.

Source: [Dev.to](https://dev.to/deploylark/mongodb-in-docker-fix-authentication-failed-and-init-scripts-47nm)

Sponsored