Prerequisites:
Docker
installed on your machine
-
Build images, volume and network by running the following:
docker-compose up -d --build
-
Install laravel by running the following:
docker-compose exec app composer create-project laravel/laravel .
-
Set your database credentials.
Database:
DB_HOST=mysql DB_PORT=3306 DB_DATABASE=app DB_USERNAME=app DB_PASSWORD=secret
-
Voila! All should be working right now.
Footnotes:
- Note that this takes a longer time to be accessible, specially when the container is freshly built. You can check the container logs to see its progress.
- Laravel artisan commands
docker-compose exec app php artisan {command}
- Laravel migrate command
docker-compose exec app php artisan migrate
- Stopping services
docker-compose stop
- Starting services
docker-compose start
- Bash
docker-compose exec app bash