Created
August 21, 2018 08:07
-
-
Save MKagesawa/a03892b8c44c015cd991c2c5311f1768 to your computer and use it in GitHub Desktop.
Docker-compose MySQL Image create multiple databases
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The official MySQL (https://hub.docker.com/_/mysql/) supports only one MYSQL_DATABASE environment variable. | |
# By modifying the entrypoint and passing shell script, you can create multiple dbs without having to make a mysql image just for this purpose. | |
version: '3' | |
services: | |
# Some other service connecting to mysql | |
db: | |
image: mysql:5.6 | |
environment: | |
- MYSQL_USER=root | |
- MYSQL_ALLOW_EMPTY_PASSWORD=yes | |
entrypoint: | |
sh -c " | |
echo 'CREATE DATABASE IF NOT EXISTS firstDB; CREATE DATABASE IF NOT EXISTS secondDB;' > /docker-entrypoint-initdb.d/init.sql; | |
/usr/local/bin/docker-entrypoint.sh --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci | |
" | |
ports: | |
- 3306:3306 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
there is very well explained tutorial for the multiple databases found which works perfect
https://medium.com/@onexlab.io/docker-compose-mysql-multiple-database-fe640938e06b