How can I create a mysql db with Docker compose?

Viewed 43716

I'm trying to host on docker an application which uses MySQL db. I'm using docker compose. my yml file looks like this:

version: '2'
volumes:
  data_sql:    
services:  
medical-mysql:
    image: mysql
    hostname: medical-mysql    
    volumes:    
     - data_sql:/dbcreation.sql
    environment:
      MYSQL_DATABASE: Medical
      MYSQL_ROOT_PASSWORD: root
      STARTUP_SQL: data_sql
    ports:
    - "3306:3306"
  medical-main:
    build: .
    ports:
     - "8080:8080"    
    depends_on:
     - medical-mysql

I have a dbcreation.sql which creates the db schema and is kept in the yml folder. When I run the yml file it seems as if the file is not running.

What have I missed?

2 Answers
Related