Can’t connect to docker mysql container via PHP

I created a docker container from mysql:5.7 image.

sudo docker run --name mysqltest -e MYSQL_ROOT_PASSWORD=password -v mysql:/var/lib/mysql -d mysql:5.7

And I Created a php container that included phpunit

sudo docker run --rm -v $(pwd):/app -w /app phpunit/phpunit:8 phpunit --testdox file.php

in file.php I’m trying to connect mysql container, via mysql container ip as host:

sudo docker inspect mysqltest

but still I get “connection Refused”, but I can connect to mysql container directly via :

sudo docker exec -it mysqltest mysql -ppassword

Please Help me, I’m really confused !

Source: StackOverflow