Featured image of post How to enable MongoDB authentication with docker-compose ?

How to enable MongoDB authentication with docker-compose ?

By default there is no authentication in MongoDB. It means that it comes with empty authentication. So we should create users and roles manually. There are lots of ways to create MongoDB docker-compose with authentication. The most popular one of them is to write a bash script with user and roles then use it in docker-compose and another way is to create an init-mongodb.js file with users and roles and use it in docker-compose. But in this post, I will show you how you could create MongoDB docker-compose and then add users and roles manually.