MySQL Docker not accessible from host

Hi,

I tries to setup MySQL server using docker using

docker run --name=mysql2 -e MYSQL_ROOT_PASSWORD=pass123 -p 3306:3306 -d mysql/mysql-server

But, it is inaccessible

Warning : mysqli::mysqli(): php_network_getaddresses: getaddrinfo failed: Name does not resolve in /var/www/html/php/mysql_test.php on line 7

Warning : mysqli::mysqli(): (HY000/2002): php_network_getaddresses: getaddrinfo failed: Name does not resolve in /var/www/html/php/mysql_test.php on line 7
Connection failed: php_network_getaddresses: getaddrinfo failed: Name does not resolve

How to solve this ?

Any idea ? I am still can’t access the MySQL server from outside docker.