I am running mongo docker using docker compose file with below configurations.
version: '3.1'
services:
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: some_password
ports:
- "127.0.0.1:27017:27017"
when I exec to mongo container and connect to mongodb through mongosh command without mentioning username and password its still connecting. Based on my understanding when authentication is enabled it should not connect to test database as well.
I am just started working with mongodb so please let me know if this is expected behavior or I am missing some configuration while creating container.