How can I create a mysql db with Docker compose?

后端 未结 2 1675
攒了一身酷
攒了一身酷 2021-01-31 20:06

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:             


        
2条回答
  •  孤街浪徒
    2021-01-31 20:21

    Simply just put your .sql file (dbcreation.sql) in a folder (ie. /mysql_init) and add the folder as a volume like this:

    volumes:
      - /mysql_init:/docker-entrypoint-initdb.d
    

    The MySQL image will execute all .sql, .sh and .sql.gz files in /docker-entrypoint-initdb.d on startup.

提交回复
热议问题