简体   繁体   English

Docker容器-MYSQL_RANDOM_ROOT_PASSWORD未在STDOUT中显示输出

[英]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.

相关问题 Docker-compose mysql 似乎无法识别环境变量 MYSQL_RANDOM_ROOT_PASSWORD - Docker-compose mysql does not seem to recognize environment variable MYSQL_RANDOM_ROOT_PASSWORD Docker Mysql容器root密码[mysqld侦听端口0] - Docker Mysql container root password [mysqld listens port 0] MYSQL_ROOT_PASSWORD 已设置但在 docker 容器中出现“用户 'root'@'localhost'(使用密码:YES)拒绝访问” - MYSQL_ROOT_PASSWORD is set but getting "Access denied for user 'root'@'localhost' (using password: YES)" in docker container 在 Docker 容器中更改 mysql 密码 - Change mysql password in Docker container 在docker容器中重置密码mysql - Reset password mysql in docker container mysql-docker-container - 错误 1045 (28000):用户 'root'@'localhost' 的访问被拒绝(使用密码:NO) - mysql-docker-container - ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) 为什么MySQL Docker容器抱怨使用Docker 17.03机密时必须定义MYSQL_ROOT_PASSWORD env? - Why does MySQL Docker container complain that MYSQL_ROOT_PASSWORD env must be defined when using Docker 17.03 secrets? Docker Compose - MySQL - MYSQL_ROOT_PASSWORD - Docker Compose - MySQL - MYSQL_ROOT_PASSWORD Docker中的MySQL冻结在root密码配置中 - MySQL in Docker frozen at root password config 以随机(非root)Linux用户身份运行预填充的Docker容器MySQL? - Run MySQL a prefilled docker container as random (non-root) linux user?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM