Laravel Docker Apache Configuration using Docker-compose Example

By Hardik Savani December 21, 2023 Category : Laravel

Hi Guys,

This tutorial will provide an example of laravel docker apache configuration. In this article, we will implement a laravel docker 000-default.conf file. If you have a question about install laravel docker with apache example then I will give a simple example with a solution. This example will help you laravel docker compose apache configuration.

In this example, we will simply setup docker-compose for laravel application. we will create apache default.conf configuration file and setup path and permission. You can see the simple steps:

Now, we will start step by step setup laravel 10 project with docker compose.

Step 1: Install Laravel 10

This step is not required; however, if you have not created the laravel app, then you may go ahead and execute the below command:

composer create-project laravel/laravel example-app

Step 2: Create a Dockerfile

Create a file named "Dockerfile" in the root of your Laravel project with the following content:


FROM php:8.2-apache

WORKDIR /var/www/html

RUN apt-get update && apt-get install -y \

libzip-dev \

unzip \

&& docker-php-ext-install zip pdo_mysql

COPY . /var/www/html/

RUN chown -R www-data:www-data /var/www/html/storage /var/www/html/bootstrap/cache

RUN chmod -R 775 /var/www/html/storage /var/www/html/bootstrap/cache


Step 3: Create a VirtualHost Configuration

Create a file named "default.conf" in the ".docker/apache" directory (you may need to create the .docker/apache directory) with the following content:


<VirtualHost *:80>

DocumentRoot /var/www/html/public

<Directory /var/www/html>

AllowOverride All

Require all granted


ErrorLog ${APACHE_LOG_DIR}/error.log

CustomLog ${APACHE_LOG_DIR}/access.log combined


Step 4: Create a docker-compose.yml File

Create a file named "docker-compose.yml" in the root of your Laravel project with the following content:


version: '3'




context: .

dockerfile: Dockerfile

image: my-laravel-app


- "8080:80"


- .:/var/www/html

- ./.docker/apache/default.conf:/etc/apache2/sites-enabled/000-default.conf

Step 5: Build and Run Docker Containers

Run the following commands to build and run your Docker containers:

docker-compose up -d --build

You can check your port "8080" is running or not by using follow command:

docker-compose ps

Then you can check following url on browser and check it will works:



I hope it can help you...

Tags :