Docker setup for Laravel with Nginx and MySQL. Quickly spin up a Laravel environment with optimized configurations for PHP and Nginx.
This boilerplate provides a ready-to-use Docker setup for Laravel, utilizing Nginx, PHP, MySQL, phpMyAdmin, Composer, Artisan, Node (NPM), and Mailpit for a complete development environment.
- Docker & Docker Compose installed
Clone the Repository
git clone <repo-url>
cd <repo-directory>
Configure Environment
Ensure you have a .env
file in your Laravel src
directory with the appropriate configuration. Here are the recommended settings for database and mail service:
DB_HOST=mysql
DB_DATABASE=database_name
DB_USERNAME=database_user_name
DB_PASSWORD=database_password
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_MAILER=smtp
MAIL_HOST=mailpit
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Start Docker Containers
To start all services, run:
docker compose up -d --build
The following services are configured for local development and can be accessed via the URLs below:
Service | URL | Description |
---|---|---|
Nginx | http://localhost | Serves your Laravel application. |
phpMyAdmin | http://localhost:8081 | Manage and visualize your database. |
Mailpit | http://localhost:8025 | Test email functionality locally. |
If you're having trouble logging into phpMyAdmin, ensure the following:
Correct Credentials:
Username: laravel or root
Password: secret