Define mongodb migration inside docker-compose.yml on docker newest versions

Dear all,
i wonder how to launch mongodb first migration on db container starts?
Any suggestion?

Have you tried the image description?

When a container is started for the first time it will execute files with extensions .sh and .js that are found in /docker-entrypoint-initdb.d . Files will be executed in alphabetical order. .js files will be executed by mongosh (mongo on versions below 6) using the database specified by the MONGO_INITDB_DATABASE variable, if it is present, or test otherwise. You may also switch databases within the .js script.

You probably just need to mount your files into that folder. I don’t use mongodb, but this is similar to how it works in other database servers.