저는 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 데몬이 실행 중이라면 무엇이 문제입니까?
답변1
문제는 6초 이상이 필요할 수도 있는데 5초만 기다리고 있다는 점이다.
실행하기 전에 mysqladmin create wordpress
MYSQL이 준비되었는지 확인해야 합니다.
따라서 루프를 사용할 수 있습니다 mysqladmin ping
.
따라서 RUN
명령은 다음과 같습니다.
RUN (/usr/bin/mysqld_safe &); \
while( ! mysqladmin ping ) ;do sleep 1 ; date ; done ; \
mysqladmin -u root -proot create wordpress
답변2
Dockerfile
컴파일할 최신 버전은 다음을 참조하세요.
FROM ubuntu:19.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get -y install \
apache2 \
php7.2 \
php7.2-mysql \
supervisor \
wget
RUN echo 'mysql-server mysql-server/root_password password root' | debconf-set-selections && \
echo 'mysql-server mysql-server/root_password_again password root' | debconf-set-selections
RUN apt-get install -qqy mariadb-server
RUN wget http://wordpress.org/latest.tar.gz && \
tar xzvf latest.tar.gz && \
cp -R ./wordpress/* /var/www/html && \
rm /var/www/html/index.html
RUN (/usr/bin/mysqld_safe &); sleep 5; mysqladmin -u root -proot create wordpress
COPY wp-config.php /var/www/html/wp-config.php
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 80
CMD ["/usr/bin/supervisord"]