-
-
Save nietzscheson/59c34ec87e225430e812d2f261162e3d 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