Please help, cannot map mariadb data folder

Dear all

I’m using Docker Toolbox on Windows 10

I can access the php part succesfully via http://192.168.99.100:8000, I have been working around with the mariadb part but still having several problems

I have an sql file as /mariadb/initdb/abc.sql so I should be copied into /docker-entrypoint-initdb.d, after the container is created I use docker-compose exec mariadb to access the container, there is the file as /docker-entrypoint-initdb.d/abc.sql but the file never get executed, I also have tested to import the sql file to the container manually, it was succesful so the sql file is valid

I don’t quite understand about the data folder mapping, and what to do to get the folder sync with the container, I always get the warning when recreate the container using docker-compose up -d

WARNING: Service "mariadb" is using volume "/var/lib/mysql" from the previous container. Host mapping "/mariadb/data" has no effect. Remove the existing containers (with docker-compose rm mariadb) to use the Recreating db ... done

Questions

  1. How to get the sql file in /docker-entrypoint-initdb.d to be executed ?
  2. What is the right way to map the data folder with the mariadb container ?

Please guide
Thanks

This is my docker-compose.yml

version: "3.2"

services:

    php:
        image: php:7.1-apache
        container_name: web
        restart: always
        volumes:
            - /php:/var/www/html
        ports:
            - "8000:80"

    mariadb:
        image: mariadb:latest
        container_name: db
        restart: always
        environment:
            - MYSQL_ROOT_PASSWORD=12345
        volumes:
            - /mariadb/initdb:/docker-entrypoint-initdb.d
            - /mariadb/data:/var/lib/mysql
        ports:
            - "3306:3306"