Dockerize Your Laravel Application

Share this post on:

How to Install Laravel with Docker

Before we dive into the installation steps, make sure you have the necessary system requirements and Windows edition to run Docker Desktop. Here’s a simplified guide to get Laravel up and running with Docker.

System Requirements

  • Windows 11 (64-bit): Home or Pro version 21H2 or higher, or Enterprise or Education version 21H2 or higher.
  • Windows 10 (64-bit): Home or Pro 21H2 (build 19045) or higher, or Enterprise or Education 21H2 (build 19045) or higher.
  • Ensure WSL 2 (Windows Subsystem for Linux 2) is enabled on Windows. Refer to Microsoft’s documentation for instructions.

Hardware Prerequisites

For Windows 10 or 11, you’ll need:

  • 64-bit processor with Second Level Address Translation (SLAT)
  • 4GB system RAM
  • BIOS-level hardware virtualization support enabled

Important Note

Running Windows containers requires Windows 10 or 11 Professional or Enterprise edition. Windows Home or Education editions only support Linux containers.

Installation Steps

  1. Download Docker Desktop for Windows from their official website.
  2. Run the installer by double-clicking on “Docker Desktop Installer.exe.”
  3. During installation, select the “Use WSL 2 instead of Hyper-V” option if available.
    • Note: If your system supports only one option, you won’t have a choice in the backend.
  4. Follow the installation wizard’s instructions to authorize the installer and complete the process.
  5. After successful installation, select “Close.” Docker will ask you to log out and back into your Windows session or restart your machine to finish the installation.

Starting Docker Desktop

After the restart:

  1. Start Docker Desktop by searching for it in the start menu.
  2. The first time you run Docker, it may take a few minutes to configure itself.
  3. Open a command prompt or PowerShell window.
  4. Run the command docker --version to ensure Docker is installed and running.

Setting Up Laravel with Docker

Dockerfile

Create a Dockerfile in your Laravel project’s root directory with the following content:

docker-compose.yml

Create a docker-compose.yml file in your Laravel project’s root directory:

Running Docker Containers

  1. Navigate to your Laravel project’s base directory in the command prompt.
  2. Execute docker-compose build to build the Docker containers.
  3. Launch the application with docker-compose up.
  4. Access the Docker container with docker exec -it laravel-docker bash. Replace “laravel-docker” with your container’s name if different.

Install Laravel and Configure Database

  1. Install Laravel using the command: composer create-project laravel/laravel .
  2. Once Laravel is installed, execute the exit command.

Modify the .env File

Update the database connection details in the .env file with these settings:

Execute Migrations

Run the migrations using the following command:

Now, your Laravel project should be accessible at http://localhost:9000/public/, and you can manage your database with PHPMyAdmin at http://localhost:9001/. Enjoy developing with Laravel and Docker!

Share this post on:

BlogAdmin

Digital Transformation Counsultant (Public Sector)

25+ years experience
UK public sector & enterprise specialist
Board-level commercial leadership
Technology & consultancy expertise

Core Technologies

Business Development 95%
Digital Transformation 92%
Public Sector Solutions 90%
Cloud & AWS Partnerships 85%
  • Public Sector: Government & enterprise solution engagement
  • Commercial: Consultative business development, stakeholder management
  • Technology: Digital services, cloud-led transformation solutions
  • Leadership: Board-level advisory, operational efficiency & innovation
  • Backend: Business transformation strategy, programme delivery, solution consulting
  • Public Sector
  • Enterprise Technology
  • Consulting & Advisory
  • Programme Delivery
  • Cloud & Digital Services
  • Solving complex business challanges through technology-led innovaion
  • Combining consultancy, and delivery expertise
  • Building long-term partnershipis across enterprise & government sectors
  • Driving transformation with practical, outcome-focused solutions
  • Aligning technology investments with operational and commercial goals

BlogAdmin is an experienced digital transformation leader (public sector) with a strong track record of helping organizations solve complex operational and technology challanges through innovative commercial and technical solutions.

With extensive experience spanning consultancy, programme delivery, cloud partnerships, and strategic business dvelopment, he has worked across multiple sectors including public sector, enterprise technology, and digital services.

He brings a rare combinatioin of board-level commercial leadership and hands-on delivery understanding, enabling him to bridge the gap between business objectives and technology execution.

BlogAdmin is paricularly experienced in consultative selling, AWS partnership ecosystems, public sector engagement, and designing commercially viable transformation strategies that combine technology, services and operational efficiency.

Known for his ability to thinik differently around business challanges, he focuses on creating scalable, innovative solutions that help organizations modernize operations, improve service delivery, and accelarate digital transformation initiatives.

    Reach Out Us


    Your name

    Your email

    Subject

    Your message