title: Docker-compose mysql: import .sql
body: <p>My docker-compose script successfully manages to run a mysql/mariadb service, and copies my "init.sql" script containing the database schema to "/docker-entrypoint-initdb.d". However, the sql script is never executed like it should <a href="https://hub.docker.com/_/mariadb/" rel="nofollow noreferrer">according to the docs</a>.</p>
  
  <p>There is no error, nothing in the logs. I checked that the sql file is copied at the right place in the container. I checked that the script runs with no errors on an empty database.</p>
  
  <p>What am I missing? Is it even visible in the logs if the script was executed (and for some reason did nothing)?</p>
  
  <p>(<strong>Edit:</strong> docker-compose version: 1.8.1, image mariadb:10.1.21)</p>
  
  <pre><code># docker-compose.yml
  
  version: '2'
  volumes:
    data-volume: {}
  services:
    mysql:
      image: mariadb
      ports:
        - "3306:3306"
      environment:
        MYSQL_ROOT_PASSWORD: pwd
        MYSQL_DATABASE: users_db
      volumes:
        - data-volume:/var/lib/mysql
        - ./resources/docker-sql/init.sql:/docker-entrypoint-initdb.d/init.sql
    backend:
      image: myapp
      ports:
        - "8000:80"
      depends_on:
        - mysql
      links:
        - mysql
  </code></pre>