简体   繁体   中英

Docker container - MYSQL_RANDOM_ROOT_PASSWORD not showing output in STDOUT

I am new to docker so this can be a noob question.

I would like to print out the root password for MySQL in stdout, to do it I did set:

ENV MYSQL_RANDOM_ROOT_PASSWORD yes

Based on the manual https://dev.mysql.com/doc/refman/5.7/en/docker-mysql-more-topics.html#docker_var_mysql_random_root_password - The password is printed to stdout of the container and can be found by looking at the container's log but I don't see it.

Here's link to my container: https://hub.docker.com/r/thk1/lamp

I also have second problem. When I run the container on Synology NAS server I can see the stdout log by using DSM application. But when I run the container on my Windows by doing docker build and docker run, and then viewing docker logs I can't see anything (yes the container is running when I check the logs).

So my questions are - what am I doing wrong in case of the MYSQL_RANDOM_ROOT_PASSWORD and why I can't view logs?

If someone is offended by my questions because /put here whatever reason you want/ then remember that everyone learns and rather instead of biting, help me to be a better man. :)

I suggest to add this to your "run-lamp.sh":

PASS=`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 13 ; echo ''`
mysqladmin -u root password $PASS
echo "Root Password is $PASS"

in this way you setup and print the password to docker logs.

PS : the ENV you use will only works on mysql official image.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM