Skip to content
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

Use of Environment Variables MYSQL_DATABASE - has no effect #448

Closed
fkaminski opened this issue Dec 28, 2018 · 10 comments
Closed

Use of Environment Variables MYSQL_DATABASE - has no effect #448

fkaminski opened this issue Dec 28, 2018 · 10 comments
Assignees

Comments

@fkaminski
Copy link

fkaminski commented Dec 28, 2018

ISSUE TYPE

  • Feature request

SUMMARY

I am using the "docker-volumes" branch with "Docker Toolbox v18.09.0" -
tested with Windows 7/10 Home.

The "mysql-5.7" Server Image is set in the ".env" file.

For the mysql service the MYSQL_ROOT_PASSWORD is already in use.
I have tried to set the MYSQL_DATABASE variable in the docker-compose.yml for testing purpose like:

mysql:
  environment:
    - MYSQL_DATABASE=db_devilbox

to create a default database on start,
so i do not need to create a database manually - see:

https://hub.docker.com/_/mysql
https://hub.docker.com/_/mariadb

Unfortunately, this has no effect at all.
When i start the container with "docker-compose up -d httpd php mysql"
there is no database "db_devilbox" created - checked via phpMyAdmin.

Goal

Use of the MYSQL_DATABASE variable in ".env" / "docker-compose.yml" for the mysql service to create a default database on container/service start.

@fkaminski
Copy link
Author

Think that the variable is just not present in the provided images:
( sorry for my english )

https://github.com/cytopia/docker-mysql-5.7
https://github.com/cytopia/docker-mariadb-10.3

compared to the original mysql image on "Docker Hub" ...

@cytopia
Copy link
Owner

cytopia commented Dec 28, 2018

Yes, by the time I've done the initial work for the Devilbox, PerconaDB was not yet available as an official Docker image.

As it is now, it is time to move MySQL, MariaDB and PerconaDB to official images. I first need to ensure that they do offer all the currently implemented functionality and have the same sets of injectable variable names,

@cytopia cytopia self-assigned this Dec 28, 2018
@fkaminski
Copy link
Author

I see - thanks and greetings form Bremen to Berlin ...

@cytopia
Copy link
Owner

cytopia commented Jan 2, 2019

I had a look at all three Docker images (MySQL, MariaDB and PerconaDB), they are all built the same way and use the same set of Volumes and Variables.

However I will have to create my own Docker Images out of those, simply by the way the tags are organized as I am unable to do something like this:

#MYSQL_SERVER=mysql:5.5
#MYSQL_SERVER=mysql:5.6
#MYSQL_SERVER=mysql:5.7
#MYSQL_SERVER=mysql:8.0
#MYSQL_SERVER=mariadb:5.5
#MYSQL_SERVER=mariadb:10.0
#MYSQL_SERVER=mariadb:10.1
#MYSQL_SERVER=mariadb:10.2
MYSQL_SERVER=mariadb:10.3
#MYSQL_SERVER=percona:5.5
#MYSQL_SERVER=percona:5.6
#MYSQL_SERVER=percona:5.7

The issue is with the : (colon) in the name, which will be invalid for Docker Compose variables. So I will simply copy all of them to a single repository and push them by the following TAG structure:

# Repository: devilbox/mysql
# Example Tag: percona-5.6

# Env file then as currently:
#MYSQL_SERVER=mysql-5.5
#MYSQL_SERVER=mysql-5.6
#MYSQL_SERVER=mysql-5.7
#MYSQL_SERVER=mysql-8.0
#MYSQL_SERVER=mariadb-5.5
#MYSQL_SERVER=mariadb-10.0
#MYSQL_SERVER=mariadb-10.1
#MYSQL_SERVER=mariadb-10.2
MYSQL_SERVER=mariadb-10.3
#MYSQL_SERVER=percona-5.5
#MYSQL_SERVER=percona-5.6
#MYSQL_SERVER=percona-5.7

This way I can preserve the same current structure I have.

@cytopia
Copy link
Owner

cytopia commented Jan 9, 2019

@fkaminski this one might be interesting to you how to add official MySQL to the stack and make use of the desired variables: #466

@cytopia
Copy link
Owner

cytopia commented Feb 8, 2019

@fkaminski official MySQL images will be integrated into the Devilbox shortly.

cytopia added a commit that referenced this issue Feb 12, 2019
* Refs #175, Refs #382 Use Docker volumes instead of data directories

* Ensure default values are used for mounted data directories as well

* Update container versions

* Remove unecessary data dirs

* Ensure mail uses a Docker volume

* Clean up docker-compose.yml

* Adjust project files: CHANGELOG, CONTRIBUTING and UPDATING

* Refs: #501 #448 Use Official MySQL, MariaDB and Percona images

* Ensure Docker Compose examples use Docker volumes

* Fix gitignore

* Bump version

* Update Changelog

* Update container versions

* Ensure mail uses a Docker volume

* Refs: #501 #448 Use Official MySQL, MariaDB and Percona images

* Ensure Docker Compose examples use Docker volumes

* Fix gitignore

* Bump version

* Update Changelog

* Fix Docker image update script

* Remove obsolete configuration directories

* Bump version date

* Fix fetching Memcached keys

* Show the usage of Docker volumes in intranet

* Be more verbose on connection tests
@cytopia
Copy link
Owner

cytopia commented Feb 12, 2019

@fkaminski could you try out the release branch: #416 Please pay special attention to the instructions in the PR description.

@cytopia
Copy link
Owner

cytopia commented Mar 2, 2019

@fkaminski please let me now if this works out for you now with the above mentioned branch.

@fkaminski
Copy link
Author

Hi, with this branch a database will be generated with the settings mentioned above ( tested with mysql 5.7 ). So this works now as expected. Thank you.

I've set the Variable within the docker-compose-override.yml or within an own my-project1.yml file - see:
https://docs.docker.com/compose/extends/

However this only works once, or rather as long as no db Volume is present.
To use multiple databases with an existing volume, they must be created manually afterwards - I think ...

@cytopia
Copy link
Owner

cytopia commented Mar 5, 2019

That's good news. And yes I can confirm that this only works for a single database. It's a limitation of the official MySQL images, which I can't do anything about it.

So I will close this issue then.

@cytopia cytopia closed this as completed Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants