Laradock migrateまで

  • 環境
    Windows 10 Pro
    Docker Desctop 2.0.0.3
    PHP 7.2.15
    Laravel Framework 5.7.27
    MySQL 8.0.15
    ターミナル:Git Bash
$ git clone https://github.com/LaraDock/laradock.git
$ cd laradock
$ cp .env.example .env
$ docker-compose up -d nginx mysql workspace
$ winpty docker-compose exec --user=laradock workspace bash
$ composer create-project laravel/laravel projectxxx --prefer-dist "5.7.*"
$ docker-compose down
/laradock/.env
# Point to the path of your applications code on your host
APP_CODE_PATH_HOST=../projectxxx
$ docker-compose up -d nginx mysql workspace

localhostにアクセス

$ winpty docker-compose exec mysql bash
mysql> SELECT user, host, plugin FROM mysql.user;
+------------------+-----------+-----------------------+
| user             | host      | plugin                |
+------------------+-----------+-----------------------+
| default          | %         | caching_sha2_password |
| root             | %         | caching_sha2_password |
| mysql.infoschema | localhost | caching_sha2_password |
| mysql.session    | localhost | caching_sha2_password |
| mysql.sys        | localhost | caching_sha2_password |
| root             | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+

mysql> CREATE USER 'default'@'localhost' IDENTIFIED WITH mysql_native_password BY 'secret';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'default'@'localhost' WITH GRANT OPTION;
mysql> CREATE DATABASE IF NOT EXISTS `sandbox` COLLATE 'utf8mb4_general_ci' ;
mysql> GRANT ALL ON `sandbox`.* TO 'default'@'%' ;
mysql> FLUSH PRIVILEGES ;
  • LaravelのDB設定
.env
DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=sandbox
DB_USERNAME=default
DB_PASSWORD=secret
$ winpty docker-compose exec --user=laradock workspace bash
$ php artisan migrate