Laravel with Docker | Practical Lessons
Learn Laravel with Docker through ten practical Urdu lessons: PHP, Apache, MySQL, Nginx, scheduler, Mailtrap queues, PostgreSQL, MongoDB, Composer, Node.js/npm and Supervisor. Follow English guides and working examples.
- 10 lessons
- 1h 47m
- Updated Oct 21, 2026
Watch at your own pace, right here or on YouTube.
Learn one lesson at a time
A clear path from the overview to the practical details.
Your learning workspace
Course curriculum
10 lessons · 1h 47m
Lesson 1 – Laravel Docker Setup: PHP 8.2 + Apache
Explore the project's actual Dockerfile, Docker Compose web service, Apache configuration, volume mounts, host dependency preparation, SQLite environment, and container diagnostic commands. Narration is in Urdu. This lesson documents the project's existing local HTTP setup.
What you'll learn
- Explain the PHP 8.2 + Apache Dockerfile, extensions, rewrite support and Laravel public-directory configuration.
- Understand Docker Compose web and MySQL 8.0 services, port mappings, mounts and persistent dbdata storage.
- Prepare Composer dependencies, Vite assets, and Laravel's local SQLite environment on the host.
- Build, start and inspect the containers, and distinguish database service startup from Laravel connection configuration and database readiness.
- Explain the Nginx/PHP-FPM request path, FastCGI forwarding, Compose ports and mounts, and identify syntax and image-build gaps in the lesson-3 snapshot.
- Run Laravel scheduled tasks every five seconds in a dedicated Docker service and display synthetic users in a paginated, auto-refreshing Blade view.
- Queue an email in MySQL, process it in a separate Docker worker and render a Blade Mailable for Mailtrap Sandbox, with retries and configuration reloads.
- Connect Laravel to PostgreSQL in Docker, configure PDO PostgreSQL, preserve database storage and verify migrations and connectivity.
- Authenticate Laravel with MongoDB using named credentials, install the PHP driver inside Docker and create and display notes with the MongoDB Eloquent model.
- Install Composer in the PHP Docker image, install locked dependencies at build time and manage runtime vendor volumes and Composer cache permissions.
- Run Node.js and npm inside Docker, install locked frontend dependencies and build working Laravel Vite assets.
- Manage PHP-FPM and Nginx together with Supervisor, inspect process status and logs, and understand graceful restarts and shutdown.
The bigger picture
About this course
Course source code and lesson snapshots
The Laravel Docker lessons repository on GitLab contains the source used throughout this series. Each lesson-N tag preserves a lesson snapshot; main contains later work and may not match the video you are following.
Start with the repository lesson index and setup and correction checklist. Lesson 3 has historical configuration errors documented in its written guide; Lesson 4 carries the Nginx corrections. For MongoDB, use the corrected lesson-7.1 snapshot described in Lesson 7.
The course currently lists ten video lessons. The repository also includes Lesson 11 on Redis; its written Redis queue and cache guide is available separately.
Learn Laravel and Docker through practical lessons based on a real project's implementation. Video narration is in Urdu, with English guides for the configuration files and commands.
Lesson 1: Laravel with PHP 8.2 and Apache
The first lesson explains the existing local Docker setup for a Laravel 12 application: a PHP 8.2 + Apache image, one Docker Compose web service, port mapping from localhost:8081 to container port 80, and Apache's document root at /var/www/html/public.
It covers the project bind mount, anonymous volumes for storage and bootstrap/cache, preparing Composer dependencies and Vite assets on the host, the existing SQLite environment, Laravel migrations, and commands for building, starting, and inspecting the containers.
Read Lesson 1: Deploying Laravel with Docker
Lesson 2: Apache, PHP & MySQL Setup
Lesson 2 follows the lesson-2 Git tag, commit 189d683. It documents the PHP 8.2 + Apache Dockerfile, ZIP and PDO MySQL extensions, Apache mod_rewrite, Laravel directory permissions and the public-directory virtual host with AllowOverride All and Require all granted.
Docker Compose runs separate web and db services. The application is exposed on localhost:8081; MySQL 8.0 uses host port 3307 and container port 3306, creates the laravel_app database and stores its data in the dbdata volume. The lesson covers service dependencies, mounts and commands for building, starting and inspecting the containers.
The tagged .env.example still selects SQLite. The Compose dependency defines startup order without a database readiness health check, and MYSQL_PASSWORD is specified without MYSQL_USER. The written guide explains these snapshot details without treating them as a completed Laravel MySQL connection or a separate application database user.
Read the Lesson 2 written tutorial
Lesson 3: Nginx, PHP & MySQL Setup
Lesson 3 follows the lesson-3 Git tag, commit 640e6e7. The Dockerfile changes to php:8.2-fpm, with ZIP and PDO MySQL extensions. Docker Compose separates the web, nginx and db services. Nginx serves Laravel's public directory and is intended to forward PHP requests to web:9000 using FastCGI.
The HTTP mapping is 8080:80, while MySQL 8.0 maps 3308:3306 and keeps the persistent dbdata volume. The lesson explores project mounts, directory permissions and the transition from Apache to Nginx/PHP-FPM.
The tagged Nginx file contains syntax errors, and Compose references my-laravel-app without a build definition. The written guide explains these snapshot issues and validation commands. The tagged environment still defaults to SQLite; service startup does not establish Laravel's MySQL connection.
Read the Lesson 3 written tutorial
Lesson 4: Laravel Scheduler & Cron Jobs with Docker
Build an Artisan command that creates one synthetic test user, then run it approximately every five seconds with Laravel's scheduler in a separate Docker Compose service. Learn the opt-in scheduler profile, MySQL connection settings and overlap protection for the single scheduler container.
Display generated users on a Blade page with pagination, UTC creation times, manual refresh and optional five-second auto-refresh. The lesson also includes the corrected Nginx setup carried forward from Lesson 3 and explains how to stop the scheduler after the demonstration. These synthetic example.com addresses are not emailed.
Read Lesson 4, including the complete users-view Blade code.
Lesson 5: Laravel Queue Jobs & Mailtrap with Docker
Dispatch one email job from an Artisan command to the MySQL database queue, then process it in a separate Docker Compose worker. Build a Mailable with HTML and plain-text Blade templates and preview the email through its read-only route.
Configure Mailtrap Email Sandbox using the existing MAIL_* environment keys. Learn the dedicated emails queue, retries, failed jobs and worker restarts. A queued message is separate from successful SMTP submission; use your own private sandbox credentials.
Read Lesson 5, including routes, mail configuration and the full queue implementation.
Watch the Laravel with Docker course on YouTube
New lessons will be added as the project develops.
Lesson 6: Laravel PostgreSQL Setup with Docker
Connect Laravel to PostgreSQL 17 using a separate Docker Compose configuration. Install the PDO PostgreSQL extension in PHP, configure database credentials, retain persistent storage and verify migrations and the connection.
Read the complete Lesson 6 guide and Compose files.
Lesson 7: Laravel MongoDB Setup with Docker
Run authenticated MongoDB in Docker with separate username and password settings. Install the native PHP extension inside Docker, create notes through the MongoDB Eloquent model and show them on a Blade page. The guide includes matching Composer lock files and the correct Model import.
Read the corrected Lesson 7 guide and troubleshooting steps.
Lesson 8: Install Composer in a Docker Container
Copy Composer 2 from its official image into the PHP container and install dependencies from composer.lock during the Docker build. Understand .dockerignore, the anonymous vendor volume, Composer commands inside Docker and cache permissions for the www-data user.
Read the complete Lesson 8 guide, Dockerfile and commands.
Lesson 9: Install Node.js & NPM in Docker
Add Node.js 22 and npm to the PHP image. Install locked frontend dependencies, isolate Linux node_modules and build Vite assets for a working Blade and JavaScript demo.
Read the complete Lesson 9 guide.
Lesson 10: PHP & Nginx with Supervisor in Docker
Run PHP-FPM and Nginx together in an optional combined container. Configure Supervisor, inspect foreground processes and logs, and understand local FastCGI routing, restarts and graceful shutdown.
Read the complete Lesson 10 guide.
Open the code for your lesson
Lesson 1 – Laravel Docker Setup: PHP 8.2 + Apache — source snapshot
Lesson 4: Laravel Scheduler & Cron Jobs with Docker — source snapshot
Lesson 5: Laravel Queue Jobs & Mailtrap with Docker — source snapshot
Lesson 6: Laravel PostgreSQL Setup with Docker — source snapshot
Lesson 7: Laravel MongoDB Setup with Docker — source snapshot
Lesson 8: Install Composer in a Docker Container — source snapshot
Lesson 10: PHP & Nginx with Supervisor in Docker — source snapshot
Before you begin
Who this course is for
Laravel developers learning to run and inspect an existing application with Docker. Video narration is in Urdu, with an English written tutorial.
What you'll need
- Basic Laravel and command-line familiarity.
- Docker with Docker Compose installed.
- Composer and Node.js/npm for preparing host dependencies and assets.
- An existing Laravel application.
YouTube Channel
Build Along With Me
Practical walkthroughs on Laravel, React, APIs and deployment workflows.
What Does Your Application Need Next?
Share your current system, the problem you want to solve and what a useful result looks like. We can identify the right starting point and agree on a practical scope.
Technical Audit
Find the Next Useful Fix
Application Development
Scoped, Reviewable Milestones
Ongoing Support
Agreed Capacity and Priorities
Share your goals, current stack and requirements before the call.

