docker-compose mysql init sql is not executed

The docker-entrypoint-initdb.d folder will only be run once while the container is created (instantiated) so you actually have to do a docker-compose down -v to re-activate this for the next run.

If you want to be able to add sql files at any moment you can look here at a specialized MySql docker image... http://ivo2u.nl/o4

Update for M1 arch: Here an almost drop-in replacement in MariaDB: http://ivo2u.nl/V1


Many containerized applications, especially stateful ones, have a way of running init scripts (like the sql scripts here) and they are supposed to run only once.

And since they are stateful, the volumes are a source of truth for the containers on whether to run the init scripts or not on container restart.

Like in your case, deleting the folder used for bind mount or using a new named volume should re-run any init scripts present.