Uma solução para rodar o migrate no Docker usando o Laravel Sail.
O Código de Erro que é apresentado somente no Linux(Red Hat 9). No Windows usando o WSL não apresentou esse problema
sail php artisan migrate
Illuminate\Database\QueryException
SQLSTATE[HY000] [2002] No such file or directory (Connection: mysql, SQL: select * from information_schema.tables where table_schema = larawebservice and table_name = migrations and table_type = 'BASE TABLE')
at vendor/laravel/framework/src/Illuminate/Database/Connection.php:793
789▕ // If an exception occurs when attempting to run a query, we'll format the error
790▕ // message to include the bindings with SQL, which will make this exception a
791▕ // lot more helpful to the developer instead of just the database's errors.
792▕ catch (Exception $e) {
➜ 793▕ throw new QueryException(
794▕ $this->getName(), $query, $this->prepareBindings($bindings), $e
795▕ );
796▕ }
797▕ }
+38 vendor frames
39 artisan:35
Illuminate\Foundation\Console\Kernel::handle()
No arquivo .env fiz o ajuste, Antes:
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=larawebservice
Depois:
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=larawebservice
com isso o migrate roda perfeitamente:
sail php artisan migrate
INFO Preparing database.
Creating migration table ............................. 25ms DONE
INFO Running migrations.
2014_10_12_000000_create_users_table ....................... 29ms DONE
2014_10_12_100000_create_password_reset_tokens_table ........................ 46ms DONE
2019_08_19_000000_create_failed_jobs_table .................... 31ms DONE
2019_12_14_000001_create_personal_access_tokens_table .............. 47ms DONE