Can't connect to my dockerized MySQL
Since the response is Access denied for user so the port and the ip address is correct.

I guess the only issue as @James said  will be in the permission, you have to allow root access to mysql from elk and php containers, you can do it in easy way but it's not secure:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password';



%: mean match all


or you can specify who has the access per domain name or ip:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.18.0.2' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.18.0.3' IDENTIFIED BY 'password';


PS: don't forget to change the password to match you root password