MySQL official image takes up 8 minutes to start ! Should start instantly!

Issue type:

  • initialization bug with mysql:8 docker official image.

Versions:

  • Docker version 20.10.14, build a224086;
  • Linux Ubuntu 21.10 host machine OS;
  • Docker mysql:8 and mysql:oracle official image tags, both with same bug.

Steps to reproduce:

  • run mysql:8 docker official image from docker hub passing the needed args at the CLI env variables. Such as:

sudo docker run --name app-mysql-container -v [some-absolute-path-in-your-host-machine]:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=[some-root-password] -e MYSQL_DATABASE=[some-database-name] -e MYSQL_USER=[some-user-name] -e MYSQL_PASSWORD=[some-user-password] -d mysql:8

  • use another instance of the terminal to follow the logs live of the container just created:
    sudo docker --follow logs app-mysql-container

  • then use at the other instance of the terminal:
    sudo docker exec -it app-mysql-container bash , in order to get inside the container bash shell, and type:
    mysql -u root -p
    [type password]

  • ERROR HAPPENS CONTINUOUSLY until server finishes getting up - about 8 minutes !!
    ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)

  • after the 8 minutes, when the mysqld server finally gets ready for connection, with a ready socket connection at 3306 port, then everything starts working fine… both for access from inside the container (MySQL CLI) as from outside linked containers with applications connecting to the mysql server.

  • Eventually the MySQL server starts almost instantly, rather than after 8 minutes… something is wrong with this docker image…

Printscreens at the zip file below: