From ede9f9963dadf6499d5ec544702895a7b728558b Mon Sep 17 00:00:00 2001 From: Tyler Date: Sat, 8 Apr 2017 22:33:14 -0400 Subject: [PATCH 1/2] Updated MySQL docs re: _FILE env vars n/t --- mysql/content.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mysql/content.md b/mysql/content.md index 3d0afb43a..0b7575067 100644 --- a/mysql/content.md +++ b/mysql/content.md @@ -120,6 +120,14 @@ This is an optional variable. Set to `yes` to generate a random initial password Sets root (*not* the user specified in `MYSQL_USER`!) user as expired once init is complete, forcing a password change on first login. *NOTE*: This feature is supported on MySQL 5.6+ only. Using this option on MySQL 5.5 will throw an appropriate error during initialization. +## Docker Secrets + +As an alternative to passing sensitive information via environment variables, \_FILE may be appended to the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. In particular, this can be used to load passwords from Docker secrets stored in /run/secrets/ files. For example: + +```console +$ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql-root -d mysql:tag +``` + # Initializing a fresh instance When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions `.sh`, `.sql` and `.sql.gz` that are found in `/docker-entrypoint-initdb.d`. Files will be executed in alphabetical order. You can easily populate your %%REPO%% services by [mounting a SQL dump into that directory](https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-file-as-a-data-volume) and provide [custom images](https://docs.docker.com/reference/builder/) with contributed data. SQL files will be imported by default to the database specified by the `MYSQL_DATABASE` variable. From 9b10aacbc583976d9d6119a7f72f0c30d214640b Mon Sep 17 00:00:00 2001 From: Tyler Date: Mon, 10 Apr 2017 13:38:08 -0400 Subject: [PATCH 2/2] Add note about supported variables --- mysql/content.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql/content.md b/mysql/content.md index 0b7575067..49b9ffc8a 100644 --- a/mysql/content.md +++ b/mysql/content.md @@ -128,6 +128,8 @@ As an alternative to passing sensitive information via environment variables, \_ $ docker run --name some-mysql -e MYSQL_ROOT_PASSWORD_FILE=/run/secrets/mysql-root -d mysql:tag ``` +Currently, this is only supported for MYSQL_ROOT_PASSWORD, MYSQL_ROOT_HOST, MYSQL_DATABASE, MYSQL_USER, and MYSQL_PASSWORD. + # Initializing a fresh instance When a container is started for the first time, a new database with the specified name will be created and initialized with the provided configuration variables. Furthermore, it will execute files with extensions `.sh`, `.sql` and `.sql.gz` that are found in `/docker-entrypoint-initdb.d`. Files will be executed in alphabetical order. You can easily populate your %%REPO%% services by [mounting a SQL dump into that directory](https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-file-as-a-data-volume) and provide [custom images](https://docs.docker.com/reference/builder/) with contributed data. SQL files will be imported by default to the database specified by the `MYSQL_DATABASE` variable.