docker-laravel ├ docker-compose.yml ├ docker │ ├ php │ │ ├ php.ini │ │ └ Dockerfile │ └ nginx │ └ default.conf └ server
Download from the official website according to the procedure (easy) https://www.docker.com/products/docker-desktop
terminal
open /Applications/Docker.app
Prepare a working folder (name is arbitrary) called docker-laravel on the desktop, Place folders and files in it with the above configuration.
I will omit the details (see github) ・ Docker-compose.yml ・ Dockerfile ・ Php.ini -Default.conf (nginx configuration file)
・ Start docker (it takes a little time)
docker-compose.Run in directory with yml
$ docker-compose up -d
・ Enter the php container
python
$ docker-compose exec php bash
・ Laravel project creation
-After the following command, the Laravel project will be built under the server directory.
root@ae5eec7aea3c:/var/www#
$ composer create-project laravel/laravel docker-laravel-app(Project name)
・ Success if you can access localhost and check the top screen of laravel.
-Enter the mysql container and if you can log in, the connection is complete.
terminal
$ docker exec -it db-host-practice bash
terminal
mysql -u docker -p
Enter password:password
-Modify the .env file (match the contents of docker-compose.yml)
.env
DB_CONNECTION=mysql
DB_HOST=db-host-practice
DB_PORT=3306
DB_DATABASE=[docker-Database name defined by compose]
DB_USERNAME=[docker-Username defined in compose]
DB_PASSWORD=[docker-Password name defined in compose]
·migration
root@4ef799d9efc8:/var/www/docker-laravel-app#
php artisan migrate
Recommended Posts