Skip to content

Commit 1fee5fc

Browse files
committed
Updated readme for password from file
1 parent 5a1608f commit 1fee5fc

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ Most of the variables listed below are optional, but one of the variables `MYSQL
6464

6565
This variable specifies a password that will be set for the MySQL root superuser account. In the above example, it was set `to my-secret-pw`. **NOTE:** Setting the MySQL root user password on the command line is insecure. See the section *Secure Container Startup* below for an alternative.
6666

67+
As an alternative to specifying the password explicitly, if the variable is set to a file path, the contents of the file will be used as the root password.
68+
6769
## `MYSQL_RANDOM_ROOT_PASSWORD`
6870

6971
When this variable is set to `yes`, a random password for the server's root user will be generated. The password will be printed to stdout in the container, and it can be obtained by using the command `docker logs my-container-name`.
@@ -111,6 +113,10 @@ And finally, on the mysql client command line, set a new, secure root password f
111113

112114
ALTER USER root IDENTIFIED BY 'my-secret-pw';
113115

116+
An alternative is to use MYSQL_ROOT_PASSWORD, but set it to point to a file that contains the password. This provides better security than having the password on the command line and is easier to use in automated processes than the random password:
117+
118+
docker run --name my-container-name -e MYSQL_ROOT_PASSWORD=/tmp/password.txt -v mypasswordfile:/tmp/password.txt -e MYSQL_ONETIME_PASSWORD=yes -d mysql/mysql-server:tag
119+
114120
## Where to Store Data
115121

116122
There are basically two ways to store data used by applications that run in Docker containers. We encourage users of MySQL with Docker to familiarize themselves with the options available, including:
@@ -195,4 +201,4 @@ These images are officially supported by the MySQL team on Docker version 1.9. S
195201

196202
# User Feedback
197203

198-
We welcome your feedback! For general comments or discussion, please drop us a line in the Comments section below. For bugs and issues, please submit a bug report at http://bugs.mysql.com under the category "MySQL Package Repos and Docker Images".
204+
We welcome your feedback! For general comments or discussion, please drop us a line in the Comments section below. For bugs and issues, please submit a bug report at http://bugs.mysql.com under the category "MySQL Package Repos and Docker Images".

0 commit comments

Comments
 (0)