[英]Docker container - MYSQL_RANDOM_ROOT_PASSWORD not showing output in STDOUT
I am new to docker so this can be a noob question. 我是Docker的新手,所以这可能是一个菜鸟问题。
I would like to print out the root password for MySQL in stdout, to do it I did set: 我想在标准输出中打印出MySQL的root密码,要做的就是我设置的:
ENV MYSQL_RANDOM_ROOT_PASSWORD yes ENV MYSQL_RANDOM_ROOT_PASSWORD是
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. 基于手册https://dev.mysql.com/doc/refman/5.7/en/docker-mysql-more-topics.html#docker_var_mysql_random_root_password-密码被打印到容器的标准输出中,可以通过查看以下内容找到容器的日志,但看不到。
Here's link to my container: https://hub.docker.com/r/thk1/lamp 这是我的容器的链接: 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.
在Synology NAS服务器上运行容器时,可以使用DSM应用程序查看标准输出日志。 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).
但是当我通过执行docker build和docker run在Windows上运行容器,然后查看docker日志时,我什么也看不到(是的,当我检查日志时,容器正在运行)。
So my questions are - what am I doing wrong in case of the MYSQL_RANDOM_ROOT_PASSWORD and why I can't view logs? 所以我的问题是-如果使用MYSQL_RANDOM_ROOT_PASSWORD,我在做什么错?为什么我不能查看日志?
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": 我建议将其添加到您的“ 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. 通过这种方式,您可以设置密码并将其打印到docker日志中。
PS : the ENV you use will only works on mysql official image. PS :您使用的ENV仅适用于mysql官方映像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.