我在 Ubuntu 19.04 发行版上运行并且有一个 Dockerfile,当我们到达第 7 步时;
Step 7/11 : RUN (/usr/bin/mysqld_safe &); sleep 5; mysqladmin -u root -proot create wordpress
我们得到;
2019-10-09T12:18:34.365421Z mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
查看错误消息:mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
cookie@cookie-K501UX:~/code/docker$ ls -la /var/run/mysqld
total 8
drwxr-xr-x 2 mysql mysql 100 Oct 9 13:10 .
drwxr-xr-x 36 root root 1060 Oct 9 13:10 ..
-rw-r----- 1 mysql mysql 6 Oct 9 13:10 mysqld.pid
srwxrwxrwx 1 mysql mysql 0 Oct 9 13:10 mysqld.sock
-rw------- 1 mysql mysql 6 Oct 9 13:10 mysqld.sock.lock
确实如此。和Check that mysqld is running
$ sudo systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2019-10-09 13:26:21 BST; 8min ago
这是。如果套接字文件存在并且 MySQL 守护程序正在运行 - 有什么问题?
问题是您正在等待 5 秒,可能需要 6 秒或更多
在运行之前,
mysqladmin create wordpress
您必须检查 MYSQL 是否准备就绪。因此,您可以使用带有
mysqladmin ping
.所以
RUN
命令可以是Dockerfile
有关将编译的最新版本,请参见: