However, after docker restart, the container fails to start again.
The reason it always tries to initialize the database newly, even if it was already initialed the very first start.
"Cmd": [
"/bin/sh",
"-c",
"/usr/local/mysql/bin/mysqld --initialize --user=mysql && /usr/local/mysql/bin/mysqld_safe --user=mysql"]
After a restart, it fails to start with the following error
2021-05-19T10:59:44.931154Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.15) initializing of server in progress as process 8
2021-05-19T10:59:44.932740Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
2021-05-19T10:59:44.932749Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /usr/local/mysql/data/ is unusable. You can safely remove it.
2021-05-19T10:59:44.932791Z 0 [ERROR] [MY-010119] [Server] Aborting
Suggested fix:
Change CMD to "/usr/local/mysql/bin/mysqld --initialize --user=mysql; /usr/local/mysql/bin/mysqld_safe" with a semicolon instead of &&. This won't eliminate the error on 2nd start, but will also let the container continue to run successfully.
The Docker container image for mysql 8.x in Dockerhub (8.0.13) can be pulled and started on a IBM Z/IBM LinuxONE machine https://hub.docker.com/r/ibmcom/mysql-s390x
However, after docker restart, the container fails to start again.
The reason it always tries to initialize the database newly, even if it was already initialed the very first start. "Cmd": [ "/bin/sh", "-c", "/usr/local/mysql/bin/mysqld --initialize --user=mysql && /usr/local/mysql/bin/mysqld_safe --user=mysql"]
After a restart, it fails to start with the following error 2021-05-19T10:59:44.931154Z 0 [System] [MY-013169] [Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.15) initializing of server in progress as process 8 2021-05-19T10:59:44.932740Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting. 2021-05-19T10:59:44.932749Z 0 [ERROR] [MY-013236] [Server] Newly created data directory /usr/local/mysql/data/ is unusable. You can safely remove it. 2021-05-19T10:59:44.932791Z 0 [ERROR] [MY-010119] [Server] Aborting
Suggested workaround:
Substitute command inside of the container, e.g.
docker run --name=mysql1 -p 3306:3306 --restart on-failure --user=mysql -v /root/data:/usr/local/mysql/data -d ibmcom/mysql-s390x:8.0.13 /bin/sh -c "/usr/local/mysql/bin/mysqld --initialize --user=mysql; /usr/local/mysql/bin/mysqld_safe"
Suggested fix: Change CMD to "/usr/local/mysql/bin/mysqld --initialize --user=mysql; /usr/local/mysql/bin/mysqld_safe" with a semicolon instead of &&. This won't eliminate the error on 2nd start, but will also let the container continue to run successfully.