-
Notifications
You must be signed in to change notification settings - Fork 444
Support multiple databases creation #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Although your yaml syntax would not work, there was discussion of letting MYSQL_DATABASE be a space separated string of databases: docker-library/mysql#18. |
Keep in mind @visay, best practice would be to have a separate container for each application if that's what you're trying to do. Maybe your one application for some reason needs more than one database, though. |
+1 |
1 similar comment
+1 |
-1 the idea for docker is minimalism. one database per container. you can start multiple containers with different databases. |
@madalinignisca Probably ok during development. What about the additional resource required to run another container? And additional configurations needed, especially when I need a mysql cluster? |
You can make a simple Dockerfile using this one as the image source and just add your own extra env variables to add more databases to your service. Easy as that. The base one isn't supposed to cover all possible scenarios we think about, but to offer the foundation on which we build the solutions to our problems. Building it it might take an extra second or less ;) |
Reading the README file suggests
So adding your own .sql file should be able to create multiple databases. |
+1 |
Thanks, @amir20, that did it -- total duh moment LOL |
Just update startup file under mysql directory: DROP USER IF EXISTS 'MYSQL_USER'; |
What's the status of this issue? why is closed? |
@sirgalleto because you can already do it with our own script if they are mounted into See the description at https://hub.docker.com/_/mariadb/ section "Initializing a fresh instance" |
To my point of view it could be quite useful and should be reopened |
Created clear example of docker-compose with multiple databases, just use for your purposes: |
Take a look here: https://gist.github.com/MKagesawa/a03892b8c44c015cd991c2c5311f1768
|
@MKagesawa Thanks!!!! Although this alternative is a little hacky. You could use a config file for Swarm or a ConfigMap for Kubernetes in order to inject the init.sql |
ive got the same problem, so here my fix: https://hub.docker.com/r/ganjaaa/mariadb |
@amir20 But how many times does |
In my case, the |
Why should it be any different? Everything else in init is once only.
Useless for what requirement? Some "I want to create new database on the second startup"? Its sounding weird. Why not just created it using a SQL connection? If you really want to force this in the container:
|
Yeah, I guess I realized since then that my approach was wrong Im trying to have multiple database in a single container, but it makes much more sense to just create them outside of the container startup logic, from a (Btw just to clarify, I wasn't calling the whole |
If that's really the case, you should be using your application's
migrations mechanism instead. For example flyway https://flywaydb.org/ or
liquibase https://www.liquibase.org/
…On Wed, Apr 5, 2023, 10:31 Vincent Huss ***@***.***> wrote:
Why should it be any different? Everything else in init is once only.
Yeah, I guess I realized since then that my approach was wrong
Im trying to have multiple database in a single container, but it makes
much more sense to just create them outside of the container startup logic,
from a docker exec command or directly through a SQL GUI admin.
(Btw just to clarify, I wasn't calling the whole
/docker-entrypoint-initdb.d/init.sql functionality useless, only in the
context of using it to answer the problem discussed here)
—
Reply to this email directly, view it on GitHub
<#15 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABOMALFETSGFK7G2WCLQL2DW7UNWNANCNFSM4BJ2SMKA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Currently I only have the option to create only one database in my docker-compose.yml
It would be good if multiple databases is supported (something similar to this merge request in mysql https://github.com/docker-library/mysql/pull/18/files), so I can write:
The text was updated successfully, but these errors were encountered: