I can’t run php artisan migrate inside container pointing out ip external

.env Lumen 6x-

DB_HOST=172.17.0.1
DB_PORT=3306
DB_DATABASE=teste
DB_USERNAME=root
DB_PASSWORD=teste

After run php artisan migrate I am getting this error:

SQLSTATE[HY000] [1045] Access denied for user ‘root’@’172.17.0.2‘ (using password: NO)

I reported this:172.17.0.1, but he used this: 172.17.0.2.

When it runs inside the container mysql -h 172.17.0.1 -u root -p it works

I have my server running apache and mysql. I installed the docker and created a container. But I can’t access my database with php artisan migrate.

Source: StackOverflow