Laravel development environment construction with Docker (Mac)

■ Composition

docker-laravel ├ docker-compose.yml ├ docker │  ├ php │  │  ├ php.ini │  │  └ Dockerfile │  └ nginx │    └ default.conf └ server

■ Procedure

1. Download the Docker desktop app

Download from the official website according to the procedure (easy) https://www.docker.com/products/docker-desktop

2. Start Docker.app

terminal


open /Applications/Docker.app

3. Create directory

Prepare a working folder (name is arbitrary) called docker-laravel on the desktop, Place folders and files in it with the above configuration.

4. Main files

I will omit the details (see github) ・ Docker-compose.yml ・ Dockerfile ・ Php.ini -Default.conf (nginx configuration file)

5. Start Docker and create a laravel project

・ 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.

スクリーンショット 2020-11-08 16.20.51.png

6. Also mysql

-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

Laravel development environment construction with Docker (Mac)
Environment construction with Docker (Ubuntu20.04) + Laravel + nginx
Laravel + MySQL + phpMyadmin environment construction with Docker
Rails6 development environment construction [Mac]
[Docker] Rails 5.2 environment construction with docker
React environment construction with Docker
Wordpress local environment construction & development procedure with Docker
Rails + MySQL environment construction with Docker
Node.js environment construction with Docker Compose
Environment construction with Docker for beginners
Laravel + Docker Laradock usage environment construction
Create Laravel environment with Docker (docker-compose)
[Environment construction with Docker] Rails 6 & MySQL 8
Build docker + laravel environment with laradock
Docker environment construction
[Portfolio] Manage site with laravel APP implementation (Docker environment construction)
Rails application development environment construction with Docker [Docker, Rails, Puma, Nginx, MySQL]
GPU environment construction with Docker [October 2020 version]
Rails environment construction with Docker (personal apocalypse)
Sapper × Go (echo) × Docker development environment construction
Build a PureScript development environment with Docker
Java development environment construction memo on Mac
Create Spring Boot-gradle-mysql development environment with Docker
[Docker] Development environment construction Rails6 / Ruby2.7 / MySQL8
Spring Boot + Docker Java development environment construction
Build a Wordpress development environment with Docker
Lightweight PHP 7.4 development environment created with Docker
Ruby on Rails development environment construction with Docker + VSCode (Remote Container)
PostgreSQL environment construction with Docker (from setup to just before development)
Rails Docker environment construction
java development environment construction
Spring Boot environment construction with Docker (January 2021 version)
[Jakarta EE 8 application development with Gradle] 1. Environment construction
Build a Laravel / Docker environment with VSCode devcontainer
Environment construction command memo with Docker on AWS
Build a WordPress development environment quickly with Docker
Rails6 [API mode] + MySQL5.7 environment construction with Docker
A reminder of Docker and development environment construction
Ruby on Rails development environment construction on M1 Mac
React + Django + Nginx + MySQL environment construction with Docker
[First team development ②] Build an environment with Docker
Create a Spring Boot development environment with docker
Creating a java web application development environment with docker for mac part1
[Copy and paste] Build a Laravel development environment with Docker Compose Part 2
[Copy and paste] Build a Laravel development environment with Docker Compose Participation
Create a java web application development environment with docker for mac part2
Template: Build a Ruby / Rails development environment with a Docker container (Mac version)
Pytorch execution environment with Docker
Build Java development environment with VS Code on Mac
Deploy with EC2 / Docker / Laravel
BEAR application Docker development environment construction example (docker-sync, Mutagen)
[Mac] VS Code development environment construction (Java, Gradle, Node.js)
Stable development environment construction manual for "Rails6" with "Docker-compose"
MySQL 5.7 (Docker) environment construction memo
Build Docker + Laravel PHP + Vue.js development environment in 5 minutes
[First team development ③] Share the development environment created with Docker
Java development environment (Mac, Eclipse)
Redmine (Docker) environment construction memo
Build docker environment with WSL
Build Java development environment with WSL2 Docker VS Code
How to make Laravel faster with Docker for Mac