2

I'm running on an Ubuntu 19.04 distro and have a Dockerfile which when we reach step 7;

Step 7/11 : RUN (/usr/bin/mysqld_safe &); sleep 5; mysqladmin -u root -proot create wordpress

we get;

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!

Looking at the error message: 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

it does. And 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

it is. If the socket file exists and the MySQL daemon is running - what's the problem?

  • can you share the dockerfile , or only part of docker file from step 1 to 7 . – EchoMike444 Oct 10 at 0:20
  • Original Dockerfile was from here: https://github.com/how2dock/docbook/blob/master/ch01/supervisor/Dockerfile – cookie Oct 10 at 8:07
  • It just occurred to me that changing parameters for the Dockerfile breaks stuff - new to Docker. In my case, Ubuntu 19.04 and mysql is no bueno. Rather it should be more like Ubuntu 19.04 and mariadb. I've answered my own question essentially. – cookie Oct 10 at 8:11
  • I think the original repo is out-of-date slightly. I'll try to find an up-to-date Dockerfile config for a modern Wordpress install and post my findings. – cookie Oct 10 at 8:19
1

The issue is that you are waiting for 5 secs , and may be your need 6 secs or more

Before running mysqladmin create wordpress you must check if MYSQL is ready .

So you can use a loop with mysqladmin ping .

So the RUN command can be

RUN (/usr/bin/mysqld_safe &); \
     while( ! mysqladmin ping ) ;do  sleep 1 ; date ; done ; \
     mysqladmin -u root -proot create wordpress
  • Great. I'll take a look at that, thanks. – cookie Oct 11 at 7:28
0

For an up-to-date Dockerfile which will compile see:

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"]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.