Problems with the behavior of MongoDB ARM version and Docker

Hello, trying to create a database with the following configuration of my docker compose:

The docker compose file:

    image: arm64v8/mongo
    ports:
    - 27017:27017
    environment:
      MONGO_INITDB_DATABASE: admin
      MONGO_INITDB_ROOT_USERNAME: root
      MONGO_INITDB_ROOT_PASSWORD: password
    volumes:
    - ./mongo/database:/data/db
    - ./mongo/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro

init-mongo.js:

db = db.getSiblingDB('admin');
db.auth("root", "password");

db = db.getSiblingDB('local')
db.createUser({
  user: 'root',
  pwd: 'password',
  roles: [{role: 'readWrite', db: `local`}]
});

db.createCollection('schema', {capped: false});

When try to launch the docker compose, for any reason the logs said me:

MongoServerError: Cannot create users in the local database

That’s happens when I don’t have a database created, after that error message mongo create the database but no with the expected user and database, and I am not sure what I am doing bad, my version of Mongo its 6.0.5 and I using the arm64 image in a Apple Laptop with M1 Chipset, any advice will be appreciated, thank you

Why you are choosing local db in step 2
You cannot create users in local db
You should give sample_db or test_db
In first step you are authenticating to admin db
In second step you are creating the db and user for this db

I choose local in the second step because I wanted use a database named local, I didn’t know not posible create users in that local database, and yes, I am authenticating as admin because in my journey of try to find the answer of this problem I read about that’s steps.

Its posible do users in a local database or avoid the creation by default of that database?

Thank you for your answer

@Adrian_Lagartera_Heras Don’t use the ARM MongoDB for the M1 chipset, use Rosetta.

You cannot and you should not use local db
Check the doc