I'm running a simple query on the MySQL server (5.7.20) inside Docker container. Query is run from a BASH script inside the same container. Variables are exported and defined. Credentials are checked and valid.
mysql --user="root" --password="${MYSQL_ROOT_PASSWORD}" --show-warnings --verbose -e "DROP DATABASE IF EXISTS ${MYSQL_TEST_DB};"
There is no firewall problem since the MySQL server is binned to 127.0.0.1. Running and connecting also from localhost.
/etc/hosts does have a 127.0.0.1 localhost
defined.
Service is running and I'm able to login to MySQL over CLI with the same credentials.
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN
Full error message shows
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 104
Not finding anything useful on Google or SO and running out of ideas. Most of the answers are connected to firewall or timeout answers.