MariaDB doesn’t create configuration files when sharing a directory using volumes

Issue type: Docker, bind mounts/volumes
OS Version/build: Linux 5.3.0-59-generic #53~18.04.1-Ubuntu SMP Thu Jun 4 14:58:26 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
App version: Docker version 19.03.8, build afacb8b7f0
Image:

REPOSITORY       TAG         IMAGE ID          CREATED          SIZE
mariadb          10.5        af16a2dc06bd      6 weeks ago      365MB

I tried creating a container with a mariadb:10.5 image and bind mount for my configuration files.
Here’s the command:

sudo docker run -d --name database-mariadb1 \
-e MYSQL_ROOT_PASSWORD=XXX \
-p 9270:3306 \
-v "/opt/example/database/mariadb/mysql:/etc/mysql/" \
mariadb:10.5

The /opt/example/database/mariadb/mysql directory is empty, but when I tried creating a container without the bind mount, configuration files are created just fine.

I have NGINX, PHP, Certbot and SRCDS running under similar configurations (though they’re using docker-compose, but the same thing was happening when I tried to launch a mariadb container with it).

I tried just mounting the my.cnf configuration file like in MariaDB’s DockerHub page example, in a section “Using a custom MySQL configuration file”,

docker run --name some-mariadb -v /my/custom:/etc/mysql/conf.d -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mariadb:tag

but it kept creating a folder named my.cnf instead.

Also, after a container had been initialized and was running. I tried executing bash on the container and looking in the folder where the configuration files were supposed to be at, but they weren’t inside the container too.

Any help appreciated!