Search posts, tags, users, and pages
That can't be it, it fails on Docker Hub.
Emil Moe did you clear the cache? and
ln -sf /dev/stdout /var/log/mysqld.err
shouldn't you also pipe stderr?
Emil Moe also just splitt the whole thing into run commands so you can see what's going wrong? The && chain is nifty but it also hides the position of the error.
I can see this error occurs in the log
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Even with this added to a config
socket=/var/lib/mysql/mysql.sock
---> Running in fc9a9ce9c90f
[91mmysql_secure_installation: [Warning] Using a password on the command line interface can be insecure.
[0m
Securing the MySQL server deployment.
Error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Removing intermediate container fc9a9ce9c90f
The command '/bin/sh -c mysql_secure_installation --use-default --password=123456' returned a non-zero code: 1
I guess that warning kills it
Emil Moe just pipe the password in an extra file and use that? as a pragmatic workaround
&& echo "[mysql]\npassword=123456" > passwordfile && /bin/sh -c mysql_secure_installation --use-default --defaults-file=passwordfile
or something similar
It still fails
The command '/bin/sh -c echo "[mysql]\npassword=123456" > passwordfile && /bin/sh -c mysql_secure_installation --use-default --defaults-file=passwordfile' returned a non-zero code: 1
It feels like Docker made an explicit rule that MySQL should fail 🤔
Emil Moe lol :D na you could be pragmatic and just echo the password in the my.cnf :D but as a devops guy I didn't want to go there.
also i could've give you the wrong version of commands I did look up the mysql 8 documention in the end
I succeeds if I remove the whole password part, so at least I have isolated the issue
I solved out the mystery, I need to run all these commands after the container is created. So during creation I store the init script in a file, when "booting" I check that the init script exists, if it does i run it and delete, so next time it won't be run.