I have a mysql service as a docker container.
Here's the config at docker-compose.yml:
version: '3'
networks:
laravel:
services:
nginx:
image: nginx:stable-alpine
container_name: nginx
ports:
- "8080:80"
volumes:
- ./src:/var/www
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
- mysql
networks:
- laravel
mysql:
image: mysql:5.7.22
container_name: mysql
restart: unless-stopped
tty: true
ports:
- "3307:3306"
environment:
MYSQL_DATABASE: homestead
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
MYSQL_ROOT_PASSWORD: secret
SERVICE_TAGS: dev
SERVICE_NAME: mysql
networks:
- laravel
php:
build:
context: .
dockerfile: Dockerfile
container_name: php
volumes:
- ./src:/var/www
ports:
- "9000:9000"
networks:
- laravel
And .env file inside laravel app:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3307
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
I can connect to container's mysql from my host:
mysql -uhomestead -p -h localhost -P 3307
and there are information_schema and homestead databases listed on show databases;
But when I try to run artisan migrate command, I get

I cannot seem to locate the issue, since I've been following this tutorial.